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