ホーム › Networking.Ldap › ldap_compareA
ldap_compareA
関数属性値が一致するかLDAPサーバーで非同期に比較する(ANSI版)。
シグネチャ
// WLDAP32.dll (ANSI / -A)
#include <windows.h>
DWORD ldap_compareA(
LDAP* ld,
LPCSTR dn,
LPCSTR attr,
LPSTR value
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ld | LDAP* | inout | 比較操作を行う対象のLDAPセッションハンドル。 |
| dn | LPCSTR | in | 比較対象エントリの識別名(DN、ANSI)。 |
| attr | LPCSTR | in | 比較する属性名(ANSI)。エントリ内の対象属性を指す。 |
| value | LPSTR | in | 属性と照合する値(ANSI)。一致するかをサーバーが判定する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// WLDAP32.dll (ANSI / -A)
#include <windows.h>
DWORD ldap_compareA(
LDAP* ld,
LPCSTR dn,
LPCSTR attr,
LPSTR value
);[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_compareA(
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_compareA(
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_compareA 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_compareA = ctypes.cdll.wldap32.ldap_compareA
ldap_compareA.restype = wintypes.DWORD
ldap_compareA.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_compareA = Fiddle::Function.new(
lib['ldap_compareA'],
[
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_compareA(
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_compareA(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_compareA' -Namespace Win32 -PassThru
# $api::ldap_compareA(ld, dn, attr, value)#uselib "WLDAP32.dll"
#func global ldap_compareA "ldap_compareA" sptr, sptr, sptr, sptr
; ldap_compareA 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_compareA "ldap_compareA" var, str, str, str ; res = ldap_compareA(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_compareA "ldap_compareA" sptr, str, str, str ; res = ldap_compareA(varptr(ld), dn, attr, value) ; ld : LDAP* in/out -> "sptr" ; dn : LPCSTR -> "str" ; attr : LPCSTR -> "str" ; value : LPSTR -> "str" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ldap_compareA(LDAP* ld, LPCSTR dn, LPCSTR attr, LPSTR value) #uselib "WLDAP32.dll" #cfunc global ldap_compareA "ldap_compareA" var, str, str, str ; res = ldap_compareA(ld, dn, attr, value) ; ld : LDAP* in/out -> "var" ; dn : LPCSTR -> "str" ; attr : LPCSTR -> "str" ; value : LPSTR -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ldap_compareA(LDAP* ld, LPCSTR dn, LPCSTR attr, LPSTR value) #uselib "WLDAP32.dll" #cfunc global ldap_compareA "ldap_compareA" intptr, str, str, str ; res = ldap_compareA(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_compareA = wldap32.NewProc("ldap_compareA")
)
// ld (LDAP* in/out), dn (LPCSTR), attr (LPCSTR), value (LPSTR)
r1, _, err := procldap_compareA.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_compareA(
ld: Pointer; // LDAP* in/out
dn: PAnsiChar; // LPCSTR
attr: PAnsiChar; // LPCSTR
value: PAnsiChar // LPSTR
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_compareA';result := DllCall("WLDAP32\ldap_compareA"
, "Ptr", ld ; LDAP* in/out
, "AStr", dn ; LPCSTR
, "AStr", attr ; LPCSTR
, "AStr", value ; LPSTR
, "Cdecl UInt") ; return: DWORD●ldap_compareA(ld, dn, attr, value) = DLL("WLDAP32.dll", "dword ldap_compareA(void*, char*, char*, char*)")
# 呼び出し: ldap_compareA(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`,…) を使用。const std = @import("std");
extern "wldap32" fn ldap_compareA(
ld: [*c]LDAP, // LDAP* in/out
dn: [*c]const u8, // LPCSTR
attr: [*c]const u8, // LPCSTR
value: [*c]const u8 // LPSTR
) callconv(.c) u32;proc ldap_compareA(
ld: ptr LDAP, # LDAP* in/out
dn: cstring, # LPCSTR
attr: cstring, # LPCSTR
value: cstring # LPSTR
): uint32 {.importc: "ldap_compareA", cdecl, dynlib: "WLDAP32.dll".}pragma(lib, "wldap32");
extern(C)
uint ldap_compareA(
LDAP* ld, // LDAP* in/out
const(char)* dn, // LPCSTR
const(char)* attr, // LPCSTR
const(char)* value // LPSTR
);ccall((:ldap_compareA, "WLDAP32.dll"), UInt32,
(Ptr{LDAP}, Cstring, Cstring, Cstring),
ld, dn, attr, value)
# ld : LDAP* in/out -> Ptr{LDAP}
# dn : LPCSTR -> Cstring
# attr : LPCSTR -> Cstring
# value : LPSTR -> Cstringlocal ffi = require("ffi")
ffi.cdef[[
uint32_t ldap_compareA(
void* ld,
const char* dn,
const char* attr,
const char* value);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_compareA(ld, dn, attr, value)
-- ld : LDAP* in/out
-- dn : LPCSTR
-- attr : LPCSTR
-- value : LPSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WLDAP32.dll');
const ldap_compareA = lib.func('__cdecl', 'ldap_compareA', 'uint32_t', ['void *', 'str', 'str', 'str']);
// ldap_compareA(ld, dn, attr, value)
// ld : LDAP* in/out -> 'void *'
// dn : LPCSTR -> 'str'
// attr : LPCSTR -> 'str'
// value : LPSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WLDAP32.dll", {
ldap_compareA: { parameters: ["pointer", "buffer", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.ldap_compareA(ld, dn, attr, value)
// ld : LDAP* in/out -> "pointer"
// dn : LPCSTR -> "buffer"
// attr : LPCSTR -> "buffer"
// value : LPSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ldap_compareA(
void* ld,
const char* dn,
const char* attr,
const char* value);
C, "WLDAP32.dll");
// $ffi->ldap_compareA(ld, dn, attr, value);
// ld : LDAP* in/out
// dn : LPCSTR
// attr : LPCSTR
// value : LPSTR
// 構造体/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.ASCII_OPTIONS);
int ldap_compareA(
Pointer ld, // LDAP* in/out
String dn, // LPCSTR
String attr, // LPCSTR
String value // LPSTR
);
}@[Link("wldap32")]
lib LibWLDAP32
fun ldap_compareA = ldap_compareA(
ld : LDAP*, # LDAP* in/out
dn : UInt8*, # LPCSTR
attr : UInt8*, # LPCSTR
value : UInt8* # LPSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ldap_compareANative = Uint32 Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
typedef ldap_compareADart = int Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
final ldap_compareA = DynamicLibrary.open('WLDAP32.dll')
.lookupFunction<ldap_compareANative, ldap_compareADart>('ldap_compareA');
// ld : LDAP* in/out -> Pointer<Void>
// dn : LPCSTR -> Pointer<Utf8>
// attr : LPCSTR -> Pointer<Utf8>
// value : LPSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ldap_compareA(
ld: Pointer; // LDAP* in/out
dn: PAnsiChar; // LPCSTR
attr: PAnsiChar; // LPCSTR
value: PAnsiChar // LPSTR
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_compareA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ldap_compareA"
c_ldap_compareA :: Ptr () -> CString -> CString -> CString -> IO Word32
-- ld : LDAP* in/out -> Ptr ()
-- dn : LPCSTR -> CString
-- attr : LPCSTR -> CString
-- value : LPSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ldap_comparea =
foreign "ldap_compareA"
((ptr void) @-> string @-> string @-> string @-> returning uint32_t)
(* ld : LDAP* in/out -> (ptr void) *)
(* dn : LPCSTR -> string *)
(* attr : LPCSTR -> string *)
(* value : LPSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)
(cffi:defcfun ("ldap_compareA" ldap-compare-a :convention :cdecl) :uint32
(ld :pointer) ; LDAP* in/out
(dn :string) ; LPCSTR
(attr :string) ; LPCSTR
(value :string)) ; LPSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ldap_compareA = Win32::API::More->new('WLDAP32',
'DWORD ldap_compareA(LPVOID ld, LPCSTR dn, LPCSTR attr, LPCSTR value)');
# my $ret = $ldap_compareA->Call($ld, $dn, $attr, $value);
# ld : LDAP* in/out -> LPVOID
# dn : LPCSTR -> LPCSTR
# attr : LPCSTR -> LPCSTR
# value : LPSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f ldap_compareW (Unicode版) — 属性値が一致するかLDAPサーバーで非同期に比較する(Unicode版)。
使用する型