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