Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › LsaSetDomainInformationPolicy

LsaSetDomainInformationPolicy

関数
LSAポリシーにドメイン関連のポリシー情報を設定する。
DLLADVAPI32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

NTSTATUS LsaSetDomainInformationPolicy(
    LSA_HANDLE PolicyHandle,
    POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
    void* Buffer   // optional
);

パラメーター

名前方向
PolicyHandleLSA_HANDLEin
InformationClassPOLICY_DOMAIN_INFORMATION_CLASSin
Buffervoid*inoptional

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS LsaSetDomainInformationPolicy(
    LSA_HANDLE PolicyHandle,
    POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
    void* Buffer   // optional
);
[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern int LsaSetDomainInformationPolicy(
    IntPtr PolicyHandle,   // LSA_HANDLE
    int InformationClass,   // POLICY_DOMAIN_INFORMATION_CLASS
    IntPtr Buffer   // void* optional
);
<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function LsaSetDomainInformationPolicy(
    PolicyHandle As IntPtr,   ' LSA_HANDLE
    InformationClass As Integer,   ' POLICY_DOMAIN_INFORMATION_CLASS
    Buffer As IntPtr   ' void* optional
) As Integer
End Function
' PolicyHandle : LSA_HANDLE
' InformationClass : POLICY_DOMAIN_INFORMATION_CLASS
' Buffer : void* optional
Declare PtrSafe Function LsaSetDomainInformationPolicy Lib "advapi32" ( _
    ByVal PolicyHandle 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

LsaSetDomainInformationPolicy = ctypes.windll.advapi32.LsaSetDomainInformationPolicy
LsaSetDomainInformationPolicy.restype = ctypes.c_int
LsaSetDomainInformationPolicy.argtypes = [
    ctypes.c_ssize_t,  # PolicyHandle : LSA_HANDLE
    ctypes.c_int,  # InformationClass : POLICY_DOMAIN_INFORMATION_CLASS
    ctypes.POINTER(None),  # Buffer : void* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
LsaSetDomainInformationPolicy = Fiddle::Function.new(
  lib['LsaSetDomainInformationPolicy'],
  [
    Fiddle::TYPE_INTPTR_T,  # PolicyHandle : LSA_HANDLE
    Fiddle::TYPE_INT,  # InformationClass : POLICY_DOMAIN_INFORMATION_CLASS
    Fiddle::TYPE_VOIDP,  # Buffer : void* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn LsaSetDomainInformationPolicy(
        PolicyHandle: isize,  // LSA_HANDLE
        InformationClass: i32,  // POLICY_DOMAIN_INFORMATION_CLASS
        Buffer: *mut ()  // void* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern int LsaSetDomainInformationPolicy(IntPtr PolicyHandle, int InformationClass, IntPtr Buffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_LsaSetDomainInformationPolicy' -Namespace Win32 -PassThru
# $api::LsaSetDomainInformationPolicy(PolicyHandle, InformationClass, Buffer)
#uselib "ADVAPI32.dll"
#func global LsaSetDomainInformationPolicy "LsaSetDomainInformationPolicy" sptr, sptr, sptr
; LsaSetDomainInformationPolicy PolicyHandle, InformationClass, Buffer   ; 戻り値は stat
; PolicyHandle : LSA_HANDLE -> "sptr"
; InformationClass : POLICY_DOMAIN_INFORMATION_CLASS -> "sptr"
; Buffer : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVAPI32.dll"
#cfunc global LsaSetDomainInformationPolicy "LsaSetDomainInformationPolicy" sptr, int, sptr
; res = LsaSetDomainInformationPolicy(PolicyHandle, InformationClass, Buffer)
; PolicyHandle : LSA_HANDLE -> "sptr"
; InformationClass : POLICY_DOMAIN_INFORMATION_CLASS -> "int"
; Buffer : void* optional -> "sptr"
; NTSTATUS LsaSetDomainInformationPolicy(LSA_HANDLE PolicyHandle, POLICY_DOMAIN_INFORMATION_CLASS InformationClass, void* Buffer)
#uselib "ADVAPI32.dll"
#cfunc global LsaSetDomainInformationPolicy "LsaSetDomainInformationPolicy" intptr, int, intptr
; res = LsaSetDomainInformationPolicy(PolicyHandle, InformationClass, Buffer)
; PolicyHandle : LSA_HANDLE -> "intptr"
; InformationClass : POLICY_DOMAIN_INFORMATION_CLASS -> "int"
; Buffer : void* optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procLsaSetDomainInformationPolicy = advapi32.NewProc("LsaSetDomainInformationPolicy")
)

// PolicyHandle (LSA_HANDLE), InformationClass (POLICY_DOMAIN_INFORMATION_CLASS), Buffer (void* optional)
r1, _, err := procLsaSetDomainInformationPolicy.Call(
	uintptr(PolicyHandle),
	uintptr(InformationClass),
	uintptr(Buffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // NTSTATUS
function LsaSetDomainInformationPolicy(
  PolicyHandle: NativeInt;   // LSA_HANDLE
  InformationClass: Integer;   // POLICY_DOMAIN_INFORMATION_CLASS
  Buffer: Pointer   // void* optional
): Integer; stdcall;
  external 'ADVAPI32.dll' name 'LsaSetDomainInformationPolicy';
result := DllCall("ADVAPI32\LsaSetDomainInformationPolicy"
    , "Ptr", PolicyHandle   ; LSA_HANDLE
    , "Int", InformationClass   ; POLICY_DOMAIN_INFORMATION_CLASS
    , "Ptr", Buffer   ; void* optional
    , "Int")   ; return: NTSTATUS
●LsaSetDomainInformationPolicy(PolicyHandle, InformationClass, Buffer) = DLL("ADVAPI32.dll", "int LsaSetDomainInformationPolicy(int, int, void*)")
# 呼び出し: LsaSetDomainInformationPolicy(PolicyHandle, InformationClass, Buffer)
# PolicyHandle : LSA_HANDLE -> "int"
# InformationClass : POLICY_DOMAIN_INFORMATION_CLASS -> "int"
# Buffer : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。