ldap_search_sW
関数シグネチャ
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
DWORD ldap_search_sW(
LDAP* ld,
LPCWSTR base, // optional
DWORD scope,
LPCWSTR filter,
WORD** attrs,
DWORD attrsonly,
LDAPMessage** res
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ld | LDAP* | inout | セッション ハンドル。 |
| base | LPCWSTR | inoptional | 検索を開始するエントリの識別名を格納する、null で終わる文字列へのポインター。 |
| scope | DWORD | in | 検索スコープを示す次のいずれかの値を指定します。 LDAP_SCOPE_BASEベース エントリのみを検索します。 LDAP_SCOPE_ONELEVELベース エントリを除く、ベース エントリの 1 つ下のレベルにあるすべてのエントリを検索します。 LDAP_SCOPE_SUBTREEベース エントリと、その下位のツリーにあるすべてのエントリを検索します。 |
| filter | LPCWSTR | in | 検索フィルターを指定する、null で終わる文字列へのポインター。詳細については、 検索フィルターの構文を参照してください。 |
| attrs | WORD** | in | 一致した各エントリについて返す属性を示す、null で終わる文字列から成る null 終端の配列。利用可能なすべての属性を取得するには NULL を渡します。 |
| attrsonly | DWORD | in | 属性の型と値の両方を返す場合は 0、型のみが必要な場合は 0 以外を指定するブール値。 |
| res | LDAPMessage** | out | 呼び出しの完了時に、検索の結果を格納します。関数呼び出しがエラー コードで失敗した場合でも、部分的な結果や拡張データが格納されることがあります。返された結果は、アプリケーションで不要になった時点で ldap_msgfree を呼び出して解放してください。 - scope.LDAP_SCOPE_BASEベース エントリのみを検索します。 - scope.LDAP_SCOPE_ONELEVELベース エントリを除く、ベース エントリの 1 つ下のレベルにあるすべてのエントリを検索します。 - scope.LDAP_SCOPE_SUBTREEベース エントリと、その下位のツリーにあるすべてのエントリを検索します。 |
戻り値の型: DWORD
公式ドキュメント
ldap_search_sW (Unicode) 関数 (winldap.h) は、LDAP ディレクトリを同期的に検索し、一致した各エントリについて要求された属性のセットを返します。
戻り値
関数が成功した場合、戻り値は LDAP_SUCCESS です。
関数が失敗した場合はエラー コードを返しますが、ldap_search_s は失敗しても pMsg を割り当てていることがあります。たとえば、LDAP_PARTIAL_RESULTS と LDAP_REFERRAL のいずれのエラー コードの場合も pMsg が割り当てられます。詳細については、以下のコード例を参照してください。詳細については、 Return Values を参照してください。
解説(Remarks)
ldap_search_s 関数は、同期的な検索を開始します。
検索の実行方法を決定する LDAP_OPT_SIZELIMIT、LDAP_OPT_TIMELIMIT、LDAP_OPT_DEREF の各オプションを設定するには、ld セッション ハンドルを指定して ldap_set_option 関数を使用します。詳細については、 Session Options を参照してください。
ldap_search_s は、検索操作の完了時に呼び出し元に制御を返します。操作を非同期に実行するには、 ldap_search を使用します。
マルチスレッド: ldap_search_s の呼び出しはスレッド セーフです。
次のコード例は、ldap_search_s が失敗した場合に pMsg を解放する方法を示しています。
// 戻り値を NULL に初期化します。
LDAPMessage *pMsg = NULL;
// 検索要求を実行します。
dwErr = ldap_search_s (i_pldap,
i_lpszBase,
i_ulScope,
i_lpszSearchFilter,
lpszAttributes,
0,
&pMsg
);
// 呼び出しパラメーターをクリーンアップします。
if (lpszAttributes != NULL)
delete [] lpszAttributes;
// 必要に応じて、エラー コードを変換し pMsg をクリーンアップします。
if (dwErr != LDAP_SUCCESS)
{
DebugOutLDAPError(i_pldap, dwErr, _T("ldap_search_s"));
hr = HRESULT_FROM_WIN32(dwErr);
// ldap_search_s の呼び出しがエラー コードを返した場合でも、
// pMsg に有効なデータが格納されていることがある点に注意してください。
// これは、LDAP_RESULTS_TOO_LARGE などの、検索が部分的な結果を
// 返したことを示すコードをサーバーが返した場合に発生します。
// 必要であればユーザー コードでこれらのケースを処理できますが、
// この例では、どのエラー コードの場合も pMsg を解放するだけです。
if (pMsg != NULL)
ldap_msgfree(pMsg);
}
else
{
// 検索結果を処理します。
...
// 不要になった時点で結果を解放します。
if (pMsg != NULL) ldap_msgfree(pMsg);
}
winldap.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして ldap_search_s を定義しています。エンコード非依存のエイリアスの使用と、エンコード非依存ではないコードを混在させると、不一致が生じてコンパイル エラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規則を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
DWORD ldap_search_sW(
LDAP* ld,
LPCWSTR base, // optional
DWORD scope,
LPCWSTR filter,
WORD** attrs,
DWORD attrsonly,
LDAPMessage** res
);[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_search_sW(
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 res // LDAPMessage** out
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_search_sW(
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
res As IntPtr ' LDAPMessage** out
) As UInteger
End Function' ld : LDAP* in/out
' base : LPCWSTR optional
' scope : DWORD
' filter : LPCWSTR
' attrs : WORD**
' attrsonly : DWORD
' res : LDAPMessage** out
Declare PtrSafe Function ldap_search_sW 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 res 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_search_sW = ctypes.cdll.wldap32.ldap_search_sW
ldap_search_sW.restype = wintypes.DWORD
ldap_search_sW.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, # res : LDAPMessage** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_search_sW = Fiddle::Function.new(
lib['ldap_search_sW'],
[
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, # res : LDAPMessage** out
],
-Fiddle::TYPE_INT, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wldap32")]
extern "C" {
fn ldap_search_sW(
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
res: *mut *mut LDAPMessage // LDAPMessage** 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_sW(IntPtr ld, [MarshalAs(UnmanagedType.LPWStr)] string base, uint scope, [MarshalAs(UnmanagedType.LPWStr)] string filter, IntPtr attrs, uint attrsonly, IntPtr res);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_search_sW' -Namespace Win32 -PassThru
# $api::ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res)#uselib "WLDAP32.dll"
#func global ldap_search_sW "ldap_search_sW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; ldap_search_sW varptr(ld), base, scope, filter, varptr(attrs), attrsonly, varptr(res) ; 戻り値は stat
; ld : LDAP* in/out -> "wptr"
; base : LPCWSTR optional -> "wptr"
; scope : DWORD -> "wptr"
; filter : LPCWSTR -> "wptr"
; attrs : WORD** -> "wptr"
; attrsonly : DWORD -> "wptr"
; res : LDAPMessage** out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WLDAP32.dll" #cfunc global ldap_search_sW "ldap_search_sW" var, wstr, int, wstr, var, int, var ; res = ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res) ; ld : LDAP* in/out -> "var" ; base : LPCWSTR optional -> "wstr" ; scope : DWORD -> "int" ; filter : LPCWSTR -> "wstr" ; attrs : WORD** -> "var" ; attrsonly : DWORD -> "int" ; res : LDAPMessage** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ldap_search_sW "ldap_search_sW" sptr, wstr, int, wstr, sptr, int, sptr ; res = ldap_search_sW(varptr(ld), base, scope, filter, varptr(attrs), attrsonly, varptr(res)) ; ld : LDAP* in/out -> "sptr" ; base : LPCWSTR optional -> "wstr" ; scope : DWORD -> "int" ; filter : LPCWSTR -> "wstr" ; attrs : WORD** -> "sptr" ; attrsonly : DWORD -> "int" ; res : LDAPMessage** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; DWORD ldap_search_sW(LDAP* ld, LPCWSTR base, DWORD scope, LPCWSTR filter, WORD** attrs, DWORD attrsonly, LDAPMessage** res) #uselib "WLDAP32.dll" #cfunc global ldap_search_sW "ldap_search_sW" var, wstr, int, wstr, var, int, var ; res = ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res) ; ld : LDAP* in/out -> "var" ; base : LPCWSTR optional -> "wstr" ; scope : DWORD -> "int" ; filter : LPCWSTR -> "wstr" ; attrs : WORD** -> "var" ; attrsonly : DWORD -> "int" ; res : LDAPMessage** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ldap_search_sW(LDAP* ld, LPCWSTR base, DWORD scope, LPCWSTR filter, WORD** attrs, DWORD attrsonly, LDAPMessage** res) #uselib "WLDAP32.dll" #cfunc global ldap_search_sW "ldap_search_sW" intptr, wstr, int, wstr, intptr, int, intptr ; res = ldap_search_sW(varptr(ld), base, scope, filter, varptr(attrs), attrsonly, varptr(res)) ; ld : LDAP* in/out -> "intptr" ; base : LPCWSTR optional -> "wstr" ; scope : DWORD -> "int" ; filter : LPCWSTR -> "wstr" ; attrs : WORD** -> "intptr" ; attrsonly : DWORD -> "int" ; res : LDAPMessage** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_search_sW = wldap32.NewProc("ldap_search_sW")
)
// ld (LDAP* in/out), base (LPCWSTR optional), scope (DWORD), filter (LPCWSTR), attrs (WORD**), attrsonly (DWORD), res (LDAPMessage** out)
r1, _, err := procldap_search_sW.Call(
uintptr(ld),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(base))),
uintptr(scope),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(filter))),
uintptr(attrs),
uintptr(attrsonly),
uintptr(res),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ldap_search_sW(
ld: Pointer; // LDAP* in/out
base: PWideChar; // LPCWSTR optional
scope: DWORD; // DWORD
filter: PWideChar; // LPCWSTR
attrs: Pointer; // WORD**
attrsonly: DWORD; // DWORD
res: Pointer // LDAPMessage** out
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_search_sW';result := DllCall("WLDAP32\ldap_search_sW"
, "Ptr", ld ; LDAP* in/out
, "WStr", base ; LPCWSTR optional
, "UInt", scope ; DWORD
, "WStr", filter ; LPCWSTR
, "Ptr", attrs ; WORD**
, "UInt", attrsonly ; DWORD
, "Ptr", res ; LDAPMessage** out
, "Cdecl UInt") ; return: DWORD●ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res) = DLL("WLDAP32.dll", "dword ldap_search_sW(void*, char*, dword, char*, void*, dword, void*)")
# 呼び出し: ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res)
# ld : LDAP* in/out -> "void*"
# base : LPCWSTR optional -> "char*"
# scope : DWORD -> "dword"
# filter : LPCWSTR -> "char*"
# attrs : WORD** -> "void*"
# attrsonly : DWORD -> "dword"
# res : LDAPMessage** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "wldap32" fn ldap_search_sW(
ld: [*c]LDAP, // LDAP* in/out
base: [*c]const u16, // LPCWSTR optional
scope: u32, // DWORD
filter: [*c]const u16, // LPCWSTR
attrs: [*c][*c]u16, // WORD**
attrsonly: u32, // DWORD
res: [*c][*c]LDAPMessage // LDAPMessage** out
) callconv(.c) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc ldap_search_sW(
ld: ptr LDAP, # LDAP* in/out
base: WideCString, # LPCWSTR optional
scope: uint32, # DWORD
filter: WideCString, # LPCWSTR
attrs: ptr uint16, # WORD**
attrsonly: uint32, # DWORD
res: ptr LDAPMessage # LDAPMessage** out
): uint32 {.importc: "ldap_search_sW", cdecl, dynlib: "WLDAP32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "wldap32");
extern(C)
uint ldap_search_sW(
LDAP* ld, // LDAP* in/out
const(wchar)* base, // LPCWSTR optional
uint scope, // DWORD
const(wchar)* filter, // LPCWSTR
ushort** attrs, // WORD**
uint attrsonly, // DWORD
LDAPMessage** res // LDAPMessage** out
);ccall((:ldap_search_sW, "WLDAP32.dll"), UInt32,
(Ptr{LDAP}, Cwstring, UInt32, Cwstring, Ptr{UInt16}, UInt32, Ptr{LDAPMessage}),
ld, base, scope, filter, attrs, attrsonly, res)
# ld : LDAP* in/out -> Ptr{LDAP}
# base : LPCWSTR optional -> Cwstring
# scope : DWORD -> UInt32
# filter : LPCWSTR -> Cwstring
# attrs : WORD** -> Ptr{UInt16}
# attrsonly : DWORD -> UInt32
# res : LDAPMessage** out -> Ptr{LDAPMessage}
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t ldap_search_sW(
void* ld,
const uint16_t* base,
uint32_t scope,
const uint16_t* filter,
uint16_t** attrs,
uint32_t attrsonly,
void* res);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res)
-- ld : LDAP* in/out
-- base : LPCWSTR optional
-- scope : DWORD
-- filter : LPCWSTR
-- attrs : WORD**
-- attrsonly : DWORD
-- res : LDAPMessage** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('WLDAP32.dll');
const ldap_search_sW = lib.func('__cdecl', 'ldap_search_sW', 'uint32_t', ['void *', 'str16', 'uint32_t', 'str16', 'uint16_t *', 'uint32_t', 'void *']);
// ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res)
// ld : LDAP* in/out -> 'void *'
// base : LPCWSTR optional -> 'str16'
// scope : DWORD -> 'uint32_t'
// filter : LPCWSTR -> 'str16'
// attrs : WORD** -> 'uint16_t *'
// attrsonly : DWORD -> 'uint32_t'
// res : LDAPMessage** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WLDAP32.dll", {
ldap_search_sW: { parameters: ["pointer", "buffer", "u32", "buffer", "pointer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res)
// ld : LDAP* in/out -> "pointer"
// base : LPCWSTR optional -> "buffer"
// scope : DWORD -> "u32"
// filter : LPCWSTR -> "buffer"
// attrs : WORD** -> "pointer"
// attrsonly : DWORD -> "u32"
// res : LDAPMessage** out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ldap_search_sW(
void* ld,
const uint16_t* base,
uint32_t scope,
const uint16_t* filter,
uint16_t** attrs,
uint32_t attrsonly,
void* res);
C, "WLDAP32.dll");
// $ffi->ldap_search_sW(ld, base, scope, filter, attrs, attrsonly, res);
// ld : LDAP* in/out
// base : LPCWSTR optional
// scope : DWORD
// filter : LPCWSTR
// attrs : WORD**
// attrsonly : DWORD
// res : LDAPMessage** out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wldap32 extends Library {
Wldap32 INSTANCE = Native.load("wldap32", Wldap32.class, W32APIOptions.UNICODE_OPTIONS);
int ldap_search_sW(
Pointer ld, // LDAP* in/out
WString base, // LPCWSTR optional
int scope, // DWORD
WString filter, // LPCWSTR
Pointer attrs, // WORD**
int attrsonly, // DWORD
Pointer res // LDAPMessage** out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("wldap32")]
lib LibWLDAP32
fun ldap_search_sW = ldap_search_sW(
ld : LDAP*, # LDAP* in/out
base : UInt16*, # LPCWSTR optional
scope : UInt32, # DWORD
filter : UInt16*, # LPCWSTR
attrs : UInt16**, # WORD**
attrsonly : UInt32, # DWORD
res : LDAPMessage** # LDAPMessage** out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ldap_search_sWNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Uint32, Pointer<Utf16>, Pointer<Uint16>, Uint32, Pointer<Void>);
typedef ldap_search_sWDart = int Function(Pointer<Void>, Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Uint16>, int, Pointer<Void>);
final ldap_search_sW = DynamicLibrary.open('WLDAP32.dll')
.lookupFunction<ldap_search_sWNative, ldap_search_sWDart>('ldap_search_sW');
// ld : LDAP* in/out -> Pointer<Void>
// base : LPCWSTR optional -> Pointer<Utf16>
// scope : DWORD -> Uint32
// filter : LPCWSTR -> Pointer<Utf16>
// attrs : WORD** -> Pointer<Uint16>
// attrsonly : DWORD -> Uint32
// res : LDAPMessage** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ldap_search_sW(
ld: Pointer; // LDAP* in/out
base: PWideChar; // LPCWSTR optional
scope: DWORD; // DWORD
filter: PWideChar; // LPCWSTR
attrs: Pointer; // WORD**
attrsonly: DWORD; // DWORD
res: Pointer // LDAPMessage** out
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_search_sW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ldap_search_sW"
c_ldap_search_sW :: Ptr () -> CWString -> Word32 -> CWString -> Ptr Word16 -> Word32 -> Ptr () -> IO Word32
-- ld : LDAP* in/out -> Ptr ()
-- base : LPCWSTR optional -> CWString
-- scope : DWORD -> Word32
-- filter : LPCWSTR -> CWString
-- attrs : WORD** -> Ptr Word16
-- attrsonly : DWORD -> Word32
-- res : LDAPMessage** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ldap_search_sw =
foreign "ldap_search_sW"
((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* ld : LDAP* in/out -> (ptr void) *)
(* base : LPCWSTR optional -> (ptr uint16_t) *)
(* scope : DWORD -> uint32_t *)
(* filter : LPCWSTR -> (ptr uint16_t) *)
(* attrs : WORD** -> (ptr uint16_t) *)
(* attrsonly : DWORD -> uint32_t *)
(* res : LDAPMessage** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)
(cffi:defcfun ("ldap_search_sW" ldap-search-s-w :convention :cdecl) :uint32
(ld :pointer) ; LDAP* in/out
(base (:string :encoding :utf-16le)) ; LPCWSTR optional
(scope :uint32) ; DWORD
(filter (:string :encoding :utf-16le)) ; LPCWSTR
(attrs :pointer) ; WORD**
(attrsonly :uint32) ; DWORD
(res :pointer)) ; LDAPMessage** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ldap_search_sW = Win32::API::More->new('WLDAP32',
'DWORD ldap_search_sW(LPVOID ld, LPCWSTR base, DWORD scope, LPCWSTR filter, LPVOID attrs, DWORD attrsonly, LPVOID res)');
# my $ret = $ldap_search_sW->Call($ld, $base, $scope, $filter, $attrs, $attrsonly, $res);
# ld : LDAP* in/out -> LPVOID
# base : LPCWSTR optional -> LPCWSTR
# scope : DWORD -> DWORD
# filter : LPCWSTR -> LPCWSTR
# attrs : WORD** -> LPVOID
# attrsonly : DWORD -> DWORD
# res : LDAPMessage** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f ldap_search_sA (ANSI版) — LDAPディレクトリを同期的に検索する(ANSI版)。
- f ldap_msgfree — LDAP操作結果のメッセージ構造体を解放する。
- f ldap_searchW — LDAPディレクトリを非同期に検索する(Unicode版)。
- f ldap_search_extW — 制御付きで非同期にLDAP拡張検索する(Unicode版)。
- f ldap_search_ext_sW — 制御付きで同期的にLDAP拡張検索する(Unicode版)。
- f ldap_search_stW — 時間制限付きで同期的にLDAP検索する(Unicode版)。