ホーム › Networking.Ldap › ldap_sasl_bind_sW
ldap_sasl_bind_sW
関数SASL認証で同期的にバインドする(Unicode版)。
シグネチャ
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
INT ldap_sasl_bind_sW(
LDAP* ExternalHandle,
LPCWSTR DistName,
LPCWSTR AuthMechanism,
const LDAP_BERVAL* cred,
LDAPControlW** ServerCtrls,
LDAPControlW** ClientCtrls,
LDAP_BERVAL** ServerData
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ExternalHandle | LDAP* | inout |
| DistName | LPCWSTR | in |
| AuthMechanism | LPCWSTR | in |
| cred | LDAP_BERVAL* | in |
| ServerCtrls | LDAPControlW** | inout |
| ClientCtrls | LDAPControlW** | inout |
| ServerData | LDAP_BERVAL** | inout |
戻り値の型: INT
各言語での呼び出し定義
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
INT ldap_sasl_bind_sW(
LDAP* ExternalHandle,
LPCWSTR DistName,
LPCWSTR AuthMechanism,
const LDAP_BERVAL* cred,
LDAPControlW** ServerCtrls,
LDAPControlW** ClientCtrls,
LDAP_BERVAL** ServerData
);[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ldap_sasl_bind_sW(
IntPtr ExternalHandle, // LDAP* in/out
[MarshalAs(UnmanagedType.LPWStr)] string DistName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string AuthMechanism, // LPCWSTR
IntPtr cred, // LDAP_BERVAL*
IntPtr ServerCtrls, // LDAPControlW** in/out
IntPtr ClientCtrls, // LDAPControlW** in/out
IntPtr ServerData // LDAP_BERVAL** in/out
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_sasl_bind_sW(
ExternalHandle As IntPtr, ' LDAP* in/out
<MarshalAs(UnmanagedType.LPWStr)> DistName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> AuthMechanism As String, ' LPCWSTR
cred As IntPtr, ' LDAP_BERVAL*
ServerCtrls As IntPtr, ' LDAPControlW** in/out
ClientCtrls As IntPtr, ' LDAPControlW** in/out
ServerData As IntPtr ' LDAP_BERVAL** in/out
) As Integer
End Function' ExternalHandle : LDAP* in/out
' DistName : LPCWSTR
' AuthMechanism : LPCWSTR
' cred : LDAP_BERVAL*
' ServerCtrls : LDAPControlW** in/out
' ClientCtrls : LDAPControlW** in/out
' ServerData : LDAP_BERVAL** in/out
Declare PtrSafe Function ldap_sasl_bind_sW Lib "wldap32" ( _
ByVal ExternalHandle As LongPtr, _
ByVal DistName As LongPtr, _
ByVal AuthMechanism As LongPtr, _
ByVal cred As LongPtr, _
ByVal ServerCtrls As LongPtr, _
ByVal ClientCtrls As LongPtr, _
ByVal ServerData 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_sasl_bind_sW = ctypes.cdll.wldap32.ldap_sasl_bind_sW
ldap_sasl_bind_sW.restype = ctypes.c_int
ldap_sasl_bind_sW.argtypes = [
ctypes.c_void_p, # ExternalHandle : LDAP* in/out
wintypes.LPCWSTR, # DistName : LPCWSTR
wintypes.LPCWSTR, # AuthMechanism : LPCWSTR
ctypes.c_void_p, # cred : LDAP_BERVAL*
ctypes.c_void_p, # ServerCtrls : LDAPControlW** in/out
ctypes.c_void_p, # ClientCtrls : LDAPControlW** in/out
ctypes.c_void_p, # ServerData : LDAP_BERVAL** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_sasl_bind_sW = Fiddle::Function.new(
lib['ldap_sasl_bind_sW'],
[
Fiddle::TYPE_VOIDP, # ExternalHandle : LDAP* in/out
Fiddle::TYPE_VOIDP, # DistName : LPCWSTR
Fiddle::TYPE_VOIDP, # AuthMechanism : LPCWSTR
Fiddle::TYPE_VOIDP, # cred : LDAP_BERVAL*
Fiddle::TYPE_VOIDP, # ServerCtrls : LDAPControlW** in/out
Fiddle::TYPE_VOIDP, # ClientCtrls : LDAPControlW** in/out
Fiddle::TYPE_VOIDP, # ServerData : LDAP_BERVAL** in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wldap32")]
extern "C" {
fn ldap_sasl_bind_sW(
ExternalHandle: *mut LDAP, // LDAP* in/out
DistName: *const u16, // LPCWSTR
AuthMechanism: *const u16, // LPCWSTR
cred: *const LDAP_BERVAL, // LDAP_BERVAL*
ServerCtrls: *mut *mut LDAPControlW, // LDAPControlW** in/out
ClientCtrls: *mut *mut LDAPControlW, // LDAPControlW** in/out
ServerData: *mut *mut LDAP_BERVAL // LDAP_BERVAL** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int ldap_sasl_bind_sW(IntPtr ExternalHandle, [MarshalAs(UnmanagedType.LPWStr)] string DistName, [MarshalAs(UnmanagedType.LPWStr)] string AuthMechanism, IntPtr cred, IntPtr ServerCtrls, IntPtr ClientCtrls, IntPtr ServerData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_sasl_bind_sW' -Namespace Win32 -PassThru
# $api::ldap_sasl_bind_sW(ExternalHandle, DistName, AuthMechanism, cred, ServerCtrls, ClientCtrls, ServerData)#uselib "WLDAP32.dll"
#func global ldap_sasl_bind_sW "ldap_sasl_bind_sW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; ldap_sasl_bind_sW varptr(ExternalHandle), DistName, AuthMechanism, varptr(cred), varptr(ServerCtrls), varptr(ClientCtrls), varptr(ServerData) ; 戻り値は stat
; ExternalHandle : LDAP* in/out -> "wptr"
; DistName : LPCWSTR -> "wptr"
; AuthMechanism : LPCWSTR -> "wptr"
; cred : LDAP_BERVAL* -> "wptr"
; ServerCtrls : LDAPControlW** in/out -> "wptr"
; ClientCtrls : LDAPControlW** in/out -> "wptr"
; ServerData : LDAP_BERVAL** in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WLDAP32.dll" #cfunc global ldap_sasl_bind_sW "ldap_sasl_bind_sW" var, wstr, wstr, var, var, var, var ; res = ldap_sasl_bind_sW(ExternalHandle, DistName, AuthMechanism, cred, ServerCtrls, ClientCtrls, ServerData) ; ExternalHandle : LDAP* in/out -> "var" ; DistName : LPCWSTR -> "wstr" ; AuthMechanism : LPCWSTR -> "wstr" ; cred : LDAP_BERVAL* -> "var" ; ServerCtrls : LDAPControlW** in/out -> "var" ; ClientCtrls : LDAPControlW** in/out -> "var" ; ServerData : LDAP_BERVAL** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ldap_sasl_bind_sW "ldap_sasl_bind_sW" sptr, wstr, wstr, sptr, sptr, sptr, sptr ; res = ldap_sasl_bind_sW(varptr(ExternalHandle), DistName, AuthMechanism, varptr(cred), varptr(ServerCtrls), varptr(ClientCtrls), varptr(ServerData)) ; ExternalHandle : LDAP* in/out -> "sptr" ; DistName : LPCWSTR -> "wstr" ; AuthMechanism : LPCWSTR -> "wstr" ; cred : LDAP_BERVAL* -> "sptr" ; ServerCtrls : LDAPControlW** in/out -> "sptr" ; ClientCtrls : LDAPControlW** in/out -> "sptr" ; ServerData : LDAP_BERVAL** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT ldap_sasl_bind_sW(LDAP* ExternalHandle, LPCWSTR DistName, LPCWSTR AuthMechanism, LDAP_BERVAL* cred, LDAPControlW** ServerCtrls, LDAPControlW** ClientCtrls, LDAP_BERVAL** ServerData) #uselib "WLDAP32.dll" #cfunc global ldap_sasl_bind_sW "ldap_sasl_bind_sW" var, wstr, wstr, var, var, var, var ; res = ldap_sasl_bind_sW(ExternalHandle, DistName, AuthMechanism, cred, ServerCtrls, ClientCtrls, ServerData) ; ExternalHandle : LDAP* in/out -> "var" ; DistName : LPCWSTR -> "wstr" ; AuthMechanism : LPCWSTR -> "wstr" ; cred : LDAP_BERVAL* -> "var" ; ServerCtrls : LDAPControlW** in/out -> "var" ; ClientCtrls : LDAPControlW** in/out -> "var" ; ServerData : LDAP_BERVAL** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT ldap_sasl_bind_sW(LDAP* ExternalHandle, LPCWSTR DistName, LPCWSTR AuthMechanism, LDAP_BERVAL* cred, LDAPControlW** ServerCtrls, LDAPControlW** ClientCtrls, LDAP_BERVAL** ServerData) #uselib "WLDAP32.dll" #cfunc global ldap_sasl_bind_sW "ldap_sasl_bind_sW" intptr, wstr, wstr, intptr, intptr, intptr, intptr ; res = ldap_sasl_bind_sW(varptr(ExternalHandle), DistName, AuthMechanism, varptr(cred), varptr(ServerCtrls), varptr(ClientCtrls), varptr(ServerData)) ; ExternalHandle : LDAP* in/out -> "intptr" ; DistName : LPCWSTR -> "wstr" ; AuthMechanism : LPCWSTR -> "wstr" ; cred : LDAP_BERVAL* -> "intptr" ; ServerCtrls : LDAPControlW** in/out -> "intptr" ; ClientCtrls : LDAPControlW** in/out -> "intptr" ; ServerData : LDAP_BERVAL** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_sasl_bind_sW = wldap32.NewProc("ldap_sasl_bind_sW")
)
// ExternalHandle (LDAP* in/out), DistName (LPCWSTR), AuthMechanism (LPCWSTR), cred (LDAP_BERVAL*), ServerCtrls (LDAPControlW** in/out), ClientCtrls (LDAPControlW** in/out), ServerData (LDAP_BERVAL** in/out)
r1, _, err := procldap_sasl_bind_sW.Call(
uintptr(ExternalHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DistName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(AuthMechanism))),
uintptr(cred),
uintptr(ServerCtrls),
uintptr(ClientCtrls),
uintptr(ServerData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ldap_sasl_bind_sW(
ExternalHandle: Pointer; // LDAP* in/out
DistName: PWideChar; // LPCWSTR
AuthMechanism: PWideChar; // LPCWSTR
cred: Pointer; // LDAP_BERVAL*
ServerCtrls: Pointer; // LDAPControlW** in/out
ClientCtrls: Pointer; // LDAPControlW** in/out
ServerData: Pointer // LDAP_BERVAL** in/out
): Integer; cdecl;
external 'WLDAP32.dll' name 'ldap_sasl_bind_sW';result := DllCall("WLDAP32\ldap_sasl_bind_sW"
, "Ptr", ExternalHandle ; LDAP* in/out
, "WStr", DistName ; LPCWSTR
, "WStr", AuthMechanism ; LPCWSTR
, "Ptr", cred ; LDAP_BERVAL*
, "Ptr", ServerCtrls ; LDAPControlW** in/out
, "Ptr", ClientCtrls ; LDAPControlW** in/out
, "Ptr", ServerData ; LDAP_BERVAL** in/out
, "Cdecl Int") ; return: INT●ldap_sasl_bind_sW(ExternalHandle, DistName, AuthMechanism, cred, ServerCtrls, ClientCtrls, ServerData) = DLL("WLDAP32.dll", "int ldap_sasl_bind_sW(void*, char*, char*, void*, void*, void*, void*)")
# 呼び出し: ldap_sasl_bind_sW(ExternalHandle, DistName, AuthMechanism, cred, ServerCtrls, ClientCtrls, ServerData)
# ExternalHandle : LDAP* in/out -> "void*"
# DistName : LPCWSTR -> "char*"
# AuthMechanism : LPCWSTR -> "char*"
# cred : LDAP_BERVAL* -> "void*"
# ServerCtrls : LDAPControlW** in/out -> "void*"
# ClientCtrls : LDAPControlW** in/out -> "void*"
# ServerData : LDAP_BERVAL** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。