ホーム › Networking.ActiveDirectory › DsBindW
DsBindW
関数指定ドメインコントローラへ接続しハンドルを取得する(Unicode版)。
シグネチャ
// NTDSAPI.dll (Unicode / -W)
#include <windows.h>
DWORD DsBindW(
LPCWSTR DomainControllerName, // optional
LPCWSTR DnsDomainName, // optional
HANDLE* phDS
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| DomainControllerName | LPCWSTR | inoptional |
| DnsDomainName | LPCWSTR | inoptional |
| phDS | HANDLE* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// NTDSAPI.dll (Unicode / -W)
#include <windows.h>
DWORD DsBindW(
LPCWSTR DomainControllerName, // optional
LPCWSTR DnsDomainName, // optional
HANDLE* phDS
);[DllImport("NTDSAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint DsBindW(
[MarshalAs(UnmanagedType.LPWStr)] string DomainControllerName, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string DnsDomainName, // LPCWSTR optional
IntPtr phDS // HANDLE* out
);<DllImport("NTDSAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DsBindW(
<MarshalAs(UnmanagedType.LPWStr)> DomainControllerName As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> DnsDomainName As String, ' LPCWSTR optional
phDS As IntPtr ' HANDLE* out
) As UInteger
End Function' DomainControllerName : LPCWSTR optional
' DnsDomainName : LPCWSTR optional
' phDS : HANDLE* out
Declare PtrSafe Function DsBindW Lib "ntdsapi" ( _
ByVal DomainControllerName As LongPtr, _
ByVal DnsDomainName As LongPtr, _
ByVal phDS 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
DsBindW = ctypes.windll.ntdsapi.DsBindW
DsBindW.restype = wintypes.DWORD
DsBindW.argtypes = [
wintypes.LPCWSTR, # DomainControllerName : LPCWSTR optional
wintypes.LPCWSTR, # DnsDomainName : LPCWSTR optional
ctypes.c_void_p, # phDS : HANDLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NTDSAPI.dll')
DsBindW = Fiddle::Function.new(
lib['DsBindW'],
[
Fiddle::TYPE_VOIDP, # DomainControllerName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # DnsDomainName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # phDS : HANDLE* out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "ntdsapi")]
extern "system" {
fn DsBindW(
DomainControllerName: *const u16, // LPCWSTR optional
DnsDomainName: *const u16, // LPCWSTR optional
phDS: *mut *mut core::ffi::c_void // HANDLE* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NTDSAPI.dll", CharSet = CharSet.Unicode)]
public static extern uint DsBindW([MarshalAs(UnmanagedType.LPWStr)] string DomainControllerName, [MarshalAs(UnmanagedType.LPWStr)] string DnsDomainName, IntPtr phDS);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTDSAPI_DsBindW' -Namespace Win32 -PassThru
# $api::DsBindW(DomainControllerName, DnsDomainName, phDS)#uselib "NTDSAPI.dll"
#func global DsBindW "DsBindW" wptr, wptr, wptr
; DsBindW DomainControllerName, DnsDomainName, phDS ; 戻り値は stat
; DomainControllerName : LPCWSTR optional -> "wptr"
; DnsDomainName : LPCWSTR optional -> "wptr"
; phDS : HANDLE* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NTDSAPI.dll"
#cfunc global DsBindW "DsBindW" wstr, wstr, sptr
; res = DsBindW(DomainControllerName, DnsDomainName, phDS)
; DomainControllerName : LPCWSTR optional -> "wstr"
; DnsDomainName : LPCWSTR optional -> "wstr"
; phDS : HANDLE* out -> "sptr"; DWORD DsBindW(LPCWSTR DomainControllerName, LPCWSTR DnsDomainName, HANDLE* phDS)
#uselib "NTDSAPI.dll"
#cfunc global DsBindW "DsBindW" wstr, wstr, intptr
; res = DsBindW(DomainControllerName, DnsDomainName, phDS)
; DomainControllerName : LPCWSTR optional -> "wstr"
; DnsDomainName : LPCWSTR optional -> "wstr"
; phDS : HANDLE* out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ntdsapi = windows.NewLazySystemDLL("NTDSAPI.dll")
procDsBindW = ntdsapi.NewProc("DsBindW")
)
// DomainControllerName (LPCWSTR optional), DnsDomainName (LPCWSTR optional), phDS (HANDLE* out)
r1, _, err := procDsBindW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DomainControllerName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DnsDomainName))),
uintptr(phDS),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DsBindW(
DomainControllerName: PWideChar; // LPCWSTR optional
DnsDomainName: PWideChar; // LPCWSTR optional
phDS: Pointer // HANDLE* out
): DWORD; stdcall;
external 'NTDSAPI.dll' name 'DsBindW';result := DllCall("NTDSAPI\DsBindW"
, "WStr", DomainControllerName ; LPCWSTR optional
, "WStr", DnsDomainName ; LPCWSTR optional
, "Ptr", phDS ; HANDLE* out
, "UInt") ; return: DWORD●DsBindW(DomainControllerName, DnsDomainName, phDS) = DLL("NTDSAPI.dll", "dword DsBindW(char*, char*, void*)")
# 呼び出し: DsBindW(DomainControllerName, DnsDomainName, phDS)
# DomainControllerName : LPCWSTR optional -> "char*"
# DnsDomainName : LPCWSTR optional -> "char*"
# phDS : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。