ホーム › Security.Authentication.Identity › LsaSetTrustedDomainInformation
LsaSetTrustedDomainInformation
関数SIDで指定した信頼ドメインの情報を設定する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
NTSTATUS LsaSetTrustedDomainInformation(
LSA_HANDLE PolicyHandle,
PSID TrustedDomainSid,
TRUSTED_INFORMATION_CLASS InformationClass,
void* Buffer
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| PolicyHandle | LSA_HANDLE | in | LsaOpenPolicyで取得したLSAポリシーハンドル。信頼ドメイン設定権が必要となる。 |
| TrustedDomainSid | PSID | in | 情報を設定する対象の信頼ドメインのSID。有効なPSIDを指定する。 |
| InformationClass | TRUSTED_INFORMATION_CLASS | in | 設定する信頼ドメイン情報の種類を示すTRUSTED_INFORMATION_CLASS列挙値。 |
| Buffer | void* | in | 設定する情報クラスに対応する構造体を保持するバッファへのポインタ。 |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
NTSTATUS LsaSetTrustedDomainInformation(
LSA_HANDLE PolicyHandle,
PSID TrustedDomainSid,
TRUSTED_INFORMATION_CLASS InformationClass,
void* Buffer
);[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern int LsaSetTrustedDomainInformation(
IntPtr PolicyHandle, // LSA_HANDLE
IntPtr TrustedDomainSid, // PSID
int InformationClass, // TRUSTED_INFORMATION_CLASS
IntPtr Buffer // void*
);<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function LsaSetTrustedDomainInformation(
PolicyHandle As IntPtr, ' LSA_HANDLE
TrustedDomainSid As IntPtr, ' PSID
InformationClass As Integer, ' TRUSTED_INFORMATION_CLASS
Buffer As IntPtr ' void*
) As Integer
End Function' PolicyHandle : LSA_HANDLE
' TrustedDomainSid : PSID
' InformationClass : TRUSTED_INFORMATION_CLASS
' Buffer : void*
Declare PtrSafe Function LsaSetTrustedDomainInformation Lib "advapi32" ( _
ByVal PolicyHandle As LongPtr, _
ByVal TrustedDomainSid As LongPtr, _
ByVal InformationClass As Long, _
ByVal Buffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LsaSetTrustedDomainInformation = ctypes.windll.advapi32.LsaSetTrustedDomainInformation
LsaSetTrustedDomainInformation.restype = ctypes.c_int
LsaSetTrustedDomainInformation.argtypes = [
ctypes.c_ssize_t, # PolicyHandle : LSA_HANDLE
wintypes.HANDLE, # TrustedDomainSid : PSID
ctypes.c_int, # InformationClass : TRUSTED_INFORMATION_CLASS
ctypes.POINTER(None), # Buffer : void*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
LsaSetTrustedDomainInformation = Fiddle::Function.new(
lib['LsaSetTrustedDomainInformation'],
[
Fiddle::TYPE_INTPTR_T, # PolicyHandle : LSA_HANDLE
Fiddle::TYPE_VOIDP, # TrustedDomainSid : PSID
Fiddle::TYPE_INT, # InformationClass : TRUSTED_INFORMATION_CLASS
Fiddle::TYPE_VOIDP, # Buffer : void*
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn LsaSetTrustedDomainInformation(
PolicyHandle: isize, // LSA_HANDLE
TrustedDomainSid: *mut core::ffi::c_void, // PSID
InformationClass: i32, // TRUSTED_INFORMATION_CLASS
Buffer: *mut () // void*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern int LsaSetTrustedDomainInformation(IntPtr PolicyHandle, IntPtr TrustedDomainSid, int InformationClass, IntPtr Buffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_LsaSetTrustedDomainInformation' -Namespace Win32 -PassThru
# $api::LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer)#uselib "ADVAPI32.dll"
#func global LsaSetTrustedDomainInformation "LsaSetTrustedDomainInformation" sptr, sptr, sptr, sptr
; LsaSetTrustedDomainInformation PolicyHandle, TrustedDomainSid, InformationClass, Buffer ; 戻り値は stat
; PolicyHandle : LSA_HANDLE -> "sptr"
; TrustedDomainSid : PSID -> "sptr"
; InformationClass : TRUSTED_INFORMATION_CLASS -> "sptr"
; Buffer : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global LsaSetTrustedDomainInformation "LsaSetTrustedDomainInformation" sptr, sptr, int, sptr
; res = LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer)
; PolicyHandle : LSA_HANDLE -> "sptr"
; TrustedDomainSid : PSID -> "sptr"
; InformationClass : TRUSTED_INFORMATION_CLASS -> "int"
; Buffer : void* -> "sptr"; NTSTATUS LsaSetTrustedDomainInformation(LSA_HANDLE PolicyHandle, PSID TrustedDomainSid, TRUSTED_INFORMATION_CLASS InformationClass, void* Buffer)
#uselib "ADVAPI32.dll"
#cfunc global LsaSetTrustedDomainInformation "LsaSetTrustedDomainInformation" intptr, intptr, int, intptr
; res = LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer)
; PolicyHandle : LSA_HANDLE -> "intptr"
; TrustedDomainSid : PSID -> "intptr"
; InformationClass : TRUSTED_INFORMATION_CLASS -> "int"
; Buffer : void* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procLsaSetTrustedDomainInformation = advapi32.NewProc("LsaSetTrustedDomainInformation")
)
// PolicyHandle (LSA_HANDLE), TrustedDomainSid (PSID), InformationClass (TRUSTED_INFORMATION_CLASS), Buffer (void*)
r1, _, err := procLsaSetTrustedDomainInformation.Call(
uintptr(PolicyHandle),
uintptr(TrustedDomainSid),
uintptr(InformationClass),
uintptr(Buffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction LsaSetTrustedDomainInformation(
PolicyHandle: NativeInt; // LSA_HANDLE
TrustedDomainSid: THandle; // PSID
InformationClass: Integer; // TRUSTED_INFORMATION_CLASS
Buffer: Pointer // void*
): Integer; stdcall;
external 'ADVAPI32.dll' name 'LsaSetTrustedDomainInformation';result := DllCall("ADVAPI32\LsaSetTrustedDomainInformation"
, "Ptr", PolicyHandle ; LSA_HANDLE
, "Ptr", TrustedDomainSid ; PSID
, "Int", InformationClass ; TRUSTED_INFORMATION_CLASS
, "Ptr", Buffer ; void*
, "Int") ; return: NTSTATUS●LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer) = DLL("ADVAPI32.dll", "int LsaSetTrustedDomainInformation(int, void*, int, void*)")
# 呼び出し: LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer)
# PolicyHandle : LSA_HANDLE -> "int"
# TrustedDomainSid : PSID -> "void*"
# InformationClass : TRUSTED_INFORMATION_CLASS -> "int"
# Buffer : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advapi32" fn LsaSetTrustedDomainInformation(
PolicyHandle: isize, // LSA_HANDLE
TrustedDomainSid: ?*anyopaque, // PSID
InformationClass: i32, // TRUSTED_INFORMATION_CLASS
Buffer: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) i32;proc LsaSetTrustedDomainInformation(
PolicyHandle: int, # LSA_HANDLE
TrustedDomainSid: pointer, # PSID
InformationClass: int32, # TRUSTED_INFORMATION_CLASS
Buffer: pointer # void*
): int32 {.importc: "LsaSetTrustedDomainInformation", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
int LsaSetTrustedDomainInformation(
ptrdiff_t PolicyHandle, // LSA_HANDLE
void* TrustedDomainSid, // PSID
int InformationClass, // TRUSTED_INFORMATION_CLASS
void* Buffer // void*
);ccall((:LsaSetTrustedDomainInformation, "ADVAPI32.dll"), stdcall, Int32,
(Int, Ptr{Cvoid}, Int32, Ptr{Cvoid}),
PolicyHandle, TrustedDomainSid, InformationClass, Buffer)
# PolicyHandle : LSA_HANDLE -> Int
# TrustedDomainSid : PSID -> Ptr{Cvoid}
# InformationClass : TRUSTED_INFORMATION_CLASS -> Int32
# Buffer : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t LsaSetTrustedDomainInformation(
intptr_t PolicyHandle,
void* TrustedDomainSid,
int32_t InformationClass,
void* Buffer);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer)
-- PolicyHandle : LSA_HANDLE
-- TrustedDomainSid : PSID
-- InformationClass : TRUSTED_INFORMATION_CLASS
-- Buffer : void*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const LsaSetTrustedDomainInformation = lib.func('__stdcall', 'LsaSetTrustedDomainInformation', 'int32_t', ['intptr_t', 'void *', 'int32_t', 'void *']);
// LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer)
// PolicyHandle : LSA_HANDLE -> 'intptr_t'
// TrustedDomainSid : PSID -> 'void *'
// InformationClass : TRUSTED_INFORMATION_CLASS -> 'int32_t'
// Buffer : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
LsaSetTrustedDomainInformation: { parameters: ["isize", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer)
// PolicyHandle : LSA_HANDLE -> "isize"
// TrustedDomainSid : PSID -> "pointer"
// InformationClass : TRUSTED_INFORMATION_CLASS -> "i32"
// Buffer : void* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t LsaSetTrustedDomainInformation(
intptr_t PolicyHandle,
void* TrustedDomainSid,
int32_t InformationClass,
void* Buffer);
C, "ADVAPI32.dll");
// $ffi->LsaSetTrustedDomainInformation(PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
// PolicyHandle : LSA_HANDLE
// TrustedDomainSid : PSID
// InformationClass : TRUSTED_INFORMATION_CLASS
// Buffer : void*
// 構造体/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);
int LsaSetTrustedDomainInformation(
long PolicyHandle, // LSA_HANDLE
Pointer TrustedDomainSid, // PSID
int InformationClass, // TRUSTED_INFORMATION_CLASS
Pointer Buffer // void*
);
}@[Link("advapi32")]
lib LibADVAPI32
fun LsaSetTrustedDomainInformation = LsaSetTrustedDomainInformation(
PolicyHandle : LibC::SSizeT, # LSA_HANDLE
TrustedDomainSid : Void*, # PSID
InformationClass : Int32, # TRUSTED_INFORMATION_CLASS
Buffer : Void* # void*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef LsaSetTrustedDomainInformationNative = Int32 Function(IntPtr, Pointer<Void>, Int32, Pointer<Void>);
typedef LsaSetTrustedDomainInformationDart = int Function(int, Pointer<Void>, int, Pointer<Void>);
final LsaSetTrustedDomainInformation = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<LsaSetTrustedDomainInformationNative, LsaSetTrustedDomainInformationDart>('LsaSetTrustedDomainInformation');
// PolicyHandle : LSA_HANDLE -> IntPtr
// TrustedDomainSid : PSID -> Pointer<Void>
// InformationClass : TRUSTED_INFORMATION_CLASS -> Int32
// Buffer : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function LsaSetTrustedDomainInformation(
PolicyHandle: NativeInt; // LSA_HANDLE
TrustedDomainSid: THandle; // PSID
InformationClass: Integer; // TRUSTED_INFORMATION_CLASS
Buffer: Pointer // void*
): Integer; stdcall;
external 'ADVAPI32.dll' name 'LsaSetTrustedDomainInformation';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "LsaSetTrustedDomainInformation"
c_LsaSetTrustedDomainInformation :: CIntPtr -> Ptr () -> Int32 -> Ptr () -> IO Int32
-- PolicyHandle : LSA_HANDLE -> CIntPtr
-- TrustedDomainSid : PSID -> Ptr ()
-- InformationClass : TRUSTED_INFORMATION_CLASS -> Int32
-- Buffer : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let lsasettrusteddomaininformation =
foreign "LsaSetTrustedDomainInformation"
(intptr_t @-> (ptr void) @-> int32_t @-> (ptr void) @-> returning int32_t)
(* PolicyHandle : LSA_HANDLE -> intptr_t *)
(* TrustedDomainSid : PSID -> (ptr void) *)
(* InformationClass : TRUSTED_INFORMATION_CLASS -> int32_t *)
(* Buffer : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("LsaSetTrustedDomainInformation" lsa-set-trusted-domain-information :convention :stdcall) :int32
(policy-handle :int64) ; LSA_HANDLE
(trusted-domain-sid :pointer) ; PSID
(information-class :int32) ; TRUSTED_INFORMATION_CLASS
(buffer :pointer)) ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $LsaSetTrustedDomainInformation = Win32::API::More->new('ADVAPI32',
'int LsaSetTrustedDomainInformation(LPARAM PolicyHandle, HANDLE TrustedDomainSid, int InformationClass, LPVOID Buffer)');
# my $ret = $LsaSetTrustedDomainInformation->Call($PolicyHandle, $TrustedDomainSid, $InformationClass, $Buffer);
# PolicyHandle : LSA_HANDLE -> LPARAM
# TrustedDomainSid : PSID -> HANDLE
# InformationClass : TRUSTED_INFORMATION_CLASS -> int
# Buffer : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。