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