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

ldap_modrdnA

関数
LDAPエントリのRDNを非同期に変更する(旧式ANSI版)。
DLLWLDAP32.dll文字セットANSI (-A)呼出規約cdecl対応OSWindows Vista 以降

シグネチャ

// WLDAP32.dll  (ANSI / -A)
#include <windows.h>

DWORD ldap_modrdnA(
    LDAP* ExternalHandle,
    LPCSTR DistinguishedName,
    LPCSTR NewDistinguishedName
);

パラメーター

名前方向説明
ExternalHandleLDAP*inout操作対象のLDAPセッションハンドル。
DistinguishedNameLPCSTRinRDN変更対象エントリの現在の識別名(DN、ANSI)。
NewDistinguishedNameLPCSTRin新しい相対識別名(RDN、ANSI)。エントリのRDNを置き換える。

戻り値の型: DWORD

各言語での呼び出し定義

// WLDAP32.dll  (ANSI / -A)
#include <windows.h>

DWORD ldap_modrdnA(
    LDAP* ExternalHandle,
    LPCSTR DistinguishedName,
    LPCSTR NewDistinguishedName
);
[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_modrdnA(
    IntPtr ExternalHandle,   // LDAP* in/out
    [MarshalAs(UnmanagedType.LPStr)] string DistinguishedName,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string NewDistinguishedName   // LPCSTR
);
<DllImport("WLDAP32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_modrdnA(
    ExternalHandle As IntPtr,   ' LDAP* in/out
    <MarshalAs(UnmanagedType.LPStr)> DistinguishedName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> NewDistinguishedName As String   ' LPCSTR
) As UInteger
End Function
' ExternalHandle : LDAP* in/out
' DistinguishedName : LPCSTR
' NewDistinguishedName : LPCSTR
Declare PtrSafe Function ldap_modrdnA Lib "wldap32" ( _
    ByVal ExternalHandle As LongPtr, _
    ByVal DistinguishedName As String, _
    ByVal NewDistinguishedName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ldap_modrdnA = ctypes.cdll.wldap32.ldap_modrdnA
ldap_modrdnA.restype = wintypes.DWORD
ldap_modrdnA.argtypes = [
    ctypes.c_void_p,  # ExternalHandle : LDAP* in/out
    wintypes.LPCSTR,  # DistinguishedName : LPCSTR
    wintypes.LPCSTR,  # NewDistinguishedName : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WLDAP32.dll')
ldap_modrdnA = Fiddle::Function.new(
  lib['ldap_modrdnA'],
  [
    Fiddle::TYPE_VOIDP,  # ExternalHandle : LDAP* in/out
    Fiddle::TYPE_VOIDP,  # DistinguishedName : LPCSTR
    Fiddle::TYPE_VOIDP,  # NewDistinguishedName : LPCSTR
  ],
  -Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "wldap32")]
extern "C" {
    fn ldap_modrdnA(
        ExternalHandle: *mut LDAP,  // LDAP* in/out
        DistinguishedName: *const u8,  // LPCSTR
        NewDistinguishedName: *const u8  // LPCSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern uint ldap_modrdnA(IntPtr ExternalHandle, [MarshalAs(UnmanagedType.LPStr)] string DistinguishedName, [MarshalAs(UnmanagedType.LPStr)] string NewDistinguishedName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_modrdnA' -Namespace Win32 -PassThru
# $api::ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName)
#uselib "WLDAP32.dll"
#func global ldap_modrdnA "ldap_modrdnA" sptr, sptr, sptr
; ldap_modrdnA varptr(ExternalHandle), DistinguishedName, NewDistinguishedName   ; 戻り値は stat
; ExternalHandle : LDAP* in/out -> "sptr"
; DistinguishedName : LPCSTR -> "sptr"
; NewDistinguishedName : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WLDAP32.dll"
#cfunc global ldap_modrdnA "ldap_modrdnA" var, str, str
; res = ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName)
; ExternalHandle : LDAP* in/out -> "var"
; DistinguishedName : LPCSTR -> "str"
; NewDistinguishedName : LPCSTR -> "str"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD ldap_modrdnA(LDAP* ExternalHandle, LPCSTR DistinguishedName, LPCSTR NewDistinguishedName)
#uselib "WLDAP32.dll"
#cfunc global ldap_modrdnA "ldap_modrdnA" var, str, str
; res = ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName)
; ExternalHandle : LDAP* in/out -> "var"
; DistinguishedName : LPCSTR -> "str"
; NewDistinguishedName : LPCSTR -> "str"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
	procldap_modrdnA = wldap32.NewProc("ldap_modrdnA")
)

// ExternalHandle (LDAP* in/out), DistinguishedName (LPCSTR), NewDistinguishedName (LPCSTR)
r1, _, err := procldap_modrdnA.Call(
	uintptr(ExternalHandle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(DistinguishedName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(NewDistinguishedName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ldap_modrdnA(
  ExternalHandle: Pointer;   // LDAP* in/out
  DistinguishedName: PAnsiChar;   // LPCSTR
  NewDistinguishedName: PAnsiChar   // LPCSTR
): DWORD; cdecl;
  external 'WLDAP32.dll' name 'ldap_modrdnA';
result := DllCall("WLDAP32\ldap_modrdnA"
    , "Ptr", ExternalHandle   ; LDAP* in/out
    , "AStr", DistinguishedName   ; LPCSTR
    , "AStr", NewDistinguishedName   ; LPCSTR
    , "Cdecl UInt")   ; return: DWORD
●ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName) = DLL("WLDAP32.dll", "dword ldap_modrdnA(void*, char*, char*)")
# 呼び出し: ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName)
# ExternalHandle : LDAP* in/out -> "void*"
# DistinguishedName : LPCSTR -> "char*"
# NewDistinguishedName : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。
const std = @import("std");

extern "wldap32" fn ldap_modrdnA(
    ExternalHandle: [*c]LDAP, // LDAP* in/out
    DistinguishedName: [*c]const u8, // LPCSTR
    NewDistinguishedName: [*c]const u8 // LPCSTR
) callconv(.c) u32;
proc ldap_modrdnA(
    ExternalHandle: ptr LDAP,  # LDAP* in/out
    DistinguishedName: cstring,  # LPCSTR
    NewDistinguishedName: cstring  # LPCSTR
): uint32 {.importc: "ldap_modrdnA", cdecl, dynlib: "WLDAP32.dll".}
pragma(lib, "wldap32");
extern(C)
uint ldap_modrdnA(
    LDAP* ExternalHandle,   // LDAP* in/out
    const(char)* DistinguishedName,   // LPCSTR
    const(char)* NewDistinguishedName   // LPCSTR
);
ccall((:ldap_modrdnA, "WLDAP32.dll"), UInt32,
      (Ptr{LDAP}, Cstring, Cstring),
      ExternalHandle, DistinguishedName, NewDistinguishedName)
# ExternalHandle : LDAP* in/out -> Ptr{LDAP}
# DistinguishedName : LPCSTR -> Cstring
# NewDistinguishedName : LPCSTR -> Cstring
local ffi = require("ffi")
ffi.cdef[[
uint32_t ldap_modrdnA(
    void* ExternalHandle,
    const char* DistinguishedName,
    const char* NewDistinguishedName);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName)
-- ExternalHandle : LDAP* in/out
-- DistinguishedName : LPCSTR
-- NewDistinguishedName : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WLDAP32.dll');
const ldap_modrdnA = lib.func('__cdecl', 'ldap_modrdnA', 'uint32_t', ['void *', 'str', 'str']);
// ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName)
// ExternalHandle : LDAP* in/out -> 'void *'
// DistinguishedName : LPCSTR -> 'str'
// NewDistinguishedName : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WLDAP32.dll", {
  ldap_modrdnA: { parameters: ["pointer", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName)
// ExternalHandle : LDAP* in/out -> "pointer"
// DistinguishedName : LPCSTR -> "buffer"
// NewDistinguishedName : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t ldap_modrdnA(
    void* ExternalHandle,
    const char* DistinguishedName,
    const char* NewDistinguishedName);
C, "WLDAP32.dll");
// $ffi->ldap_modrdnA(ExternalHandle, DistinguishedName, NewDistinguishedName);
// ExternalHandle : LDAP* in/out
// DistinguishedName : LPCSTR
// NewDistinguishedName : LPCSTR
// 構造体/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);
    int ldap_modrdnA(
        Pointer ExternalHandle,   // LDAP* in/out
        String DistinguishedName,   // LPCSTR
        String NewDistinguishedName   // LPCSTR
    );
}
@[Link("wldap32")]
lib LibWLDAP32
  fun ldap_modrdnA = ldap_modrdnA(
    ExternalHandle : LDAP*,   # LDAP* in/out
    DistinguishedName : UInt8*,   # LPCSTR
    NewDistinguishedName : UInt8*   # LPCSTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ldap_modrdnANative = Uint32 Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>);
typedef ldap_modrdnADart = int Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>);
final ldap_modrdnA = DynamicLibrary.open('WLDAP32.dll')
    .lookupFunction<ldap_modrdnANative, ldap_modrdnADart>('ldap_modrdnA');
// ExternalHandle : LDAP* in/out -> Pointer<Void>
// DistinguishedName : LPCSTR -> Pointer<Utf8>
// NewDistinguishedName : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ldap_modrdnA(
  ExternalHandle: Pointer;   // LDAP* in/out
  DistinguishedName: PAnsiChar;   // LPCSTR
  NewDistinguishedName: PAnsiChar   // LPCSTR
): DWORD; cdecl;
  external 'WLDAP32.dll' name 'ldap_modrdnA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ldap_modrdnA"
  c_ldap_modrdnA :: Ptr () -> CString -> CString -> IO Word32
-- ExternalHandle : LDAP* in/out -> Ptr ()
-- DistinguishedName : LPCSTR -> CString
-- NewDistinguishedName : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ldap_modrdna =
  foreign "ldap_modrdnA"
    ((ptr void) @-> string @-> string @-> returning uint32_t)
(* ExternalHandle : LDAP* in/out -> (ptr void) *)
(* DistinguishedName : LPCSTR -> string *)
(* NewDistinguishedName : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)

(cffi:defcfun ("ldap_modrdnA" ldap-modrdn-a :convention :cdecl) :uint32
  (external-handle :pointer)   ; LDAP* in/out
  (distinguished-name :string)   ; LPCSTR
  (new-distinguished-name :string))   ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ldap_modrdnA = Win32::API::More->new('WLDAP32',
    'DWORD ldap_modrdnA(LPVOID ExternalHandle, LPCSTR DistinguishedName, LPCSTR NewDistinguishedName)');
# my $ret = $ldap_modrdnA->Call($ExternalHandle, $DistinguishedName, $NewDistinguishedName);
# ExternalHandle : LDAP* in/out -> LPVOID
# DistinguishedName : LPCSTR -> LPCSTR
# NewDistinguishedName : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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