Win32 API 日本語リファレンス
ホームNetworking.Ldap › ldap_parse_extended_resultW

ldap_parse_extended_resultW

関数
拡張操作の結果からOIDとデータを解析する(Unicode版)。
DLLWLDAP32.dll文字セットUnicode (-W)呼出規約cdecl対応OSWindows Vista 以降

シグネチャ

// WLDAP32.dll  (Unicode / -W)
#include <windows.h>

DWORD ldap_parse_extended_resultW(
    LDAP* Connection,
    LDAPMessage* ResultMessage,
    LPWSTR* ResultOID,   // optional
    LDAP_BERVAL** ResultData,
    BOOLEAN Freeit
);

パラメーター

名前方向説明
ConnectionLDAP*inout対象のLDAPセッションハンドル。拡張操作の応答を受けた接続を指す。
ResultMessageLDAPMessage*inout解析対象の拡張操作結果メッセージ。サーバ応答を渡す。
ResultOIDLPWSTR*outoptional応答の拡張操作OID文字列を受け取る出力ポインタ。ldap_memfreeで解放。NULL可。
ResultDataLDAP_BERVAL**inout拡張操作の返却データ(berval)を受け取る出力先。ber_bvfreeで解放する。NULL可。
FreeitBOOLEANin0以外ならResultMessageを解析後に自動解放する真偽フラグ。

戻り値の型: DWORD

各言語での呼び出し定義

// WLDAP32.dll  (Unicode / -W)
#include <windows.h>

DWORD ldap_parse_extended_resultW(
    LDAP* Connection,
    LDAPMessage* ResultMessage,
    LPWSTR* ResultOID,   // optional
    LDAP_BERVAL** ResultData,
    BOOLEAN Freeit
);
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_parse_extended_resultW(
    IntPtr Connection,   // LDAP* in/out
    IntPtr ResultMessage,   // LDAPMessage* in/out
    IntPtr ResultOID,   // LPWSTR* optional, out
    IntPtr ResultData,   // LDAP_BERVAL** in/out
    [MarshalAs(UnmanagedType.U1)] bool Freeit   // BOOLEAN
);
<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_parse_extended_resultW(
    Connection As IntPtr,   ' LDAP* in/out
    ResultMessage As IntPtr,   ' LDAPMessage* in/out
    ResultOID As IntPtr,   ' LPWSTR* optional, out
    ResultData As IntPtr,   ' LDAP_BERVAL** in/out
    <MarshalAs(UnmanagedType.U1)> Freeit As Boolean   ' BOOLEAN
) As UInteger
End Function
' Connection : LDAP* in/out
' ResultMessage : LDAPMessage* in/out
' ResultOID : LPWSTR* optional, out
' ResultData : LDAP_BERVAL** in/out
' Freeit : BOOLEAN
Declare PtrSafe Function ldap_parse_extended_resultW Lib "wldap32" ( _
    ByVal Connection As LongPtr, _
    ByVal ResultMessage As LongPtr, _
    ByVal ResultOID As LongPtr, _
    ByVal ResultData As LongPtr, _
    ByVal Freeit As Byte) As Long
