ホーム › Networking.Ldap › ldap_modrdn2_sW
ldap_modrdn2_sW
関数LDAPエントリのRDNを同期的に変更する(Unicode版)。
シグネチャ
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
DWORD ldap_modrdn2_sW(
LDAP* ExternalHandle,
LPCWSTR DistinguishedName,
LPCWSTR NewDistinguishedName,
INT DeleteOldRdn
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ExternalHandle | LDAP* | inout |
| DistinguishedName | LPCWSTR | in |
| NewDistinguishedName | LPCWSTR | in |
| DeleteOldRdn | INT | in |
戻り値の型: DWORD
各言語での呼び出し定義
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
DWORD ldap_modrdn2_sW(
LDAP* ExternalHandle,
LPCWSTR DistinguishedName,
LPCWSTR NewDistinguishedName,
INT DeleteOldRdn
);[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_modrdn2_sW(
IntPtr ExternalHandle, // LDAP* in/out
[MarshalAs(UnmanagedType.LPWStr)] string DistinguishedName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string NewDistinguishedName, // LPCWSTR
int DeleteOldRdn // INT
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_modrdn2_sW(
ExternalHandle As IntPtr, ' LDAP* in/out
<MarshalAs(UnmanagedType.LPWStr)> DistinguishedName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> NewDistinguishedName As String, ' LPCWSTR
DeleteOldRdn As Integer ' INT
) As UInteger
End Function' ExternalHandle : LDAP* in/out
' DistinguishedName : LPCWSTR
' NewDistinguishedName : LPCWSTR
' DeleteOldRdn : INT
Declare PtrSafe Function ldap_modrdn2_sW Lib "wldap32" ( _
ByVal ExternalHandle As LongPtr, _
ByVal DistinguishedName As LongPtr, _
ByVal NewDistinguishedName As LongPtr, _
ByVal DeleteOldRdn As Long) 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_modrdn2_sW = ctypes.cdll.wldap32.ldap_modrdn2_sW
ldap_modrdn2_sW.restype = wintypes.DWORD
ldap_modrdn2_sW.argtypes = [
ctypes.c_void_p, # ExternalHandle : LDAP* in/out
wintypes.LPCWSTR, # DistinguishedName : LPCWSTR
wintypes.LPCWSTR, # NewDistinguishedName : LPCWSTR
ctypes.c_int, # DeleteOldRdn : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_modrdn2_sW = Fiddle::Function.new(
lib['ldap_modrdn2_sW'],
[
Fiddle::TYPE_VOIDP, # ExternalHandle : LDAP* in/out
Fiddle::TYPE_VOIDP, # DistinguishedName : LPCWSTR
Fiddle::TYPE_VOIDP, # NewDistinguishedName : LPCWSTR
Fiddle::TYPE_INT, # DeleteOldRdn : INT
],
-Fiddle::TYPE_INT, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wldap32")]
extern "C" {
fn ldap_modrdn2_sW(
ExternalHandle: *mut LDAP, // LDAP* in/out
DistinguishedName: *const u16, // LPCWSTR
NewDistinguishedName: *const u16, // LPCWSTR
DeleteOldRdn: i32 // INT
) -> 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_modrdn2_sW(IntPtr ExternalHandle, [MarshalAs(UnmanagedType.LPWStr)] string DistinguishedName, [MarshalAs(UnmanagedType.LPWStr)] string NewDistinguishedName, int DeleteOldRdn);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_modrdn2_sW' -Namespace Win32 -PassThru
# $api::ldap_modrdn2_sW(ExternalHandle, DistinguishedName, NewDistinguishedName, DeleteOldRdn)#uselib "WLDAP32.dll"
#func global ldap_modrdn2_sW "ldap_modrdn2_sW" wptr, wptr, wptr, wptr
; ldap_modrdn2_sW varptr(ExternalHandle), DistinguishedName, NewDistinguishedName, DeleteOldRdn ; 戻り値は stat
; ExternalHandle : LDAP* in/out -> "wptr"
; DistinguishedName : LPCWSTR -> "wptr"
; NewDistinguishedName : LPCWSTR -> "wptr"
; DeleteOldRdn : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WLDAP32.dll" #cfunc global ldap_modrdn2_sW "ldap_modrdn2_sW" var, wstr, wstr, int ; res = ldap_modrdn2_sW(ExternalHandle, DistinguishedName, NewDistinguishedName, DeleteOldRdn) ; ExternalHandle : LDAP* in/out -> "var" ; DistinguishedName : LPCWSTR -> "wstr" ; NewDistinguishedName : LPCWSTR -> "wstr" ; DeleteOldRdn : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WLDAP32.dll" #cfunc global ldap_modrdn2_sW "ldap_modrdn2_sW" sptr, wstr, wstr, int ; res = ldap_modrdn2_sW(varptr(ExternalHandle), DistinguishedName, NewDistinguishedName, DeleteOldRdn) ; ExternalHandle : LDAP* in/out -> "sptr" ; DistinguishedName : LPCWSTR -> "wstr" ; NewDistinguishedName : LPCWSTR -> "wstr" ; DeleteOldRdn : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ldap_modrdn2_sW(LDAP* ExternalHandle, LPCWSTR DistinguishedName, LPCWSTR NewDistinguishedName, INT DeleteOldRdn) #uselib "WLDAP32.dll" #cfunc global ldap_modrdn2_sW "ldap_modrdn2_sW" var, wstr, wstr, int ; res = ldap_modrdn2_sW(ExternalHandle, DistinguishedName, NewDistinguishedName, DeleteOldRdn) ; ExternalHandle : LDAP* in/out -> "var" ; DistinguishedName : LPCWSTR -> "wstr" ; NewDistinguishedName : LPCWSTR -> "wstr" ; DeleteOldRdn : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ldap_modrdn2_sW(LDAP* ExternalHandle, LPCWSTR DistinguishedName, LPCWSTR NewDistinguishedName, INT DeleteOldRdn) #uselib "WLDAP32.dll" #cfunc global ldap_modrdn2_sW "ldap_modrdn2_sW" intptr, wstr, wstr, int ; res = ldap_modrdn2_sW(varptr(ExternalHandle), DistinguishedName, NewDistinguishedName, DeleteOldRdn) ; ExternalHandle : LDAP* in/out -> "intptr" ; DistinguishedName : LPCWSTR -> "wstr" ; NewDistinguishedName : LPCWSTR -> "wstr" ; DeleteOldRdn : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_modrdn2_sW = wldap32.NewProc("ldap_modrdn2_sW")
)
// ExternalHandle (LDAP* in/out), DistinguishedName (LPCWSTR), NewDistinguishedName (LPCWSTR), DeleteOldRdn (INT)
r1, _, err := procldap_modrdn2_sW.Call(
uintptr(ExternalHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DistinguishedName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(NewDistinguishedName))),
uintptr(DeleteOldRdn),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ldap_modrdn2_sW(
ExternalHandle: Pointer; // LDAP* in/out
DistinguishedName: PWideChar; // LPCWSTR
NewDistinguishedName: PWideChar; // LPCWSTR
DeleteOldRdn: Integer // INT
): DWORD; cdecl;
external 'WLDAP32.dll' name 'ldap_modrdn2_sW';result := DllCall("WLDAP32\ldap_modrdn2_sW"
, "Ptr", ExternalHandle ; LDAP* in/out
, "WStr", DistinguishedName ; LPCWSTR
, "WStr", NewDistinguishedName ; LPCWSTR
, "Int", DeleteOldRdn ; INT
, "Cdecl UInt") ; return: DWORD●ldap_modrdn2_sW(ExternalHandle, DistinguishedName, NewDistinguishedName, DeleteOldRdn) = DLL("WLDAP32.dll", "dword ldap_modrdn2_sW(void*, char*, char*, int)")
# 呼び出し: ldap_modrdn2_sW(ExternalHandle, DistinguishedName, NewDistinguishedName, DeleteOldRdn)
# ExternalHandle : LDAP* in/out -> "void*"
# DistinguishedName : LPCWSTR -> "char*"
# NewDistinguishedName : LPCWSTR -> "char*"
# DeleteOldRdn : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。