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

ldap_searchW

関数
LDAPディレクトリを非同期に検索する(Unicode版)。
DLLWLDAP32.dll文字セットUnicode (-W)呼出規約cdecl対応OSWindows Vista 以降

シグネチャ

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

DWORD ldap_searchW(
    LDAP* ld,
    LPCWSTR base,   // optional
    DWORD scope,
    LPCWSTR filter,
    WORD** attrs,
    DWORD attrsonly
);

パラメーター

名前方向
ldLDAP*inout
baseLPCWSTRinoptional
scopeDWORDin
filterLPCWSTRin
attrsWORD**in
attrsonlyDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ldap_searchW(
    LDAP* ld,
    LPCWSTR base,   // optional
    DWORD scope,
    LPCWSTR filter,
    WORD** attrs,
    DWORD attrsonly
);
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_searchW(
    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
);
<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_searchW(
    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
) As UInteger
End Function
' ld : LDAP* in/out
' base : LPCWSTR optional
' scope : DWORD
' filter : LPCWSTR
' attrs : WORD**
' attrsonly : DWORD
Declare PtrSafe Function ldap_searchW 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) 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_searchW = ctypes.cdll.wldap32.ldap_searchW
ldap_searchW.restype = wintypes.DWORD
ldap_searchW.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
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WLDAP32.dll')
ldap_searchW = Fiddle::Function.new(
  lib['ldap_searchW'],
  [
    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_INT, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wldap32")]
extern "C" {
    fn ldap_searchW(
        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
    ) -> 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_searchW(IntPtr ld, [MarshalAs(UnmanagedType.LPWStr)] string base, uint scope, [MarshalAs(UnmanagedType.LPWStr)] string filter, IntPtr attrs, uint attrsonly);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_searchW' -Namespace Win32 -PassThru
# $api::ldap_searchW(ld, base, scope, filter, attrs, attrsonly)
#uselib "WLDAP32.dll"
#func global ldap_searchW "ldap_searchW" wptr, wptr, wptr, wptr, wptr, wptr
; ldap_searchW varptr(ld), base, scope, filter, varptr(attrs), attrsonly   ; 戻り値は stat
; ld : LDAP* in/out -> "wptr"
; base : LPCWSTR optional -> "wptr"
; scope : DWORD -> "wptr"
; filter : LPCWSTR -> "wptr"
; attrs : WORD** -> "wptr"
; attrsonly : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WLDAP32.dll"
#cfunc global ldap_searchW "ldap_searchW" var, wstr, int, wstr, var, int
; res = ldap_searchW(ld, base, scope, filter, attrs, attrsonly)
; ld : LDAP* in/out -> "var"
; base : LPCWSTR optional -> "wstr"
; scope : DWORD -> "int"
; filter : LPCWSTR -> "wstr"
; attrs : WORD** -> "var"
; attrsonly : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD ldap_searchW(LDAP* ld, LPCWSTR base, DWORD scope, LPCWSTR filter, WORD** attrs, DWORD attrsonly)
#uselib "WLDAP32.dll"
#cfunc global ldap_searchW "ldap_searchW" var, wstr, int, wstr, var, int
; res = ldap_searchW(ld, base, scope, filter, attrs, attrsonly)
; ld : LDAP* in/out -> "var"
; base : LPCWSTR optional -> "wstr"
; scope : DWORD -> "int"
; filter : LPCWSTR -> "wstr"
; attrs : WORD** -> "var"
; attrsonly : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
	procldap_searchW = wldap32.NewProc("ldap_searchW")
)

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