' 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_parse_extended_resultW = ctypes.cdll.wldap32.ldap_parse_extended_resultW
ldap_parse_extended_resultW.restype = wintypes.DWORD
ldap_parse_extended_resultW.argtypes = [
    ctypes.c_void_p,  # Connection : LDAP* in/out
    ctypes.c_void_p,  # ResultMessage : LDAPMessage* in/out
    ctypes.c_void_p,  # ResultOID : LPWSTR* optional, out
    ctypes.c_void_p,  # ResultData : LDAP_BERVAL** in/out
    wintypes.BOOLEAN,  # Freeit : BOOLEAN
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WLDAP32.dll')
ldap_parse_extended_resultW = Fiddle::Function.new(
  lib['ldap_parse_extended_resultW'],
  [
    Fiddle::TYPE_VOIDP,  # Connection : LDAP* in/out
    Fiddle::TYPE_VOIDP,  # ResultMessage : LDAPMessage* in/out
    Fiddle::TYPE_VOIDP,  # ResultOID : LPWSTR* optional, out
    Fiddle::TYPE_VOIDP,  # ResultData : LDAP_BERVAL** in/out
    Fiddle::TYPE_CHAR,  # Freeit : BOOLEAN
  ],
  -Fiddle::TYPE_INT, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wldap32")]
extern "C" {
    fn ldap_parse_extended_resultW(
        Connection: *mut LDAP,  // LDAP* in/out
        ResultMessage: *mut LDAPMessage,  // LDAPMessage* in/out
        ResultOID: *mut *mut u16,  // LPWSTR* optional, out
        ResultData: *mut *mut LDAP_BERVAL,  // LDAP_BERVAL** in/out
        Freeit: u8  // BOOLEAN
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ldap_parse_extended_resultW(IntPtr Connection, IntPtr ResultMessage, IntPtr ResultOID, IntPtr ResultData, [MarshalAs(UnmanagedType.U1)] bool Freeit);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_parse_extended_resultW' -Namespace Win32 -PassThru
# $api::ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit)
#uselib "WLDAP32.dll"
#func global ldap_parse_extended_resultW "ldap_parse_extended_resultW" wptr, wptr, wptr, wptr, wptr
; ldap_parse_extended_resultW varptr(Connection), varptr(ResultMessage), varptr(ResultOID), varptr(ResultData), Freeit   ; 戻り値は stat
; Connection : LDAP* in/out -> "wptr"
; ResultMessage : LDAPMessage* in/out -> "wptr"
; ResultOID : LPWSTR* optional, out -> "wptr"
; ResultData : LDAP_BERVAL** in/out -> "wptr"
; Freeit : BOOLEAN -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WLDAP32.dll"
#cfunc global ldap_parse_extended_resultW "ldap_parse_extended_resultW" var, var, var, var, int
; res = ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit)
; Connection : LDAP* in/out -> "var"
; ResultMessage : LDAPMessage* in/out -> "var"
; ResultOID : LPWSTR* optional, out -> "var"
; ResultData : LDAP_BERVAL** in/out -> "var"
; Freeit : BOOLEAN -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD ldap_parse_extended_resultW(LDAP* Connection, LDAPMessage* ResultMessage, LPWSTR* ResultOID, LDAP_BERVAL** ResultData, BOOLEAN Freeit)
#uselib "WLDAP32.dll"
#cfunc global ldap_parse_extended_resultW "ldap_parse_extended_resultW" var, var, var, var, int
; res = ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit)
; Connection : LDAP* in/out -> "var"
; ResultMessage : LDAPMessage* in/out -> "var"
; ResultOID : LPWSTR* optional, out -> "var"
; ResultData : LDAP_BERVAL** in/out -> "var"
; Freeit : BOOLEAN -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
	procldap_parse_extended_resultW = wldap32.NewProc("ldap_parse_extended_resultW")
)

// Connection (LDAP* in/out), ResultMessage (LDAPMessage* in/out), ResultOID (LPWSTR* optional, out), ResultData (LDAP_BERVAL** in/out), Freeit (BOOLEAN)
r1, _, err := procldap_parse_extended_resultW.Call(
	uintptr(Connection),
	uintptr(ResultMessage),
	uintptr(ResultOID),
	uintptr(ResultData),
	uintptr(Freeit),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ldap_parse_extended_resultW(
  Connection: Pointer;   // LDAP* in/out
  ResultMessage: Pointer;   // LDAPMessage* in/out
  ResultOID: PPWideChar;   // LPWSTR* optional, out
  ResultData: Pointer;   // LDAP_BERVAL** in/out
  Freeit: ByteBool   // BOOLEAN
): DWORD; cdecl;
  external 'WLDAP32.dll' name 'ldap_parse_extended_resultW';
result := DllCall("WLDAP32\ldap_parse_extended_resultW"
    , "Ptr", Connection   ; LDAP* in/out
    , "Ptr", ResultMessage   ; LDAPMessage* in/out
    , "Ptr", ResultOID   ; LPWSTR* optional, out
    , "Ptr", ResultData   ; LDAP_BERVAL** in/out
    , "Char", Freeit   ; BOOLEAN
    , "Cdecl UInt")   ; return: DWORD
●ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit) = DLL("WLDAP32.dll", "dword ldap_parse_extended_resultW(void*, void*, void*, void*, byte)")
# 呼び出し: ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit)
# Connection : LDAP* in/out -> "void*"
# ResultMessage : LDAPMessage* in/out -> "void*"
# ResultOID : LPWSTR* optional, out -> "void*"
# ResultData : LDAP_BERVAL** in/out -> "void*"
# Freeit : BOOLEAN -> "byte"
# なでしこ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_parse_extended_resultW(
    Connection: [*c]LDAP, // LDAP* in/out
    ResultMessage: [*c]LDAPMessage, // LDAPMessage* in/out
    ResultOID: [*c][*c]u16, // LPWSTR* optional, out
    ResultData: [*c][*c]LDAP_BERVAL, // LDAP_BERVAL** in/out
    Freeit: u8 // BOOLEAN
) callconv(.c) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc ldap_parse_extended_resultW(
    Connection: ptr LDAP,  # LDAP* in/out
    ResultMessage: ptr LDAPMessage,  # LDAPMessage* in/out
    ResultOID: ptr WideCString,  # LPWSTR* optional, out
    ResultData: ptr LDAP_BERVAL,  # LDAP_BERVAL** in/out
    Freeit: uint8  # BOOLEAN
): uint32 {.importc: "ldap_parse_extended_resultW", cdecl, dynlib: "WLDAP32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "wldap32");
extern(C)
uint ldap_parse_extended_resultW(
    LDAP* Connection,   // LDAP* in/out
    LDAPMessage* ResultMessage,   // LDAPMessage* in/out
    wchar** ResultOID,   // LPWSTR* optional, out
    LDAP_BERVAL** ResultData,   // LDAP_BERVAL** in/out
    ubyte Freeit   // BOOLEAN
);
ccall((:ldap_parse_extended_resultW, "WLDAP32.dll"), UInt32,
      (Ptr{LDAP}, Ptr{LDAPMessage}, Ptr{Ptr{UInt16}}, Ptr{LDAP_BERVAL}, UInt8),
      Connection, ResultMessage, ResultOID, ResultData, Freeit)
# Connection : LDAP* in/out -> Ptr{LDAP}
# ResultMessage : LDAPMessage* in/out -> Ptr{LDAPMessage}
# ResultOID : LPWSTR* optional, out -> Ptr{Ptr{UInt16}}
# ResultData : LDAP_BERVAL** in/out -> Ptr{LDAP_BERVAL}
# Freeit : BOOLEAN -> UInt8
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t ldap_parse_extended_resultW(
    void* Connection,
    void* ResultMessage,
    uint16_t** ResultOID,
    void* ResultData,
    uint8_t Freeit);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit)
