ホーム › Networking.ActiveDirectory › DsAddSidHistoryA
DsAddSidHistoryA
関数移行元プリンシパルのSIDを移行先のSID履歴に追加する。
シグネチャ
// NTDSAPI.dll (ANSI / -A)
#include <windows.h>
DWORD DsAddSidHistoryA(
HANDLE hDS,
DWORD Flags, // optional
LPCSTR SrcDomain,
LPCSTR SrcPrincipal,
LPCSTR SrcDomainController, // optional
void* SrcDomainCreds, // optional
LPCSTR DstDomain,
LPCSTR DstPrincipal
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hDS | HANDLE | in |
| Flags | DWORD | optional |
| SrcDomain | LPCSTR | in |
| SrcPrincipal | LPCSTR | in |
| SrcDomainController | LPCSTR | inoptional |
| SrcDomainCreds | void* | inoptional |
| DstDomain | LPCSTR | in |
| DstPrincipal | LPCSTR | in |
戻り値の型: DWORD
各言語での呼び出し定義
// NTDSAPI.dll (ANSI / -A)
#include <windows.h>
DWORD DsAddSidHistoryA(
HANDLE hDS,
DWORD Flags, // optional
LPCSTR SrcDomain,
LPCSTR SrcPrincipal,
LPCSTR SrcDomainController, // optional
void* SrcDomainCreds, // optional
LPCSTR DstDomain,
LPCSTR DstPrincipal
);[DllImport("NTDSAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint DsAddSidHistoryA(
IntPtr hDS, // HANDLE
uint Flags, // DWORD optional
[MarshalAs(UnmanagedType.LPStr)] string SrcDomain, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string SrcPrincipal, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string SrcDomainController, // LPCSTR optional
IntPtr SrcDomainCreds, // void* optional
[MarshalAs(UnmanagedType.LPStr)] string DstDomain, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string DstPrincipal // LPCSTR
);<DllImport("NTDSAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function DsAddSidHistoryA(
hDS As IntPtr, ' HANDLE
Flags As UInteger, ' DWORD optional
<MarshalAs(UnmanagedType.LPStr)> SrcDomain As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> SrcPrincipal As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> SrcDomainController As String, ' LPCSTR optional
SrcDomainCreds As IntPtr, ' void* optional
<MarshalAs(UnmanagedType.LPStr)> DstDomain As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> DstPrincipal As String ' LPCSTR
) As UInteger
End Function' hDS : HANDLE
' Flags : DWORD optional
' SrcDomain : LPCSTR
' SrcPrincipal : LPCSTR
' SrcDomainController : LPCSTR optional
' SrcDomainCreds : void* optional
' DstDomain : LPCSTR
' DstPrincipal : LPCSTR
Declare PtrSafe Function DsAddSidHistoryA Lib "ntdsapi" ( _
ByVal hDS As LongPtr, _
ByVal Flags As Long, _
ByVal SrcDomain As String, _
ByVal SrcPrincipal As String, _
ByVal SrcDomainController As String, _
ByVal SrcDomainCreds As LongPtr, _
ByVal DstDomain As String, _
ByVal DstPrincipal As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DsAddSidHistoryA = ctypes.windll.ntdsapi.DsAddSidHistoryA
DsAddSidHistoryA.restype = wintypes.DWORD
DsAddSidHistoryA.argtypes = [
wintypes.HANDLE, # hDS : HANDLE
wintypes.DWORD, # Flags : DWORD optional
wintypes.LPCSTR, # SrcDomain : LPCSTR
wintypes.LPCSTR, # SrcPrincipal : LPCSTR
wintypes.LPCSTR, # SrcDomainController : LPCSTR optional
ctypes.POINTER(None), # SrcDomainCreds : void* optional
wintypes.LPCSTR, # DstDomain : LPCSTR
wintypes.LPCSTR, # DstPrincipal : LPCSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NTDSAPI.dll')
DsAddSidHistoryA = Fiddle::Function.new(
lib['DsAddSidHistoryA'],
[
Fiddle::TYPE_VOIDP, # hDS : HANDLE
-Fiddle::TYPE_INT, # Flags : DWORD optional
Fiddle::TYPE_VOIDP, # SrcDomain : LPCSTR
Fiddle::TYPE_VOIDP, # SrcPrincipal : LPCSTR
Fiddle::TYPE_VOIDP, # SrcDomainController : LPCSTR optional
Fiddle::TYPE_VOIDP, # SrcDomainCreds : void* optional
Fiddle::TYPE_VOIDP, # DstDomain : LPCSTR
Fiddle::TYPE_VOIDP, # DstPrincipal : LPCSTR
],
-Fiddle::TYPE_INT)#[link(name = "ntdsapi")]
extern "system" {
fn DsAddSidHistoryA(
hDS: *mut core::ffi::c_void, // HANDLE
Flags: u32, // DWORD optional
SrcDomain: *const u8, // LPCSTR
SrcPrincipal: *const u8, // LPCSTR
SrcDomainController: *const u8, // LPCSTR optional
SrcDomainCreds: *mut (), // void* optional
DstDomain: *const u8, // LPCSTR
DstPrincipal: *const u8 // LPCSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NTDSAPI.dll", CharSet = CharSet.Ansi)]
public static extern uint DsAddSidHistoryA(IntPtr hDS, uint Flags, [MarshalAs(UnmanagedType.LPStr)] string SrcDomain, [MarshalAs(UnmanagedType.LPStr)] string SrcPrincipal, [MarshalAs(UnmanagedType.LPStr)] string SrcDomainController, IntPtr SrcDomainCreds, [MarshalAs(UnmanagedType.LPStr)] string DstDomain, [MarshalAs(UnmanagedType.LPStr)] string DstPrincipal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTDSAPI_DsAddSidHistoryA' -Namespace Win32 -PassThru
# $api::DsAddSidHistoryA(hDS, Flags, SrcDomain, SrcPrincipal, SrcDomainController, SrcDomainCreds, DstDomain, DstPrincipal)#uselib "NTDSAPI.dll"
#func global DsAddSidHistoryA "DsAddSidHistoryA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DsAddSidHistoryA hDS, Flags, SrcDomain, SrcPrincipal, SrcDomainController, SrcDomainCreds, DstDomain, DstPrincipal ; 戻り値は stat
; hDS : HANDLE -> "sptr"
; Flags : DWORD optional -> "sptr"
; SrcDomain : LPCSTR -> "sptr"
; SrcPrincipal : LPCSTR -> "sptr"
; SrcDomainController : LPCSTR optional -> "sptr"
; SrcDomainCreds : void* optional -> "sptr"
; DstDomain : LPCSTR -> "sptr"
; DstPrincipal : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NTDSAPI.dll"
#cfunc global DsAddSidHistoryA "DsAddSidHistoryA" sptr, int, str, str, str, sptr, str, str
; res = DsAddSidHistoryA(hDS, Flags, SrcDomain, SrcPrincipal, SrcDomainController, SrcDomainCreds, DstDomain, DstPrincipal)
; hDS : HANDLE -> "sptr"
; Flags : DWORD optional -> "int"
; SrcDomain : LPCSTR -> "str"
; SrcPrincipal : LPCSTR -> "str"
; SrcDomainController : LPCSTR optional -> "str"
; SrcDomainCreds : void* optional -> "sptr"
; DstDomain : LPCSTR -> "str"
; DstPrincipal : LPCSTR -> "str"; DWORD DsAddSidHistoryA(HANDLE hDS, DWORD Flags, LPCSTR SrcDomain, LPCSTR SrcPrincipal, LPCSTR SrcDomainController, void* SrcDomainCreds, LPCSTR DstDomain, LPCSTR DstPrincipal)
#uselib "NTDSAPI.dll"
#cfunc global DsAddSidHistoryA "DsAddSidHistoryA" intptr, int, str, str, str, intptr, str, str
; res = DsAddSidHistoryA(hDS, Flags, SrcDomain, SrcPrincipal, SrcDomainController, SrcDomainCreds, DstDomain, DstPrincipal)
; hDS : HANDLE -> "intptr"
; Flags : DWORD optional -> "int"
; SrcDomain : LPCSTR -> "str"
; SrcPrincipal : LPCSTR -> "str"
; SrcDomainController : LPCSTR optional -> "str"
; SrcDomainCreds : void* optional -> "intptr"
; DstDomain : LPCSTR -> "str"
; DstPrincipal : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ntdsapi = windows.NewLazySystemDLL("NTDSAPI.dll")
procDsAddSidHistoryA = ntdsapi.NewProc("DsAddSidHistoryA")
)
// hDS (HANDLE), Flags (DWORD optional), SrcDomain (LPCSTR), SrcPrincipal (LPCSTR), SrcDomainController (LPCSTR optional), SrcDomainCreds (void* optional), DstDomain (LPCSTR), DstPrincipal (LPCSTR)
r1, _, err := procDsAddSidHistoryA.Call(
uintptr(hDS),
uintptr(Flags),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SrcDomain))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SrcPrincipal))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SrcDomainController))),
uintptr(SrcDomainCreds),
uintptr(unsafe.Pointer(windows.BytePtrFromString(DstDomain))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(DstPrincipal))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DsAddSidHistoryA(
hDS: THandle; // HANDLE
Flags: DWORD; // DWORD optional
SrcDomain: PAnsiChar; // LPCSTR
SrcPrincipal: PAnsiChar; // LPCSTR
SrcDomainController: PAnsiChar; // LPCSTR optional
SrcDomainCreds: Pointer; // void* optional
DstDomain: PAnsiChar; // LPCSTR
DstPrincipal: PAnsiChar // LPCSTR
): DWORD; stdcall;
external 'NTDSAPI.dll' name 'DsAddSidHistoryA';result := DllCall("NTDSAPI\DsAddSidHistoryA"
, "Ptr", hDS ; HANDLE
, "UInt", Flags ; DWORD optional
, "AStr", SrcDomain ; LPCSTR
, "AStr", SrcPrincipal ; LPCSTR
, "AStr", SrcDomainController ; LPCSTR optional
, "Ptr", SrcDomainCreds ; void* optional
, "AStr", DstDomain ; LPCSTR
, "AStr", DstPrincipal ; LPCSTR
, "UInt") ; return: DWORD●DsAddSidHistoryA(hDS, Flags, SrcDomain, SrcPrincipal, SrcDomainController, SrcDomainCreds, DstDomain, DstPrincipal) = DLL("NTDSAPI.dll", "dword DsAddSidHistoryA(void*, dword, char*, char*, char*, void*, char*, char*)")
# 呼び出し: DsAddSidHistoryA(hDS, Flags, SrcDomain, SrcPrincipal, SrcDomainController, SrcDomainCreds, DstDomain, DstPrincipal)
# hDS : HANDLE -> "void*"
# Flags : DWORD optional -> "dword"
# SrcDomain : LPCSTR -> "char*"
# SrcPrincipal : LPCSTR -> "char*"
# SrcDomainController : LPCSTR optional -> "char*"
# SrcDomainCreds : void* optional -> "void*"
# DstDomain : LPCSTR -> "char*"
# DstPrincipal : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。