ホーム › Security.Authorization › BuildTrusteeWithSidA
BuildTrusteeWithSidA
関数SIDを指定してTRUSTEE構造体を初期化する。
シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
void BuildTrusteeWithSidA(
TRUSTEE_A* pTrustee,
PSID pSid // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pTrustee | TRUSTEE_A* | inout | 初期化する TRUSTEE 構造体へのポインターです。BuildTrusteeWithSid 関数はメモリを割り当てません。このパラメーターが NULL または無効なポインターの場合、結果は未定義です。 | ||||||||||
| pSid | PSID | inoptional | trustee を識別する SID 構造体へのポインターです。BuildTrusteeWithSid 関数は、このポインターを TRUSTEE 構造体の ptstrName メンバーに割り当てます。この関数は TRUSTEE 構造体の他のメンバーを次のように設定します。
|
戻り値の型: void
公式ドキュメント
TRUSTEE 構造体を初期化します。呼び出し側は trustee のセキュリティ識別子 (SID) を指定します。この関数は構造体の他のメンバーを既定値に設定し、SID に関連付けられた名前の検索は行いません。(ANSI)
解説(Remarks)
メモ
aclapi.h ヘッダーは BuildTrusteeWithSid を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコード中立のエイリアスの使用を、エンコード中立でないコードと混在させると、不一致が生じてコンパイルエラーや実行時エラーの原因となる場合があります。詳細については、関数プロトタイプの規約 を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
void BuildTrusteeWithSidA(
TRUSTEE_A* pTrustee,
PSID pSid // optional
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern void BuildTrusteeWithSidA(
IntPtr pTrustee, // TRUSTEE_A* in/out
IntPtr pSid // PSID optional
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Sub BuildTrusteeWithSidA(
pTrustee As IntPtr, ' TRUSTEE_A* in/out
pSid As IntPtr ' PSID optional
)
End Sub' pTrustee : TRUSTEE_A* in/out
' pSid : PSID optional
Declare PtrSafe Sub BuildTrusteeWithSidA Lib "advapi32" ( _
ByVal pTrustee As LongPtr, _
ByVal pSid As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BuildTrusteeWithSidA = ctypes.windll.advapi32.BuildTrusteeWithSidA
BuildTrusteeWithSidA.restype = None
BuildTrusteeWithSidA.argtypes = [
ctypes.c_void_p, # pTrustee : TRUSTEE_A* in/out
wintypes.HANDLE, # pSid : PSID optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
BuildTrusteeWithSidA = Fiddle::Function.new(
lib['BuildTrusteeWithSidA'],
[
Fiddle::TYPE_VOIDP, # pTrustee : TRUSTEE_A* in/out
Fiddle::TYPE_VOIDP, # pSid : PSID optional
],
Fiddle::TYPE_VOID)#[link(name = "advapi32")]
extern "system" {
fn BuildTrusteeWithSidA(
pTrustee: *mut TRUSTEE_A, // TRUSTEE_A* in/out
pSid: *mut core::ffi::c_void // PSID optional
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi)]
public static extern void BuildTrusteeWithSidA(IntPtr pTrustee, IntPtr pSid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_BuildTrusteeWithSidA' -Namespace Win32 -PassThru
# $api::BuildTrusteeWithSidA(pTrustee, pSid)#uselib "ADVAPI32.dll"
#func global BuildTrusteeWithSidA "BuildTrusteeWithSidA" sptr, sptr
; BuildTrusteeWithSidA varptr(pTrustee), pSid
; pTrustee : TRUSTEE_A* in/out -> "sptr"
; pSid : PSID optional -> "sptr"出力引数:
#uselib "ADVAPI32.dll" #func global BuildTrusteeWithSidA "BuildTrusteeWithSidA" var, sptr ; BuildTrusteeWithSidA pTrustee, pSid ; pTrustee : TRUSTEE_A* in/out -> "var" ; pSid : PSID optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #func global BuildTrusteeWithSidA "BuildTrusteeWithSidA" sptr, sptr ; BuildTrusteeWithSidA varptr(pTrustee), pSid ; pTrustee : TRUSTEE_A* in/out -> "sptr" ; pSid : PSID optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void BuildTrusteeWithSidA(TRUSTEE_A* pTrustee, PSID pSid) #uselib "ADVAPI32.dll" #func global BuildTrusteeWithSidA "BuildTrusteeWithSidA" var, intptr ; BuildTrusteeWithSidA pTrustee, pSid ; pTrustee : TRUSTEE_A* in/out -> "var" ; pSid : PSID optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void BuildTrusteeWithSidA(TRUSTEE_A* pTrustee, PSID pSid) #uselib "ADVAPI32.dll" #func global BuildTrusteeWithSidA "BuildTrusteeWithSidA" intptr, intptr ; BuildTrusteeWithSidA varptr(pTrustee), pSid ; pTrustee : TRUSTEE_A* in/out -> "intptr" ; pSid : PSID optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procBuildTrusteeWithSidA = advapi32.NewProc("BuildTrusteeWithSidA")
)
// pTrustee (TRUSTEE_A* in/out), pSid (PSID optional)
r1, _, err := procBuildTrusteeWithSidA.Call(
uintptr(pTrustee),
uintptr(pSid),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure BuildTrusteeWithSidA(
pTrustee: Pointer; // TRUSTEE_A* in/out
pSid: THandle // PSID optional
); stdcall;
external 'ADVAPI32.dll' name 'BuildTrusteeWithSidA';result := DllCall("ADVAPI32\BuildTrusteeWithSidA"
, "Ptr", pTrustee ; TRUSTEE_A* in/out
, "Ptr", pSid ; PSID optional
, "Int") ; return: void●BuildTrusteeWithSidA(pTrustee, pSid) = DLL("ADVAPI32.dll", "int BuildTrusteeWithSidA(void*, void*)")
# 呼び出し: BuildTrusteeWithSidA(pTrustee, pSid)
# pTrustee : TRUSTEE_A* in/out -> "void*"
# pSid : PSID optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advapi32" fn BuildTrusteeWithSidA(
pTrustee: [*c]TRUSTEE_A, // TRUSTEE_A* in/out
pSid: ?*anyopaque // PSID optional
) callconv(std.os.windows.WINAPI) void;proc BuildTrusteeWithSidA(
pTrustee: ptr TRUSTEE_A, # TRUSTEE_A* in/out
pSid: pointer # PSID optional
) {.importc: "BuildTrusteeWithSidA", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
void BuildTrusteeWithSidA(
TRUSTEE_A* pTrustee, // TRUSTEE_A* in/out
void* pSid // PSID optional
);ccall((:BuildTrusteeWithSidA, "ADVAPI32.dll"), stdcall, Cvoid,
(Ptr{TRUSTEE_A}, Ptr{Cvoid}),
pTrustee, pSid)
# pTrustee : TRUSTEE_A* in/out -> Ptr{TRUSTEE_A}
# pSid : PSID optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void BuildTrusteeWithSidA(
void* pTrustee,
void* pSid);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.BuildTrusteeWithSidA(pTrustee, pSid)
-- pTrustee : TRUSTEE_A* in/out
-- pSid : PSID optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const BuildTrusteeWithSidA = lib.func('__stdcall', 'BuildTrusteeWithSidA', 'void', ['void *', 'void *']);
// BuildTrusteeWithSidA(pTrustee, pSid)
// pTrustee : TRUSTEE_A* in/out -> 'void *'
// pSid : PSID optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
BuildTrusteeWithSidA: { parameters: ["pointer", "pointer"], result: "void" },
});
// lib.symbols.BuildTrusteeWithSidA(pTrustee, pSid)
// pTrustee : TRUSTEE_A* in/out -> "pointer"
// pSid : PSID optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void BuildTrusteeWithSidA(
void* pTrustee,
void* pSid);
C, "ADVAPI32.dll");
// $ffi->BuildTrusteeWithSidA(pTrustee, pSid);
// pTrustee : TRUSTEE_A* in/out
// pSid : PSID optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = Native.load("advapi32", Advapi32.class, W32APIOptions.ASCII_OPTIONS);
void BuildTrusteeWithSidA(
Pointer pTrustee, // TRUSTEE_A* in/out
Pointer pSid // PSID optional
);
}@[Link("advapi32")]
lib LibADVAPI32
fun BuildTrusteeWithSidA = BuildTrusteeWithSidA(
pTrustee : TRUSTEE_A*, # TRUSTEE_A* in/out
pSid : Void* # PSID optional
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BuildTrusteeWithSidANative = Void Function(Pointer<Void>, Pointer<Void>);
typedef BuildTrusteeWithSidADart = void Function(Pointer<Void>, Pointer<Void>);
final BuildTrusteeWithSidA = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<BuildTrusteeWithSidANative, BuildTrusteeWithSidADart>('BuildTrusteeWithSidA');
// pTrustee : TRUSTEE_A* in/out -> Pointer<Void>
// pSid : PSID optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure BuildTrusteeWithSidA(
pTrustee: Pointer; // TRUSTEE_A* in/out
pSid: THandle // PSID optional
); stdcall;
external 'ADVAPI32.dll' name 'BuildTrusteeWithSidA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BuildTrusteeWithSidA"
c_BuildTrusteeWithSidA :: Ptr () -> Ptr () -> IO ()
-- pTrustee : TRUSTEE_A* in/out -> Ptr ()
-- pSid : PSID optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let buildtrusteewithsida =
foreign "BuildTrusteeWithSidA"
((ptr void) @-> (ptr void) @-> returning void)
(* pTrustee : TRUSTEE_A* in/out -> (ptr void) *)
(* pSid : PSID optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("BuildTrusteeWithSidA" build-trustee-with-sid-a :convention :stdcall) :void
(p-trustee :pointer) ; TRUSTEE_A* in/out
(p-sid :pointer)) ; PSID optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BuildTrusteeWithSidA = Win32::API::More->new('ADVAPI32',
'void BuildTrusteeWithSidA(LPVOID pTrustee, HANDLE pSid)');
# my $ret = $BuildTrusteeWithSidA->Call($pTrustee, $pSid);
# pTrustee : TRUSTEE_A* in/out -> LPVOID
# pSid : PSID optional -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f BuildTrusteeWithSidW (Unicode版) — SIDを指定してTRUSTEE構造体を初期化する。
公式の関連項目
- f BuildTrusteeWithNameA — アカウント名を指定してTRUSTEE構造体を初期化する。
- f BuildTrusteeWithObjectsAndNameA — オブジェクトと名前を指定してTRUSTEE構造体を初期化する。
- f BuildTrusteeWithObjectsAndSidA — オブジェクトとSIDを指定してTRUSTEE構造体を初期化する。
使用する型