-- Connection : LDAP* in/out
-- ResultMessage : LDAPMessage* in/out
-- ResultOID : LPWSTR* optional, out
-- ResultData : LDAP_BERVAL** in/out
-- Freeit : BOOLEAN
-- 構造体/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_parse_extended_resultW = lib.func('__cdecl', 'ldap_parse_extended_resultW', 'uint32_t', ['void *', 'void *', 'void *', 'void *', 'uint8_t']);
// ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit)
// Connection : LDAP* in/out -> 'void *'
// ResultMessage : LDAPMessage* in/out -> 'void *'
// ResultOID : LPWSTR* optional, out -> 'void *'
// ResultData : LDAP_BERVAL** in/out -> 'void *'
// Freeit : BOOLEAN -> 'uint8_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WLDAP32.dll", {
  ldap_parse_extended_resultW: { parameters: ["pointer", "pointer", "pointer", "pointer", "u8"], result: "u32" },
});
// lib.symbols.ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit)
// Connection : LDAP* in/out -> "pointer"
// ResultMessage : LDAPMessage* in/out -> "pointer"
// ResultOID : LPWSTR* optional, out -> "pointer"
// ResultData : LDAP_BERVAL** in/out -> "pointer"
// Freeit : BOOLEAN -> "u8"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t ldap_parse_extended_resultW(
    void* Connection,
    void* ResultMessage,
    uint16_t** ResultOID,
    void* ResultData,
    uint8_t Freeit);
