ホーム › Networking.Ldap › ldap_get_valuesW
ldap_get_valuesW
関数エントリの指定属性の値配列を取得する(Unicode版)。
シグネチャ
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
LPWSTR* ldap_get_valuesW(
LDAP* ld,
LDAPMessage* entry,
LPCWSTR attr
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ld | LDAP* | inout | 対象のLDAPセッションハンドル。検索を実行した接続を指す。 |
| entry | LDAPMessage* | inout | 値を取得する対象のエントリ。ldap_first_entry等で取得したものを渡す。 |
| attr | LPCWSTR | in | 値を取得する属性名(Unicode文字列)。この属性の値配列を返す。 |
戻り値の型: LPWSTR*
各言語での呼び出し定義
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
LPWSTR* ldap_get_valuesW(
LDAP* ld,
LDAPMessage* entry,
LPCWSTR attr
);[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ldap_get_valuesW(
IntPtr ld, // LDAP* in/out
IntPtr entry, // LDAPMessage* in/out
[MarshalAs(UnmanagedType.LPWStr)] string attr // LPCWSTR
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_get_valuesW(
ld As IntPtr, ' LDAP* in/out
entry As IntPtr, ' LDAPMessage* in/out
<MarshalAs(UnmanagedType.LPWStr)> attr As String ' LPCWSTR
) As IntPtr
End Function' ld : LDAP* in/out
' entry : LDAPMessage* in/out
' attr : LPCWSTR
Declare PtrSafe Function ldap_get_valuesW Lib "wldap32" ( _
ByVal ld As LongPtr, _
ByVal entry As LongPtr, _
ByVal attr As LongPtr) As LongPtr
' 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_get_valuesW = ctypes.cdll.wldap32.ldap_get_valuesW
ldap_get_valuesW.restype = wintypes.LPWSTR
ldap_get_valuesW.argtypes = [
ctypes.c_void_p, # ld : LDAP* in/out
ctypes.c_void_p, # entry : LDAPMessage* in/out
wintypes.LPCWSTR, # attr : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_get_valuesW = Fiddle::Function.new(
lib['ldap_get_valuesW'],
[
Fiddle::TYPE_VOIDP, # ld : LDAP* in/out
Fiddle::TYPE_VOIDP, # entry : LDAPMessage* in/out
Fiddle::TYPE_VOIDP, # attr : LPCWSTR
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wldap32")]
extern "C" {
fn ldap_get_valuesW(
ld: *mut LDAP, // LDAP* in/out
entry: *mut LDAPMessage, // LDAPMessage* in/out
attr: *const u16 // LPCWSTR
) -> *mut *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ldap_get_valuesW(IntPtr ld, IntPtr entry, [MarshalAs(UnmanagedType.LPWStr)] string attr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_get_valuesW' -Namespace Win32 -PassThru
# $api::ldap_get_valuesW(ld, entry, attr)#uselib "WLDAP32.dll"
#func global ldap_get_valuesW "ldap_get_valuesW" wptr, wptr, wptr
; ldap_get_valuesW varptr(ld), varptr(entry), attr ; 戻り値は stat
; ld : LDAP* in/out -> "wptr"
; entry : LDAPMessage* in/out -> "wptr"
; attr : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WLDAP32.dll" #cfunc global ldap_get_valuesW "ldap_get_valuesW" var, var, wstr ; res = ldap_get_valuesW(ld, entry, attr) ; ld : LDAP* in/out -> "var" ; entry : LDAPMessage* in/out -> "var" ; attr : LPCWSTR -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ldap_get_valuesW "ldap_get_valuesW" sptr, sptr, wstr ; res = ldap_get_valuesW(varptr(ld), varptr(entry), attr) ; ld : LDAP* in/out -> "sptr" ; entry : LDAPMessage* in/out -> "sptr" ; attr : LPCWSTR -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; LPWSTR* ldap_get_valuesW(LDAP* ld, LDAPMessage* entry, LPCWSTR attr) #uselib "WLDAP32.dll" #cfunc global ldap_get_valuesW "ldap_get_valuesW" var, var, wstr ; res = ldap_get_valuesW(ld, entry, attr) ; ld : LDAP* in/out -> "var" ; entry : LDAPMessage* in/out -> "var" ; attr : LPCWSTR -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; LPWSTR* ldap_get_valuesW(LDAP* ld, LDAPMessage* entry, LPCWSTR attr) #uselib "WLDAP32.dll" #cfunc global ldap_get_valuesW "ldap_get_valuesW" intptr, intptr, wstr ; res = ldap_get_valuesW(varptr(ld), varptr(entry), attr) ; ld : LDAP* in/out -> "intptr" ; entry : LDAPMessage* in/out -> "intptr" ; attr : LPCWSTR -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_get_valuesW = wldap32.NewProc("ldap_get_valuesW")
)
// ld (LDAP* in/out), entry (LDAPMessage* in/out), attr (LPCWSTR)
r1, _, err := procldap_get_valuesW.Call(
uintptr(ld),
uintptr(entry),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(attr))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPWSTR*function ldap_get_valuesW(
ld: Pointer; // LDAP* in/out
entry: Pointer; // LDAPMessage* in/out
attr: PWideChar // LPCWSTR
): PWideChar; cdecl;
external 'WLDAP32.dll' name 'ldap_get_valuesW';result := DllCall("WLDAP32\ldap_get_valuesW"
, "Ptr", ld ; LDAP* in/out
, "Ptr", entry ; LDAPMessage* in/out
, "WStr", attr ; LPCWSTR
, "Cdecl Ptr") ; return: LPWSTR*●ldap_get_valuesW(ld, entry, attr) = DLL("WLDAP32.dll", "void* ldap_get_valuesW(void*, void*, char*)")
# 呼び出し: ldap_get_valuesW(ld, entry, attr)
# ld : LDAP* in/out -> "void*"
# entry : LDAPMessage* in/out -> "void*"
# attr : LPCWSTR -> "char*"
# なでしこ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_get_valuesW(
ld: [*c]LDAP, // LDAP* in/out
entry: [*c]LDAPMessage, // LDAPMessage* in/out
attr: [*c]const u16 // LPCWSTR
) callconv(.c) [*c][*c]u16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc ldap_get_valuesW(
ld: ptr LDAP, # LDAP* in/out
entry: ptr LDAPMessage, # LDAPMessage* in/out
attr: WideCString # LPCWSTR
): ptr WideCString {.importc: "ldap_get_valuesW", cdecl, dynlib: "WLDAP32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "wldap32");
extern(C)
wchar** ldap_get_valuesW(
LDAP* ld, // LDAP* in/out
LDAPMessage* entry, // LDAPMessage* in/out
const(wchar)* attr // LPCWSTR
);ccall((:ldap_get_valuesW, "WLDAP32.dll"), Ptr{Ptr{UInt16}},
(Ptr{LDAP}, Ptr{LDAPMessage}, Cwstring),
ld, entry, attr)
# ld : LDAP* in/out -> Ptr{LDAP}
# entry : LDAPMessage* in/out -> Ptr{LDAPMessage}
# attr : LPCWSTR -> Cwstring
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint16_t** ldap_get_valuesW(
void* ld,
void* entry,
const uint16_t* attr);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_get_valuesW(ld, entry, attr)
-- ld : LDAP* in/out
-- entry : LDAPMessage* in/out
-- attr : LPCWSTR
-- 構造体/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_get_valuesW = lib.func('__cdecl', 'ldap_get_valuesW', 'void *', ['void *', 'void *', 'str16']);
// ldap_get_valuesW(ld, entry, attr)
// ld : LDAP* in/out -> 'void *'
// entry : LDAPMessage* in/out -> 'void *'
// attr : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WLDAP32.dll", {
ldap_get_valuesW: { parameters: ["pointer", "pointer", "buffer"], result: "pointer" },
});
// lib.symbols.ldap_get_valuesW(ld, entry, attr)
// ld : LDAP* in/out -> "pointer"
// entry : LDAPMessage* in/out -> "pointer"
// attr : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint16_t** ldap_get_valuesW(
void* ld,
void* entry,
const uint16_t* attr);
C, "WLDAP32.dll");
// $ffi->ldap_get_valuesW(ld, entry, attr);
// ld : LDAP* in/out
// entry : LDAPMessage* in/out
// attr : LPCWSTR
// 構造体/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);
Pointer ldap_get_valuesW(
Pointer ld, // LDAP* in/out
Pointer entry, // LDAPMessage* in/out
WString attr // LPCWSTR
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("wldap32")]
lib LibWLDAP32
fun ldap_get_valuesW = ldap_get_valuesW(
ld : LDAP*, # LDAP* in/out
entry : LDAPMessage*, # LDAPMessage* in/out
attr : UInt16* # LPCWSTR
) : UInt16**
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ldap_get_valuesWNative = Pointer<Pointer<Utf16>> Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
typedef ldap_get_valuesWDart = Pointer<Pointer<Utf16>> Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
final ldap_get_valuesW = DynamicLibrary.open('WLDAP32.dll')
.lookupFunction<ldap_get_valuesWNative, ldap_get_valuesWDart>('ldap_get_valuesW');
// ld : LDAP* in/out -> Pointer<Void>
// entry : LDAPMessage* in/out -> Pointer<Void>
// attr : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ldap_get_valuesW(
ld: Pointer; // LDAP* in/out
entry: Pointer; // LDAPMessage* in/out
attr: PWideChar // LPCWSTR
): PWideChar; cdecl;
external 'WLDAP32.dll' name 'ldap_get_valuesW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ldap_get_valuesW"
c_ldap_get_valuesW :: Ptr () -> Ptr () -> CWString -> IO (Ptr CWString)
-- ld : LDAP* in/out -> Ptr ()
-- entry : LDAPMessage* in/out -> Ptr ()
-- attr : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ldap_get_valuesw =
foreign "ldap_get_valuesW"
((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> returning (ptr (ptr uint16_t)))
(* ld : LDAP* in/out -> (ptr void) *)
(* entry : LDAPMessage* in/out -> (ptr void) *)
(* attr : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)
(cffi:defcfun ("ldap_get_valuesW" ldap-get-values-w :convention :cdecl) :pointer
(ld :pointer) ; LDAP* in/out
(entry :pointer) ; LDAPMessage* in/out
(attr (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ldap_get_valuesW = Win32::API::More->new('WLDAP32',
'LPWSTR ldap_get_valuesW(LPVOID ld, LPVOID entry, LPCWSTR attr)');
# my $ret = $ldap_get_valuesW->Call($ld, $entry, $attr);
# ld : LDAP* in/out -> LPVOID
# entry : LDAPMessage* in/out -> LPVOID
# attr : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f ldap_get_valuesA (ANSI版) — エントリの指定属性の値配列を取得する(ANSI版)。
使用する型