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