ホーム › Storage.DistributedFileSystem › NetDfsGetSecurity
NetDfsGetSecurity
関数指定DFSエントリのセキュリティ記述子を取得する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetDfsGetSecurity(
LPWSTR DfsEntryPath,
DWORD SecurityInformation,
PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
DWORD* lpcbSecurityDescriptor
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| DfsEntryPath | LPWSTR | in |
| SecurityInformation | DWORD | in |
| ppSecurityDescriptor | PSECURITY_DESCRIPTOR* | out |
| lpcbSecurityDescriptor | DWORD* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD NetDfsGetSecurity(
LPWSTR DfsEntryPath,
DWORD SecurityInformation,
PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
DWORD* lpcbSecurityDescriptor
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetDfsGetSecurity(
[MarshalAs(UnmanagedType.LPWStr)] string DfsEntryPath, // LPWSTR
uint SecurityInformation, // DWORD
IntPtr ppSecurityDescriptor, // PSECURITY_DESCRIPTOR* out
out uint lpcbSecurityDescriptor // DWORD* out
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetDfsGetSecurity(
<MarshalAs(UnmanagedType.LPWStr)> DfsEntryPath As String, ' LPWSTR
SecurityInformation As UInteger, ' DWORD
ppSecurityDescriptor As IntPtr, ' PSECURITY_DESCRIPTOR* out
<Out> ByRef lpcbSecurityDescriptor As UInteger ' DWORD* out
) As UInteger
End Function' DfsEntryPath : LPWSTR
' SecurityInformation : DWORD
' ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out
' lpcbSecurityDescriptor : DWORD* out
Declare PtrSafe Function NetDfsGetSecurity Lib "netapi32" ( _
ByVal DfsEntryPath As LongPtr, _
ByVal SecurityInformation As Long, _
ByVal ppSecurityDescriptor As LongPtr, _
ByRef lpcbSecurityDescriptor As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetDfsGetSecurity = ctypes.windll.netapi32.NetDfsGetSecurity
NetDfsGetSecurity.restype = wintypes.DWORD
NetDfsGetSecurity.argtypes = [
wintypes.LPCWSTR, # DfsEntryPath : LPWSTR
wintypes.DWORD, # SecurityInformation : DWORD
ctypes.c_void_p, # ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out
ctypes.POINTER(wintypes.DWORD), # lpcbSecurityDescriptor : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetDfsGetSecurity = Fiddle::Function.new(
lib['NetDfsGetSecurity'],
[
Fiddle::TYPE_VOIDP, # DfsEntryPath : LPWSTR
-Fiddle::TYPE_INT, # SecurityInformation : DWORD
Fiddle::TYPE_VOIDP, # ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out
Fiddle::TYPE_VOIDP, # lpcbSecurityDescriptor : DWORD* out
],
-Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetDfsGetSecurity(
DfsEntryPath: *mut u16, // LPWSTR
SecurityInformation: u32, // DWORD
ppSecurityDescriptor: *mut *mut core::ffi::c_void, // PSECURITY_DESCRIPTOR* out
lpcbSecurityDescriptor: *mut u32 // DWORD* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetDfsGetSecurity([MarshalAs(UnmanagedType.LPWStr)] string DfsEntryPath, uint SecurityInformation, IntPtr ppSecurityDescriptor, out uint lpcbSecurityDescriptor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetDfsGetSecurity' -Namespace Win32 -PassThru
# $api::NetDfsGetSecurity(DfsEntryPath, SecurityInformation, ppSecurityDescriptor, lpcbSecurityDescriptor)#uselib "NETAPI32.dll"
#func global NetDfsGetSecurity "NetDfsGetSecurity" sptr, sptr, sptr, sptr
; NetDfsGetSecurity DfsEntryPath, SecurityInformation, ppSecurityDescriptor, varptr(lpcbSecurityDescriptor) ; 戻り値は stat
; DfsEntryPath : LPWSTR -> "sptr"
; SecurityInformation : DWORD -> "sptr"
; ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out -> "sptr"
; lpcbSecurityDescriptor : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "NETAPI32.dll" #cfunc global NetDfsGetSecurity "NetDfsGetSecurity" wstr, int, sptr, var ; res = NetDfsGetSecurity(DfsEntryPath, SecurityInformation, ppSecurityDescriptor, lpcbSecurityDescriptor) ; DfsEntryPath : LPWSTR -> "wstr" ; SecurityInformation : DWORD -> "int" ; ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out -> "sptr" ; lpcbSecurityDescriptor : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "NETAPI32.dll" #cfunc global NetDfsGetSecurity "NetDfsGetSecurity" wstr, int, sptr, sptr ; res = NetDfsGetSecurity(DfsEntryPath, SecurityInformation, ppSecurityDescriptor, varptr(lpcbSecurityDescriptor)) ; DfsEntryPath : LPWSTR -> "wstr" ; SecurityInformation : DWORD -> "int" ; ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out -> "sptr" ; lpcbSecurityDescriptor : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD NetDfsGetSecurity(LPWSTR DfsEntryPath, DWORD SecurityInformation, PSECURITY_DESCRIPTOR* ppSecurityDescriptor, DWORD* lpcbSecurityDescriptor) #uselib "NETAPI32.dll" #cfunc global NetDfsGetSecurity "NetDfsGetSecurity" wstr, int, intptr, var ; res = NetDfsGetSecurity(DfsEntryPath, SecurityInformation, ppSecurityDescriptor, lpcbSecurityDescriptor) ; DfsEntryPath : LPWSTR -> "wstr" ; SecurityInformation : DWORD -> "int" ; ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out -> "intptr" ; lpcbSecurityDescriptor : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD NetDfsGetSecurity(LPWSTR DfsEntryPath, DWORD SecurityInformation, PSECURITY_DESCRIPTOR* ppSecurityDescriptor, DWORD* lpcbSecurityDescriptor) #uselib "NETAPI32.dll" #cfunc global NetDfsGetSecurity "NetDfsGetSecurity" wstr, int, intptr, intptr ; res = NetDfsGetSecurity(DfsEntryPath, SecurityInformation, ppSecurityDescriptor, varptr(lpcbSecurityDescriptor)) ; DfsEntryPath : LPWSTR -> "wstr" ; SecurityInformation : DWORD -> "int" ; ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out -> "intptr" ; lpcbSecurityDescriptor : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetDfsGetSecurity = netapi32.NewProc("NetDfsGetSecurity")
)
// DfsEntryPath (LPWSTR), SecurityInformation (DWORD), ppSecurityDescriptor (PSECURITY_DESCRIPTOR* out), lpcbSecurityDescriptor (DWORD* out)
r1, _, err := procNetDfsGetSecurity.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DfsEntryPath))),
uintptr(SecurityInformation),
uintptr(ppSecurityDescriptor),
uintptr(lpcbSecurityDescriptor),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction NetDfsGetSecurity(
DfsEntryPath: PWideChar; // LPWSTR
SecurityInformation: DWORD; // DWORD
ppSecurityDescriptor: Pointer; // PSECURITY_DESCRIPTOR* out
lpcbSecurityDescriptor: Pointer // DWORD* out
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetDfsGetSecurity';result := DllCall("NETAPI32\NetDfsGetSecurity"
, "WStr", DfsEntryPath ; LPWSTR
, "UInt", SecurityInformation ; DWORD
, "Ptr", ppSecurityDescriptor ; PSECURITY_DESCRIPTOR* out
, "Ptr", lpcbSecurityDescriptor ; DWORD* out
, "UInt") ; return: DWORD●NetDfsGetSecurity(DfsEntryPath, SecurityInformation, ppSecurityDescriptor, lpcbSecurityDescriptor) = DLL("NETAPI32.dll", "dword NetDfsGetSecurity(char*, dword, void*, void*)")
# 呼び出し: NetDfsGetSecurity(DfsEntryPath, SecurityInformation, ppSecurityDescriptor, lpcbSecurityDescriptor)
# DfsEntryPath : LPWSTR -> "char*"
# SecurityInformation : DWORD -> "dword"
# ppSecurityDescriptor : PSECURITY_DESCRIPTOR* out -> "void*"
# lpcbSecurityDescriptor : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。