ホーム › Networking.Ldap › ldap_first_attribute
ldap_first_attribute
関数エントリから最初の属性名を取得する。
シグネチャ
// WLDAP32.dll (ANSI / -A)
#include <windows.h>
LPSTR ldap_first_attribute(
LDAP* ld,
LDAPMessage* entry,
BerElement** ptr
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ld | LDAP* | inout | 対象のLDAPセッションハンドル。検索を実行した接続を指す。 |
| entry | LDAPMessage* | inout | 属性を列挙する対象のエントリ。ldap_first_entry等で取得したものを渡す。 |
| ptr | BerElement** | inout | 列挙状態を保持するBerElementポインタを受け取る出力先。後続列挙とber_freeに使う。 |
戻り値の型: LPSTR
各言語での呼び出し定義
// WLDAP32.dll (ANSI / -A)
#include <windows.h>
LPSTR ldap_first_attribute(
LDAP* ld,
LDAPMessage* entry,
BerElement** ptr
);[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ldap_first_attribute(
IntPtr ld, // LDAP* in/out
IntPtr entry, // LDAPMessage* in/out
IntPtr ptr // BerElement** in/out
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_first_attribute(
ld As IntPtr, ' LDAP* in/out
entry As IntPtr, ' LDAPMessage* in/out
ptr As IntPtr ' BerElement** in/out
) As IntPtr
End Function' ld : LDAP* in/out
' entry : LDAPMessage* in/out
' ptr : BerElement** in/out
Declare PtrSafe Function ldap_first_attribute Lib "wldap32" ( _
ByVal ld As LongPtr, _
ByVal entry As LongPtr, _
ByVal ptr As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ldap_first_attribute = ctypes.cdll.wldap32.ldap_first_attribute
ldap_first_attribute.restype = wintypes.LPSTR
ldap_first_attribute.argtypes = [
ctypes.c_void_p, # ld : LDAP* in/out
ctypes.c_void_p, # entry : LDAPMessage* in/out
ctypes.c_void_p, # ptr : BerElement** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_first_attribute = Fiddle::Function.new(
lib['ldap_first_attribute'],
[
Fiddle::TYPE_VOIDP, # ld : LDAP* in/out
Fiddle::TYPE_VOIDP, # entry : LDAPMessage* in/out
Fiddle::TYPE_VOIDP, # ptr : BerElement** in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "wldap32")]
extern "C" {
fn ldap_first_attribute(
ld: *mut LDAP, // LDAP* in/out
entry: *mut LDAPMessage, // LDAPMessage* in/out
ptr: *mut *mut BerElement // BerElement** in/out
) -> *mut u8;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ldap_first_attribute(IntPtr ld, IntPtr entry, IntPtr ptr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_first_attribute' -Namespace Win32 -PassThru
# $api::ldap_first_attribute(ld, entry, ptr)#uselib "WLDAP32.dll"
#func global ldap_first_attribute "ldap_first_attribute" sptr, sptr, sptr
; ldap_first_attribute varptr(ld), varptr(entry), varptr(ptr) ; 戻り値は stat
; ld : LDAP* in/out -> "sptr"
; entry : LDAPMessage* in/out -> "sptr"
; ptr : BerElement** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WLDAP32.dll" #cfunc global ldap_first_attribute "ldap_first_attribute" var, var, var ; res = ldap_first_attribute(ld, entry, ptr) ; ld : LDAP* in/out -> "var" ; entry : LDAPMessage* in/out -> "var" ; ptr : BerElement** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ldap_first_attribute "ldap_first_attribute" sptr, sptr, sptr ; res = ldap_first_attribute(varptr(ld), varptr(entry), varptr(ptr)) ; ld : LDAP* in/out -> "sptr" ; entry : LDAPMessage* in/out -> "sptr" ; ptr : BerElement** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; LPSTR ldap_first_attribute(LDAP* ld, LDAPMessage* entry, BerElement** ptr) #uselib "WLDAP32.dll" #cfunc global ldap_first_attribute "ldap_first_attribute" var, var, var ; res = ldap_first_attribute(ld, entry, ptr) ; ld : LDAP* in/out -> "var" ; entry : LDAPMessage* in/out -> "var" ; ptr : BerElement** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; LPSTR ldap_first_attribute(LDAP* ld, LDAPMessage* entry, BerElement** ptr) #uselib "WLDAP32.dll" #cfunc global ldap_first_attribute "ldap_first_attribute" intptr, intptr, intptr ; res = ldap_first_attribute(varptr(ld), varptr(entry), varptr(ptr)) ; ld : LDAP* in/out -> "intptr" ; entry : LDAPMessage* in/out -> "intptr" ; ptr : BerElement** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_first_attribute = wldap32.NewProc("ldap_first_attribute")
)
// ld (LDAP* in/out), entry (LDAPMessage* in/out), ptr (BerElement** in/out)
r1, _, err := procldap_first_attribute.Call(
uintptr(ld),
uintptr(entry),
uintptr(ptr),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPSTRfunction ldap_first_attribute(
ld: Pointer; // LDAP* in/out
entry: Pointer; // LDAPMessage* in/out
ptr: Pointer // BerElement** in/out
): PAnsiChar; cdecl;
external 'WLDAP32.dll' name 'ldap_first_attribute';result := DllCall("WLDAP32\ldap_first_attribute"
, "Ptr", ld ; LDAP* in/out
, "Ptr", entry ; LDAPMessage* in/out
, "Ptr", ptr ; BerElement** in/out
, "Cdecl Ptr") ; return: LPSTR●ldap_first_attribute(ld, entry, ptr) = DLL("WLDAP32.dll", "char* ldap_first_attribute(void*, void*, void*)")
# 呼び出し: ldap_first_attribute(ld, entry, ptr)
# ld : LDAP* in/out -> "void*"
# entry : LDAPMessage* in/out -> "void*"
# ptr : BerElement** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "wldap32" fn ldap_first_attribute(
ld: [*c]LDAP, // LDAP* in/out
entry: [*c]LDAPMessage, // LDAPMessage* in/out
ptr: [*c][*c]BerElement // BerElement** in/out
) callconv(.c) [*c]const u8;proc ldap_first_attribute(
ld: ptr LDAP, # LDAP* in/out
entry: ptr LDAPMessage, # LDAPMessage* in/out
`ptr`: ptr BerElement # BerElement** in/out
): cstring {.importc: "ldap_first_attribute", cdecl, dynlib: "WLDAP32.dll".}pragma(lib, "wldap32");
extern(C)
const(char)* ldap_first_attribute(
LDAP* ld, // LDAP* in/out
LDAPMessage* entry, // LDAPMessage* in/out
BerElement** ptr // BerElement** in/out
);ccall((:ldap_first_attribute, "WLDAP32.dll"), Cstring,
(Ptr{LDAP}, Ptr{LDAPMessage}, Ptr{BerElement}),
ld, entry, ptr)
# ld : LDAP* in/out -> Ptr{LDAP}
# entry : LDAPMessage* in/out -> Ptr{LDAPMessage}
# ptr : BerElement** in/out -> Ptr{BerElement}local ffi = require("ffi")
ffi.cdef[[
const char* ldap_first_attribute(
void* ld,
void* entry,
void* ptr);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_first_attribute(ld, entry, ptr)
-- ld : LDAP* in/out
-- entry : LDAPMessage* in/out
-- ptr : BerElement** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WLDAP32.dll');
const ldap_first_attribute = lib.func('__cdecl', 'ldap_first_attribute', 'void *', ['void *', 'void *', 'void *']);
// ldap_first_attribute(ld, entry, ptr)
// ld : LDAP* in/out -> 'void *'
// entry : LDAPMessage* in/out -> 'void *'
// ptr : BerElement** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WLDAP32.dll", {
ldap_first_attribute: { parameters: ["pointer", "pointer", "pointer"], result: "pointer" },
});
// lib.symbols.ldap_first_attribute(ld, entry, ptr)
// ld : LDAP* in/out -> "pointer"
// entry : LDAPMessage* in/out -> "pointer"
// ptr : BerElement** in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
const char* ldap_first_attribute(
void* ld,
void* entry,
void* ptr);
C, "WLDAP32.dll");
// $ffi->ldap_first_attribute(ld, entry, ptr);
// ld : LDAP* in/out
// entry : LDAPMessage* in/out
// ptr : BerElement** in/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.ASCII_OPTIONS);
Pointer ldap_first_attribute(
Pointer ld, // LDAP* in/out
Pointer entry, // LDAPMessage* in/out
Pointer ptr // BerElement** in/out
);
}@[Link("wldap32")]
lib LibWLDAP32
fun ldap_first_attribute = ldap_first_attribute(
ld : LDAP*, # LDAP* in/out
entry : LDAPMessage*, # LDAPMessage* in/out
ptr : BerElement** # BerElement** in/out
) : UInt8*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ldap_first_attributeNative = Pointer<Utf8> Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef ldap_first_attributeDart = Pointer<Utf8> Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final ldap_first_attribute = DynamicLibrary.open('WLDAP32.dll')
.lookupFunction<ldap_first_attributeNative, ldap_first_attributeDart>('ldap_first_attribute');
// ld : LDAP* in/out -> Pointer<Void>
// entry : LDAPMessage* in/out -> Pointer<Void>
// ptr : BerElement** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ldap_first_attribute(
ld: Pointer; // LDAP* in/out
entry: Pointer; // LDAPMessage* in/out
ptr: Pointer // BerElement** in/out
): PAnsiChar; cdecl;
external 'WLDAP32.dll' name 'ldap_first_attribute';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ldap_first_attribute"
c_ldap_first_attribute :: Ptr () -> Ptr () -> Ptr () -> IO CString
-- ld : LDAP* in/out -> Ptr ()
-- entry : LDAPMessage* in/out -> Ptr ()
-- ptr : BerElement** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ldap_first_attribute =
foreign "ldap_first_attribute"
((ptr void) @-> (ptr void) @-> (ptr void) @-> returning string)
(* ld : LDAP* in/out -> (ptr void) *)
(* entry : LDAPMessage* in/out -> (ptr void) *)
(* ptr : BerElement** in/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_first_attribute" ldap-first-attribute :convention :cdecl) :string
(ld :pointer) ; LDAP* in/out
(entry :pointer) ; LDAPMessage* in/out
(ptr :pointer)) ; BerElement** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ldap_first_attribute = Win32::API::More->new('WLDAP32',
'LPSTR ldap_first_attribute(LPVOID ld, LPVOID entry, LPVOID ptr)');
# my $ret = $ldap_first_attribute->Call($ld, $entry, $ptr);
# ld : LDAP* in/out -> LPVOID
# entry : LDAPMessage* in/out -> LPVOID
# ptr : BerElement** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f ldap_first_attributeA (ANSI版) — エントリから最初の属性名を取得する(ANSI版)。
- f ldap_first_attributeW (Unicode版) — エントリから最初の属性名を取得する(Unicode版)。