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

ldap_simple_bindW

関数
DNとパスワードで非同期に簡易バインドする(Unicode版)。
DLLWLDAP32.dll文字セットUnicode (-W)呼出規約cdecl対応OSWindows Vista 以降

シグネチャ

// WLDAP32.dll  (Unicode / -W)
#include <windows.h>

DWORD ldap_simple_bindW(
    LDAP* ld,
    LPWSTR dn,   // optional
    LPWSTR passwd   // optional
);

パラメーター

名前方向
ldLDAP*inout
dnLPWSTRinoptional
passwdLPWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

// WLDAP32.dll  (Unicode / -W)
#include <windows.h>

DWORD ldap_simple_bindW(
    LDAP* ld,
    LPWSTR dn,   // optional
    LPWSTR passwd   // optional
);
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_simple_bindW(
    IntPtr ld,   // LDAP* in/out
    [MarshalAs(UnmanagedType.LPWStr)] string dn,   // LPWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string passwd   // LPWSTR optional
);
<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_simple_bindW(
    ld As IntPtr,   ' LDAP* in/out
    <MarshalAs(UnmanagedType.LPWStr)> dn As String,   ' LPWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> passwd As String   ' LPWSTR optional
) As UInteger
End Function
' ld : LDAP* in/out
' dn : LPWSTR optional
' passwd : LPWSTR optional
Declare PtrSafe Function ldap_simple_bindW Lib "wldap32" ( _
    ByVal ld As LongPtr, _
    ByVal dn As LongPtr, _
    ByVal passwd As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ldap_simple_bindW = ctypes.cdll.wldap32.ldap_simple_bindW
ldap_simple_bindW.restype = wintypes.DWORD
ldap_simple_bindW.argtypes = [
    ctypes.c_void_p,  # ld : LDAP* in/out
    wintypes.LPCWSTR,  # dn : LPWSTR optional
    wintypes.LPCWSTR,  # passwd : LPWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WLDAP32.dll')
ldap_simple_bindW = Fiddle::Function.new(
  lib['ldap_simple_bindW'],
  [
    Fiddle::TYPE_VOIDP,  # ld : LDAP* in/out
    Fiddle::TYPE_VOIDP,  # dn : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # passwd : LPWSTR optional
  ],
  -Fiddle::TYPE_INT, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wldap32")]
extern "C" {
    fn ldap_simple_bindW(
        ld: *mut LDAP,  // LDAP* in/out
        dn: *mut u16,  // LPWSTR optional
        passwd: *mut u16  // LPWSTR optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ldap_simple_bindW(IntPtr ld, [MarshalAs(UnmanagedType.LPWStr)] string dn, [MarshalAs(UnmanagedType.LPWStr)] string passwd);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_simple_bindW' -Namespace Win32 -PassThru
# $api::ldap_simple_bindW(ld, dn, passwd)
#uselib "WLDAP32.dll"
#func global ldap_simple_bindW "ldap_simple_bindW" wptr, wptr, wptr
; ldap_simple_bindW varptr(ld), dn, passwd   ; 戻り値は stat
; ld : LDAP* in/out -> "wptr"
; dn : LPWSTR optional -> "wptr"
; passwd : LPWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WLDAP32.dll"
#cfunc global ldap_simple_bindW "ldap_simple_bindW" var, wstr, wstr
; res = ldap_simple_bindW(ld, dn, passwd)
; ld : LDAP* in/out -> "var"
; dn : LPWSTR optional -> "wstr"
; passwd : LPWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD ldap_simple_bindW(LDAP* ld, LPWSTR dn, LPWSTR passwd)
#uselib "WLDAP32.dll"
#cfunc global ldap_simple_bindW "ldap_simple_bindW" var, wstr, wstr
; res = ldap_simple_bindW(ld, dn, passwd)
; ld : LDAP* in/out -> "var"
; dn : LPWSTR optional -> "wstr"
; passwd : LPWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
	procldap_simple_bindW = wldap32.NewProc("ldap_simple_bindW")
)

// ld (LDAP* in/out), dn (LPWSTR optional), passwd (LPWSTR optional)
r1, _, err := procldap_simple_bindW.Call(
	uintptr(ld),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(dn))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(passwd))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ldap_simple_bindW(
  ld: Pointer;   // LDAP* in/out
  dn: PWideChar;   // LPWSTR optional
  passwd: PWideChar   // LPWSTR optional
): DWORD; cdecl;
  external 'WLDAP32.dll' name 'ldap_simple_bindW';
result := DllCall("WLDAP32\ldap_simple_bindW"
    , "Ptr", ld   ; LDAP* in/out
    , "WStr", dn   ; LPWSTR optional
    , "WStr", passwd   ; LPWSTR optional
    , "Cdecl UInt")   ; return: DWORD
●ldap_simple_bindW(ld, dn, passwd) = DLL("WLDAP32.dll", "dword ldap_simple_bindW(void*, char*, char*)")
# 呼び出し: ldap_simple_bindW(ld, dn, passwd)
# ld : LDAP* in/out -> "void*"
# dn : LPWSTR optional -> "char*"
# passwd : LPWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。