ホーム › Networking.Ldap › ldap_simple_bind
ldap_simple_bind
関数DNとパスワードで非同期に簡易バインドする。
シグネチャ
// WLDAP32.dll (ANSI / -A)
#include <windows.h>
DWORD ldap_simple_bind(
LDAP* ld,
LPCSTR dn, // optional
LPCSTR passwd // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ld | LDAP* | inout |
| dn | LPCSTR | inoptional |
| passwd | LPCSTR | inoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// WLDAP32.dll (ANSI / -A)
#include <windows.h>
DWORD ldap_simple_bind(
LDAP* ld,
LPCSTR dn, // optional
LPCSTR passwd // optional
);[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_simple_bind(
IntPtr ld, // LDAP* in/out
[MarshalAs(UnmanagedType.LPStr)] string dn, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string passwd // LPCSTR optional
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_simple_bind(
ld As IntPtr, ' LDAP* in/out
<MarshalAs(UnmanagedType.LPStr)> dn As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> passwd As String ' LPCSTR optional
) As UInteger
End Function' ld : LDAP* in/out
' dn : LPCSTR optional
' passwd : LPCSTR optional
Declare PtrSafe Function ldap_simple_bind Lib "wldap32" ( _
ByVal ld As LongPtr, _
ByVal dn As String, _
ByVal passwd As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ldap_simple_bind = ctypes.cdll.wldap32.ldap_simple_bind
ldap_simple_bind.restype = wintypes.DWORD
ldap_simple_bind.argtypes = [
ctypes.c_void_p, # ld : LDAP* in/out
wintypes.LPCSTR, # dn : LPCSTR optional
wintypes.LPCSTR, # passwd : LPCSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_simple_bind = Fiddle::Function.new(
lib['ldap_simple_bind'],
[
Fiddle::TYPE_VOIDP, # ld : LDAP* in/out
Fiddle::TYPE_VOIDP, # dn : LPCSTR optional
Fiddle::TYPE_VOIDP, # passwd : LPCSTR optional
],
-Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "wldap32")]
extern "C" {
fn ldap_simple_bind(
ld: *mut LDAP, // LDAP* in/out
dn: *const u8, // LPCSTR optional
passwd: *const u8 // LPCSTR optional
) -> 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_simple_bind(IntPtr ld, [MarshalAs(UnmanagedType.LPStr)] string dn, [MarshalAs(UnmanagedType.LPStr)] string passwd);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_simple_bind' -Namespace Win32 -PassThru
# $api::ldap_simple_bind(ld, dn, passwd)#uselib "WLDAP32.dll"
#func global ldap_simple_bind "ldap_simple_bind" sptr, sptr, sptr
; ldap_simple_bind varptr(ld), dn, passwd ; 戻り値は stat
; ld : LDAP* in/out -> "sptr"
; dn : LPCSTR optional -> "sptr"
; passwd : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WLDAP32.dll" #cfunc global ldap_simple_bind "ldap_simple_bind" var, str, str ; res = ldap_simple_bind(ld, dn, passwd) ; ld : LDAP* in/out -> "var" ; dn : LPCSTR optional -> "str" ; passwd : LPCSTR optional -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ldap_simple_bind "ldap_simple_bind" sptr, str, str ; res = ldap_simple_bind(varptr(ld), dn, passwd) ; ld : LDAP* in/out -> "sptr" ; dn : LPCSTR optional -> "str" ; passwd : LPCSTR optional -> "str" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ldap_simple_bind(LDAP* ld, LPCSTR dn, LPCSTR passwd) #uselib "WLDAP32.dll" #cfunc global ldap_simple_bind "ldap_simple_bind" var, str, str ; res = ldap_simple_bind(ld, dn, passwd) ; ld : LDAP* in/out -> "var" ; dn : LPCSTR optional -> "str" ; passwd : LPCSTR optional -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ldap_simple_bind(LDAP* ld, LPCSTR dn, LPCSTR passwd) #uselib "WLDAP32.dll" #cfunc global ldap_simple_bind "ldap_simple_bind" intptr, str, str ; res = ldap_simple_bind(varptr(ld), dn, passwd) ; ld : LDAP* in/out -> "intptr" ; dn : LPCSTR optional -> "str" ; passwd : LPCSTR optional -> "str" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_simple_bind = wldap32.NewProc("ldap_simple_bind")
)
// ld (LDAP* in/out), dn (LPCSTR optional), passwd (LPCSTR optional)
r1, _, err := procldap_simple_bind.Call(
uintptr(ld),
uintptr(unsafe.Pointer(windows.BytePtrFromString(dn))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(passwd))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ldap_simple_bind(
ld: Pointer; // LDAP* in/out
dn: PAnsiChar; // LPCSTR optional
passwd: PAnsiChar // LPCSTR optional
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_simple_bind';result := DllCall("WLDAP32\ldap_simple_bind"
, "Ptr", ld ; LDAP* in/out
, "AStr", dn ; LPCSTR optional
, "AStr", passwd ; LPCSTR optional
, "Cdecl UInt") ; return: DWORD●ldap_simple_bind(ld, dn, passwd) = DLL("WLDAP32.dll", "dword ldap_simple_bind(void*, char*, char*)")
# 呼び出し: ldap_simple_bind(ld, dn, passwd)
# ld : LDAP* in/out -> "void*"
# dn : LPCSTR optional -> "char*"
# passwd : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。