C, "WLDAP32.dll");
// $ffi->ldap_parse_extended_resultW(Connection, ResultMessage, ResultOID, ResultData, Freeit);
// Connection : LDAP* in/out
// ResultMessage : LDAPMessage* in/out
// ResultOID : LPWSTR* optional, out
// ResultData : LDAP_BERVAL** in/out
// Freeit : BOOLEAN
// 構造体/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);
    int ldap_parse_extended_resultW(
        Pointer Connection,   // LDAP* in/out
        Pointer ResultMessage,   // LDAPMessage* in/out
        PointerByReference ResultOID,   // LPWSTR* optional, out
        Pointer ResultData,   // LDAP_BERVAL** in/out
        byte Freeit   // BOOLEAN
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("wldap32")]
lib LibWLDAP32
  fun ldap_parse_extended_resultW = ldap_parse_extended_resultW(
    Connection : LDAP*,   # LDAP* in/out
    ResultMessage : LDAPMessage*,   # LDAPMessage* in/out
    ResultOID : UInt16**,   # LPWSTR* optional, out
    ResultData : LDAP_BERVAL**,   # LDAP_BERVAL** in/out
    Freeit : UInt8   # BOOLEAN
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ldap_parse_extended_resultWNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Pointer<Utf16>>, Pointer<Void>, Uint8);
typedef ldap_parse_extended_resultWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Pointer<Utf16>>, Pointer<Void>, int);
final ldap_parse_extended_resultW = DynamicLibrary.open('WLDAP32.dll')
    .lookupFunction<ldap_parse_extended_resultWNative, ldap_parse_extended_resultWDart>('ldap_parse_extended_resultW');
// Connection : LDAP* in/out -> Pointer<Void>
// ResultMessage : LDAPMessage* in/out -> Pointer<Void>
// ResultOID : LPWSTR* optional, out -> Pointer<Pointer<Utf16>>
// ResultData : LDAP_BERVAL** in/out -> Pointer<Void>
// Freeit : BOOLEAN -> Uint8
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ldap_parse_extended_resultW(
  Connection: Pointer;   // LDAP* in/out
  ResultMessage: Pointer;   // LDAPMessage* in/out
  ResultOID: PPWideChar;   // LPWSTR* optional, out
  ResultData: Pointer;   // LDAP_BERVAL** in/out
  Freeit: ByteBool   // BOOLEAN
): DWORD; cdecl;
  external 'WLDAP32.dll' name 'ldap_parse_extended_resultW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ldap_parse_extended_resultW"
  c_ldap_parse_extended_resultW :: Ptr () -> Ptr () -> Ptr CWString -> Ptr () -> Word8 -> IO Word32
-- Connection : LDAP* in/out -> Ptr ()
-- ResultMessage : LDAPMessage* in/out -> Ptr ()
-- ResultOID : LPWSTR* optional, out -> Ptr CWString
-- ResultData : LDAP_BERVAL** in/out -> Ptr ()
-- Freeit : BOOLEAN -> Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ldap_parse_extended_resultw =
  foreign "ldap_parse_extended_resultW"
    ((ptr void) @-> (ptr void) @-> (ptr (ptr uint16_t)) @-> (ptr void) @-> uint8_t @-> returning uint32_t)
(* Connection : LDAP* in/out -> (ptr void) *)
(* ResultMessage : LDAPMessage* in/out -> (ptr void) *)
(* ResultOID : LPWSTR* optional, out -> (ptr (ptr uint16_t)) *)
(* ResultData : LDAP_BERVAL** in/out -> (ptr void) *)
(* Freeit : BOOLEAN -> uint8_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)

(cffi:defcfun ("ldap_parse_extended_resultW" ldap-parse-extended-result-w :convention :cdecl) :uint32
  (connection :pointer)   ; LDAP* in/out
  (result-message :pointer)   ; LDAPMessage* in/out
  (result-oid :pointer)   ; LPWSTR* optional, out
  (result-data :pointer)   ; LDAP_BERVAL** in/out
  (freeit :uint8))   ; BOOLEAN
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ldap_parse_extended_resultW = Win32::API::More->new('WLDAP32',
    'DWORD ldap_parse_extended_resultW(LPVOID Connection, LPVOID ResultMessage, LPVOID ResultOID, LPVOID ResultData, BYTE Freeit)');
# my $ret = $ldap_parse_extended_resultW->Call($Connection, $ResultMessage, $ResultOID, $ResultData, $Freeit);
# Connection : LDAP* in/out -> LPVOID
# ResultMessage : LDAPMessage* in/out -> LPVOID
# ResultOID : LPWSTR* optional, out -> LPVOID
# ResultData : LDAP_BERVAL** in/out -> LPVOID
# Freeit : BOOLEAN -> BYTE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
使用する型