Win32 API 日本語リファレンス
ホームNetworking.Ldap › ldap_add_ext_s

ldap_add_ext_s

関数
コントロール指定付きでLDAPエントリを同期的に追加する。
DLLWLDAP32.dll文字セットANSI (-A)呼出規約cdecl対応OSWindows Vista 以降

シグネチャ

// WLDAP32.dll  (ANSI / -A)
#include <windows.h>

DWORD ldap_add_ext_s(
    LDAP* ld,
    LPCSTR dn,
    LDAPModA** attrs,
    LDAPControlA** ServerControls,
    LDAPControlA** ClientControls
);

パラメーター

名前方向
ldLDAP*inout
dnLPCSTRin
attrsLDAPModA**inout
ServerControlsLDAPControlA**inout
ClientControlsLDAPControlA**inout

戻り値の型: DWORD

各言語での呼び出し定義

// WLDAP32.dll  (ANSI / -A)
#include <windows.h>

DWORD ldap_add_ext_s(
    LDAP* ld,
    LPCSTR dn,
    LDAPModA** attrs,
    LDAPControlA** ServerControls,
    LDAPControlA** ClientControls
);
[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_add_ext_s(
    IntPtr ld,   // LDAP* in/out
    [MarshalAs(UnmanagedType.LPStr)] string dn,   // LPCSTR
    IntPtr attrs,   // LDAPModA** in/out
    IntPtr ServerControls,   // LDAPControlA** in/out
    IntPtr ClientControls   // LDAPControlA** in/out
);
<DllImport("WLDAP32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_add_ext_s(
    ld As IntPtr,   ' LDAP* in/out
    <MarshalAs(UnmanagedType.LPStr)> dn As String,   ' LPCSTR
    attrs As IntPtr,   ' LDAPModA** in/out
    ServerControls As IntPtr,   ' LDAPControlA** in/out
    ClientControls As IntPtr   ' LDAPControlA** in/out
) As UInteger
End Function
' ld : LDAP* in/out
' dn : LPCSTR
' attrs : LDAPModA** in/out
' ServerControls : LDAPControlA** in/out
' ClientControls : LDAPControlA** in/out
Declare PtrSafe Function ldap_add_ext_s Lib "wldap32" ( _
    ByVal ld As LongPtr, _
    ByVal dn As String, _
    ByVal attrs As LongPtr, _
    ByVal ServerControls As LongPtr, _
    ByVal ClientControls As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ldap_add_ext_s = ctypes.cdll.wldap32.ldap_add_ext_s
ldap_add_ext_s.restype = wintypes.DWORD
ldap_add_ext_s.argtypes = [
    ctypes.c_void_p,  # ld : LDAP* in/out
    wintypes.LPCSTR,  # dn : LPCSTR
    ctypes.c_void_p,  # attrs : LDAPModA** in/out
    ctypes.c_void_p,  # ServerControls : LDAPControlA** in/out
    ctypes.c_void_p,  # ClientControls : LDAPControlA** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WLDAP32.dll')
ldap_add_ext_s = Fiddle::Function.new(
  lib['ldap_add_ext_s'],
  [
    Fiddle::TYPE_VOIDP,  # ld : LDAP* in/out
    Fiddle::TYPE_VOIDP,  # dn : LPCSTR
    Fiddle::TYPE_VOIDP,  # attrs : LDAPModA** in/out
    Fiddle::TYPE_VOIDP,  # ServerControls : LDAPControlA** in/out
    Fiddle::TYPE_VOIDP,  # ClientControls : LDAPControlA** in/out
  ],
  -Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "wldap32")]
extern "C" {
    fn ldap_add_ext_s(
        ld: *mut LDAP,  // LDAP* in/out
        dn: *const u8,  // LPCSTR
        attrs: *mut *mut LDAPModA,  // LDAPModA** in/out
        ServerControls: *mut *mut LDAPControlA,  // LDAPControlA** in/out
        ClientControls: *mut *mut LDAPControlA  // LDAPControlA** in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ldap_add_ext_s(IntPtr ld, [MarshalAs(UnmanagedType.LPStr)] string dn, IntPtr attrs, IntPtr ServerControls, IntPtr ClientControls);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_add_ext_s' -Namespace Win32 -PassThru
# $api::ldap_add_ext_s(ld, dn, attrs, ServerControls, ClientControls)
#uselib "WLDAP32.dll"
#func global ldap_add_ext_s "ldap_add_ext_s" sptr, sptr, sptr, sptr, sptr
; ldap_add_ext_s varptr(ld), dn, varptr(attrs), varptr(ServerControls), varptr(ClientControls)   ; 戻り値は stat
; ld : LDAP* in/out -> "sptr"
; dn : LPCSTR -> "sptr"
; attrs : LDAPModA** in/out -> "sptr"
; ServerControls : LDAPControlA** in/out -> "sptr"
; ClientControls : LDAPControlA** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WLDAP32.dll"
#cfunc global ldap_add_ext_s "ldap_add_ext_s" var, str, var, var, var
; res = ldap_add_ext_s(ld, dn, attrs, ServerControls, ClientControls)
; ld : LDAP* in/out -> "var"
; dn : LPCSTR -> "str"
; attrs : LDAPModA** in/out -> "var"
; ServerControls : LDAPControlA** in/out -> "var"
; ClientControls : LDAPControlA** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD ldap_add_ext_s(LDAP* ld, LPCSTR dn, LDAPModA** attrs, LDAPControlA** ServerControls, LDAPControlA** ClientControls)
#uselib "WLDAP32.dll"
#cfunc global ldap_add_ext_s "ldap_add_ext_s" var, str, var, var, var
; res = ldap_add_ext_s(ld, dn, attrs, ServerControls, ClientControls)
; ld : LDAP* in/out -> "var"
; dn : LPCSTR -> "str"
; attrs : LDAPModA** in/out -> "var"
; ServerControls : LDAPControlA** in/out -> "var"
; ClientControls : LDAPControlA** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
	procldap_add_ext_s = wldap32.NewProc("ldap_add_ext_s")
)

// ld (LDAP* in/out), dn (LPCSTR), attrs (LDAPModA** in/out), ServerControls (LDAPControlA** in/out), ClientControls (LDAPControlA** in/out)
r1, _, err := procldap_add_ext_s.Call(
	uintptr(ld),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(dn))),
	uintptr(attrs),
	uintptr(ServerControls),
	uintptr(ClientControls),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ldap_add_ext_s(
  ld: Pointer;   // LDAP* in/out
  dn: PAnsiChar;   // LPCSTR
  attrs: Pointer;   // LDAPModA** in/out
  ServerControls: Pointer;   // LDAPControlA** in/out
  ClientControls: Pointer   // LDAPControlA** in/out
): DWORD; cdecl;
  external 'WLDAP32.dll' name 'ldap_add_ext_s';
result := DllCall("WLDAP32\ldap_add_ext_s"
    , "Ptr", ld   ; LDAP* in/out
    , "AStr", dn   ; LPCSTR
    , "Ptr", attrs   ; LDAPModA** in/out
    , "Ptr", ServerControls   ; LDAPControlA** in/out
    , "Ptr", ClientControls   ; LDAPControlA** in/out
    , "Cdecl UInt")   ; return: DWORD
●ldap_add_ext_s(ld, dn, attrs, ServerControls, ClientControls) = DLL("WLDAP32.dll", "dword ldap_add_ext_s(void*, char*, void*, void*, void*)")
# 呼び出し: ldap_add_ext_s(ld, dn, attrs, ServerControls, ClientControls)
# ld : LDAP* in/out -> "void*"
# dn : LPCSTR -> "char*"
# attrs : LDAPModA** in/out -> "void*"
# ServerControls : LDAPControlA** in/out -> "void*"
# ClientControls : LDAPControlA** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。