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

SecurityDescriptorToBinarySD

関数
セキュリティ記述子オブジェクトをバイナリ形式へ変換する。
DLLACTIVEDS.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// ACTIVEDS.dll
#include <windows.h>

HRESULT SecurityDescriptorToBinarySD(
    VARIANT vVarSecDes,
    PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
    DWORD* pdwSDLength,
    LPCWSTR pszServerName,
    LPCWSTR userName,
    LPCWSTR passWord,
    DWORD dwFlags
);

パラメーター

名前方向
vVarSecDesVARIANTin
ppSecurityDescriptorPSECURITY_DESCRIPTOR*inout
pdwSDLengthDWORD*inout
pszServerNameLPCWSTRin
userNameLPCWSTRin
passWordLPCWSTRin
dwFlagsDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

// ACTIVEDS.dll
#include <windows.h>

HRESULT SecurityDescriptorToBinarySD(
    VARIANT vVarSecDes,
    PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
    DWORD* pdwSDLength,
    LPCWSTR pszServerName,
    LPCWSTR userName,
    LPCWSTR passWord,
    DWORD dwFlags
);
[DllImport("ACTIVEDS.dll", ExactSpelling = true)]
static extern int SecurityDescriptorToBinarySD(
    VARIANT vVarSecDes,   // VARIANT
    IntPtr ppSecurityDescriptor,   // PSECURITY_DESCRIPTOR* in/out
    ref uint pdwSDLength,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] string pszServerName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string userName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string passWord,   // LPCWSTR
    uint dwFlags   // DWORD
);
<DllImport("ACTIVEDS.dll", ExactSpelling:=True)>
Public Shared Function SecurityDescriptorToBinarySD(
    vVarSecDes As VARIANT,   ' VARIANT
    ppSecurityDescriptor As IntPtr,   ' PSECURITY_DESCRIPTOR* in/out
    ByRef pdwSDLength As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> pszServerName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> userName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> passWord As String,   ' LPCWSTR
    dwFlags As UInteger   ' DWORD
) As Integer
End Function
' vVarSecDes : VARIANT
' ppSecurityDescriptor : PSECURITY_DESCRIPTOR* in/out
' pdwSDLength : DWORD* in/out
' pszServerName : LPCWSTR
' userName : LPCWSTR
' passWord : LPCWSTR
' dwFlags : DWORD
Declare PtrSafe Function SecurityDescriptorToBinarySD Lib "activeds" ( _
    ByVal vVarSecDes As LongPtr, _
    ByVal ppSecurityDescriptor As LongPtr, _
    ByRef pdwSDLength As Long, _
    ByVal pszServerName As LongPtr, _
    ByVal userName As LongPtr, _
    ByVal passWord As LongPtr, _
    ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SecurityDescriptorToBinarySD = ctypes.windll.activeds.SecurityDescriptorToBinarySD
SecurityDescriptorToBinarySD.restype = ctypes.c_int
SecurityDescriptorToBinarySD.argtypes = [
    VARIANT,  # vVarSecDes : VARIANT
    ctypes.c_void_p,  # ppSecurityDescriptor : PSECURITY_DESCRIPTOR* in/out
    ctypes.POINTER(wintypes.DWORD),  # pdwSDLength : DWORD* in/out
    wintypes.LPCWSTR,  # pszServerName : LPCWSTR
    wintypes.LPCWSTR,  # userName : LPCWSTR
    wintypes.LPCWSTR,  # passWord : LPCWSTR
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ACTIVEDS.dll')
SecurityDescriptorToBinarySD = Fiddle::Function.new(
  lib['SecurityDescriptorToBinarySD'],
  [
    Fiddle::TYPE_VOIDP,  # vVarSecDes : VARIANT
    Fiddle::TYPE_VOIDP,  # ppSecurityDescriptor : PSECURITY_DESCRIPTOR* in/out
    Fiddle::TYPE_VOIDP,  # pdwSDLength : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # pszServerName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # userName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # passWord : LPCWSTR
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "activeds")]
extern "system" {
    fn SecurityDescriptorToBinarySD(
        vVarSecDes: VARIANT,  // VARIANT
        ppSecurityDescriptor: *mut *mut core::ffi::c_void,  // PSECURITY_DESCRIPTOR* in/out
        pdwSDLength: *mut u32,  // DWORD* in/out
        pszServerName: *const u16,  // LPCWSTR
        userName: *const u16,  // LPCWSTR
        passWord: *const u16,  // LPCWSTR
        dwFlags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ACTIVEDS.dll")]
public static extern int SecurityDescriptorToBinarySD(VARIANT vVarSecDes, IntPtr ppSecurityDescriptor, ref uint pdwSDLength, [MarshalAs(UnmanagedType.LPWStr)] string pszServerName, [MarshalAs(UnmanagedType.LPWStr)] string userName, [MarshalAs(UnmanagedType.LPWStr)] string passWord, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ACTIVEDS_SecurityDescriptorToBinarySD' -Namespace Win32 -PassThru
# $api::SecurityDescriptorToBinarySD(vVarSecDes, ppSecurityDescriptor, pdwSDLength, pszServerName, userName, passWord, dwFlags)
#uselib "ACTIVEDS.dll"
#func global SecurityDescriptorToBinarySD "SecurityDescriptorToBinarySD" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SecurityDescriptorToBinarySD vVarSecDes, ppSecurityDescriptor, varptr(pdwSDLength), pszServerName, userName, passWord, dwFlags   ; 戻り値は stat
; vVarSecDes : VARIANT -> "sptr"
; ppSecurityDescriptor : PSECURITY_DESCRIPTOR* in/out -> "sptr"
; pdwSDLength : DWORD* in/out -> "sptr"
; pszServerName : LPCWSTR -> "sptr"
; userName : LPCWSTR -> "sptr"
; passWord : LPCWSTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ACTIVEDS.dll"
#cfunc global SecurityDescriptorToBinarySD "SecurityDescriptorToBinarySD" int, sptr, var, wstr, wstr, wstr, int
; res = SecurityDescriptorToBinarySD(vVarSecDes, ppSecurityDescriptor, pdwSDLength, pszServerName, userName, passWord, dwFlags)
; vVarSecDes : VARIANT -> "int"
; ppSecurityDescriptor : PSECURITY_DESCRIPTOR* in/out -> "sptr"
; pdwSDLength : DWORD* in/out -> "var"
; pszServerName : LPCWSTR -> "wstr"
; userName : LPCWSTR -> "wstr"
; passWord : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT SecurityDescriptorToBinarySD(VARIANT vVarSecDes, PSECURITY_DESCRIPTOR* ppSecurityDescriptor, DWORD* pdwSDLength, LPCWSTR pszServerName, LPCWSTR userName, LPCWSTR passWord, DWORD dwFlags)
#uselib "ACTIVEDS.dll"
#cfunc global SecurityDescriptorToBinarySD "SecurityDescriptorToBinarySD" int, intptr, var, wstr, wstr, wstr, int
; res = SecurityDescriptorToBinarySD(vVarSecDes, ppSecurityDescriptor, pdwSDLength, pszServerName, userName, passWord, dwFlags)
; vVarSecDes : VARIANT -> "int"
; ppSecurityDescriptor : PSECURITY_DESCRIPTOR* in/out -> "intptr"
; pdwSDLength : DWORD* in/out -> "var"
; pszServerName : LPCWSTR -> "wstr"
; userName : LPCWSTR -> "wstr"
; passWord : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	activeds = windows.NewLazySystemDLL("ACTIVEDS.dll")
	procSecurityDescriptorToBinarySD = activeds.NewProc("SecurityDescriptorToBinarySD")
)

// vVarSecDes (VARIANT), ppSecurityDescriptor (PSECURITY_DESCRIPTOR* in/out), pdwSDLength (DWORD* in/out), pszServerName (LPCWSTR), userName (LPCWSTR), passWord (LPCWSTR), dwFlags (DWORD)
r1, _, err := procSecurityDescriptorToBinarySD.Call(
	uintptr(vVarSecDes),
	uintptr(ppSecurityDescriptor),
	uintptr(pdwSDLength),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszServerName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(userName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(passWord))),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SecurityDescriptorToBinarySD(
  vVarSecDes: VARIANT;   // VARIANT
  ppSecurityDescriptor: Pointer;   // PSECURITY_DESCRIPTOR* in/out
  pdwSDLength: Pointer;   // DWORD* in/out
  pszServerName: PWideChar;   // LPCWSTR
  userName: PWideChar;   // LPCWSTR
  passWord: PWideChar;   // LPCWSTR
  dwFlags: DWORD   // DWORD
): Integer; stdcall;
  external 'ACTIVEDS.dll' name 'SecurityDescriptorToBinarySD';
result := DllCall("ACTIVEDS\SecurityDescriptorToBinarySD"
    , "Ptr", vVarSecDes   ; VARIANT
    , "Ptr", ppSecurityDescriptor   ; PSECURITY_DESCRIPTOR* in/out
    , "Ptr", pdwSDLength   ; DWORD* in/out
    , "WStr", pszServerName   ; LPCWSTR
    , "WStr", userName   ; LPCWSTR
    , "WStr", passWord   ; LPCWSTR
    , "UInt", dwFlags   ; DWORD
    , "Int")   ; return: HRESULT
●SecurityDescriptorToBinarySD(vVarSecDes, ppSecurityDescriptor, pdwSDLength, pszServerName, userName, passWord, dwFlags) = DLL("ACTIVEDS.dll", "int SecurityDescriptorToBinarySD(void*, void*, void*, char*, char*, char*, dword)")
# 呼び出し: SecurityDescriptorToBinarySD(vVarSecDes, ppSecurityDescriptor, pdwSDLength, pszServerName, userName, passWord, dwFlags)
# vVarSecDes : VARIANT -> "void*"
# ppSecurityDescriptor : PSECURITY_DESCRIPTOR* in/out -> "void*"
# pdwSDLength : DWORD* in/out -> "void*"
# pszServerName : LPCWSTR -> "char*"
# userName : LPCWSTR -> "char*"
# passWord : LPCWSTR -> "char*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。