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