ホーム › Networking.Ldap › ldap_search
ldap_search
関数LDAPディレクトリを非同期に検索する。
シグネチャ
// WLDAP32.dll (ANSI / -A)
#include <windows.h>
DWORD ldap_search(
LDAP* ld,
LPSTR base, // optional
DWORD scope,
LPSTR filter,
CHAR** attrs,
DWORD attrsonly
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ld | LDAP* | inout |
| base | LPSTR | inoptional |
| scope | DWORD | in |
| filter | LPSTR | in |
| attrs | CHAR** | in |
| attrsonly | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// WLDAP32.dll (ANSI / -A)
#include <windows.h>
DWORD ldap_search(
LDAP* ld,
LPSTR base, // optional
DWORD scope,
LPSTR filter,
CHAR** attrs,
DWORD attrsonly
);[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_search(
IntPtr ld, // LDAP* in/out
[MarshalAs(UnmanagedType.LPStr)] string base, // LPSTR optional
uint scope, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string filter, // LPSTR
IntPtr attrs, // CHAR**
uint attrsonly // DWORD
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_search(
ld As IntPtr, ' LDAP* in/out
<MarshalAs(UnmanagedType.LPStr)> base As String, ' LPSTR optional
scope As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> filter As String, ' LPSTR
attrs As IntPtr, ' CHAR**
attrsonly As UInteger ' DWORD
) As UInteger
End Function' ld : LDAP* in/out
' base : LPSTR optional
' scope : DWORD
' filter : LPSTR
' attrs : CHAR**
' attrsonly : DWORD
Declare PtrSafe Function ldap_search Lib "wldap32" ( _
ByVal ld As LongPtr, _
ByVal base As String, _
ByVal scope As Long, _
ByVal filter As String, _
ByVal attrs As LongPtr, _
ByVal attrsonly As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ldap_search = ctypes.cdll.wldap32.ldap_search
ldap_search.restype = wintypes.DWORD
ldap_search.argtypes = [
ctypes.c_void_p, # ld : LDAP* in/out
wintypes.LPCSTR, # base : LPSTR optional
wintypes.DWORD, # scope : DWORD
wintypes.LPCSTR, # filter : LPSTR
ctypes.c_void_p, # attrs : CHAR**
wintypes.DWORD, # attrsonly : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_search = Fiddle::Function.new(
lib['ldap_search'],
[
Fiddle::TYPE_VOIDP, # ld : LDAP* in/out
Fiddle::TYPE_VOIDP, # base : LPSTR optional
-Fiddle::TYPE_INT, # scope : DWORD
Fiddle::TYPE_VOIDP, # filter : LPSTR
Fiddle::TYPE_VOIDP, # attrs : CHAR**
-Fiddle::TYPE_INT, # attrsonly : DWORD
],
-Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "wldap32")]
extern "C" {
fn ldap_search(
ld: *mut LDAP, // LDAP* in/out
base: *mut u8, // LPSTR optional
scope: u32, // DWORD
filter: *mut u8, // LPSTR
attrs: *mut *mut i8, // CHAR**
attrsonly: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ldap_search(IntPtr ld, [MarshalAs(UnmanagedType.LPStr)] string base, uint scope, [MarshalAs(UnmanagedType.LPStr)] string filter, IntPtr attrs, uint attrsonly);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_search' -Namespace Win32 -PassThru
# $api::ldap_search(ld, base, scope, filter, attrs, attrsonly)#uselib "WLDAP32.dll"
#func global ldap_search "ldap_search" sptr, sptr, sptr, sptr, sptr, sptr
; ldap_search varptr(ld), base, scope, filter, varptr(attrs), attrsonly ; 戻り値は stat
; ld : LDAP* in/out -> "sptr"
; base : LPSTR optional -> "sptr"
; scope : DWORD -> "sptr"
; filter : LPSTR -> "sptr"
; attrs : CHAR** -> "sptr"
; attrsonly : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WLDAP32.dll" #cfunc global ldap_search "ldap_search" var, str, int, str, var, int ; res = ldap_search(ld, base, scope, filter, attrs, attrsonly) ; ld : LDAP* in/out -> "var" ; base : LPSTR optional -> "str" ; scope : DWORD -> "int" ; filter : LPSTR -> "str" ; attrs : CHAR** -> "var" ; attrsonly : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ldap_search "ldap_search" sptr, str, int, str, sptr, int ; res = ldap_search(varptr(ld), base, scope, filter, varptr(attrs), attrsonly) ; ld : LDAP* in/out -> "sptr" ; base : LPSTR optional -> "str" ; scope : DWORD -> "int" ; filter : LPSTR -> "str" ; attrs : CHAR** -> "sptr" ; attrsonly : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ldap_search(LDAP* ld, LPSTR base, DWORD scope, LPSTR filter, CHAR** attrs, DWORD attrsonly) #uselib "WLDAP32.dll" #cfunc global ldap_search "ldap_search" var, str, int, str, var, int ; res = ldap_search(ld, base, scope, filter, attrs, attrsonly) ; ld : LDAP* in/out -> "var" ; base : LPSTR optional -> "str" ; scope : DWORD -> "int" ; filter : LPSTR -> "str" ; attrs : CHAR** -> "var" ; attrsonly : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ldap_search(LDAP* ld, LPSTR base, DWORD scope, LPSTR filter, CHAR** attrs, DWORD attrsonly) #uselib "WLDAP32.dll" #cfunc global ldap_search "ldap_search" intptr, str, int, str, intptr, int ; res = ldap_search(varptr(ld), base, scope, filter, varptr(attrs), attrsonly) ; ld : LDAP* in/out -> "intptr" ; base : LPSTR optional -> "str" ; scope : DWORD -> "int" ; filter : LPSTR -> "str" ; attrs : CHAR** -> "intptr" ; attrsonly : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_search = wldap32.NewProc("ldap_search")
)
// ld (LDAP* in/out), base (LPSTR optional), scope (DWORD), filter (LPSTR), attrs (CHAR**), attrsonly (DWORD)
r1, _, err := procldap_search.Call(
uintptr(ld),
uintptr(unsafe.Pointer(windows.BytePtrFromString(base))),
uintptr(scope),
uintptr(unsafe.Pointer(windows.BytePtrFromString(filter))),
uintptr(attrs),
uintptr(attrsonly),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ldap_search(
ld: Pointer; // LDAP* in/out
base: PAnsiChar; // LPSTR optional
scope: DWORD; // DWORD
filter: PAnsiChar; // LPSTR
attrs: Pointer; // CHAR**
attrsonly: DWORD // DWORD
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_search';result := DllCall("WLDAP32\ldap_search"
, "Ptr", ld ; LDAP* in/out
, "AStr", base ; LPSTR optional
, "UInt", scope ; DWORD
, "AStr", filter ; LPSTR
, "Ptr", attrs ; CHAR**
, "UInt", attrsonly ; DWORD
, "Cdecl UInt") ; return: DWORD●ldap_search(ld, base, scope, filter, attrs, attrsonly) = DLL("WLDAP32.dll", "dword ldap_search(void*, char*, dword, char*, void*, dword)")
# 呼び出し: ldap_search(ld, base, scope, filter, attrs, attrsonly)
# ld : LDAP* in/out -> "void*"
# base : LPSTR optional -> "char*"
# scope : DWORD -> "dword"
# filter : LPSTR -> "char*"
# attrs : CHAR** -> "void*"
# attrsonly : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。