ホーム › Networking.ActiveDirectory › DsGetForestTrustInformationW
DsGetForestTrustInformationW
関数信頼するフォレストの信頼情報を取得する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD DsGetForestTrustInformationW(
LPCWSTR ServerName, // optional
LPCWSTR TrustedDomainName, // optional
DWORD Flags,
LSA_FOREST_TRUST_INFORMATION** ForestTrustInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerName | LPCWSTR | inoptional | 問い合わせを実行するDC名を指すワイド文字列。ローカルの場合はNULL可。 |
| TrustedDomainName | LPCWSTR | inoptional | フォレスト信頼情報を取得する対象信頼ドメイン名を指すワイド文字列。 |
| Flags | DWORD | in | 取得動作を制御するフラグ。更新フラグDS_GFTI_UPDATE_TDO等を指定する。 |
| ForestTrustInfo | LSA_FOREST_TRUST_INFORMATION** | out | 取得したフォレスト信頼情報構造体へのポインタを受け取る出力。使用後はNetApiBufferFreeで解放する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD DsGetForestTrustInformationW(
LPCWSTR ServerName, // optional
LPCWSTR TrustedDomainName, // optional
DWORD Flags,
LSA_FOREST_TRUST_INFORMATION** ForestTrustInfo
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint DsGetForestTrustInformationW(
[MarshalAs(UnmanagedType.LPWStr)] string ServerName, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string TrustedDomainName, // LPCWSTR optional
uint Flags, // DWORD
IntPtr ForestTrustInfo // LSA_FOREST_TRUST_INFORMATION** out
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function DsGetForestTrustInformationW(
<MarshalAs(UnmanagedType.LPWStr)> ServerName As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> TrustedDomainName As String, ' LPCWSTR optional
Flags As UInteger, ' DWORD
ForestTrustInfo As IntPtr ' LSA_FOREST_TRUST_INFORMATION** out
) As UInteger
End Function' ServerName : LPCWSTR optional
' TrustedDomainName : LPCWSTR optional
' Flags : DWORD
' ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out
Declare PtrSafe Function DsGetForestTrustInformationW Lib "netapi32" ( _
ByVal ServerName As LongPtr, _
ByVal TrustedDomainName As LongPtr, _
ByVal Flags As Long, _
ByVal ForestTrustInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DsGetForestTrustInformationW = ctypes.windll.netapi32.DsGetForestTrustInformationW
DsGetForestTrustInformationW.restype = wintypes.DWORD
DsGetForestTrustInformationW.argtypes = [
wintypes.LPCWSTR, # ServerName : LPCWSTR optional
wintypes.LPCWSTR, # TrustedDomainName : LPCWSTR optional
wintypes.DWORD, # Flags : DWORD
ctypes.c_void_p, # ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
DsGetForestTrustInformationW = Fiddle::Function.new(
lib['DsGetForestTrustInformationW'],
[
Fiddle::TYPE_VOIDP, # ServerName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # TrustedDomainName : LPCWSTR optional
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out
],
-Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn DsGetForestTrustInformationW(
ServerName: *const u16, // LPCWSTR optional
TrustedDomainName: *const u16, // LPCWSTR optional
Flags: u32, // DWORD
ForestTrustInfo: *mut *mut LSA_FOREST_TRUST_INFORMATION // LSA_FOREST_TRUST_INFORMATION** out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint DsGetForestTrustInformationW([MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string TrustedDomainName, uint Flags, IntPtr ForestTrustInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_DsGetForestTrustInformationW' -Namespace Win32 -PassThru
# $api::DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo)#uselib "NETAPI32.dll"
#func global DsGetForestTrustInformationW "DsGetForestTrustInformationW" sptr, sptr, sptr, sptr
; DsGetForestTrustInformationW ServerName, TrustedDomainName, Flags, varptr(ForestTrustInfo) ; 戻り値は stat
; ServerName : LPCWSTR optional -> "sptr"
; TrustedDomainName : LPCWSTR optional -> "sptr"
; Flags : DWORD -> "sptr"
; ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "NETAPI32.dll" #cfunc global DsGetForestTrustInformationW "DsGetForestTrustInformationW" wstr, wstr, int, var ; res = DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo) ; ServerName : LPCWSTR optional -> "wstr" ; TrustedDomainName : LPCWSTR optional -> "wstr" ; Flags : DWORD -> "int" ; ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "NETAPI32.dll" #cfunc global DsGetForestTrustInformationW "DsGetForestTrustInformationW" wstr, wstr, int, sptr ; res = DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, varptr(ForestTrustInfo)) ; ServerName : LPCWSTR optional -> "wstr" ; TrustedDomainName : LPCWSTR optional -> "wstr" ; Flags : DWORD -> "int" ; ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DsGetForestTrustInformationW(LPCWSTR ServerName, LPCWSTR TrustedDomainName, DWORD Flags, LSA_FOREST_TRUST_INFORMATION** ForestTrustInfo) #uselib "NETAPI32.dll" #cfunc global DsGetForestTrustInformationW "DsGetForestTrustInformationW" wstr, wstr, int, var ; res = DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo) ; ServerName : LPCWSTR optional -> "wstr" ; TrustedDomainName : LPCWSTR optional -> "wstr" ; Flags : DWORD -> "int" ; ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DsGetForestTrustInformationW(LPCWSTR ServerName, LPCWSTR TrustedDomainName, DWORD Flags, LSA_FOREST_TRUST_INFORMATION** ForestTrustInfo) #uselib "NETAPI32.dll" #cfunc global DsGetForestTrustInformationW "DsGetForestTrustInformationW" wstr, wstr, int, intptr ; res = DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, varptr(ForestTrustInfo)) ; ServerName : LPCWSTR optional -> "wstr" ; TrustedDomainName : LPCWSTR optional -> "wstr" ; Flags : DWORD -> "int" ; ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procDsGetForestTrustInformationW = netapi32.NewProc("DsGetForestTrustInformationW")
)
// ServerName (LPCWSTR optional), TrustedDomainName (LPCWSTR optional), Flags (DWORD), ForestTrustInfo (LSA_FOREST_TRUST_INFORMATION** out)
r1, _, err := procDsGetForestTrustInformationW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TrustedDomainName))),
uintptr(Flags),
uintptr(ForestTrustInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DsGetForestTrustInformationW(
ServerName: PWideChar; // LPCWSTR optional
TrustedDomainName: PWideChar; // LPCWSTR optional
Flags: DWORD; // DWORD
ForestTrustInfo: Pointer // LSA_FOREST_TRUST_INFORMATION** out
): DWORD; stdcall;
external 'NETAPI32.dll' name 'DsGetForestTrustInformationW';result := DllCall("NETAPI32\DsGetForestTrustInformationW"
, "WStr", ServerName ; LPCWSTR optional
, "WStr", TrustedDomainName ; LPCWSTR optional
, "UInt", Flags ; DWORD
, "Ptr", ForestTrustInfo ; LSA_FOREST_TRUST_INFORMATION** out
, "UInt") ; return: DWORD●DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo) = DLL("NETAPI32.dll", "dword DsGetForestTrustInformationW(char*, char*, dword, void*)")
# 呼び出し: DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo)
# ServerName : LPCWSTR optional -> "char*"
# TrustedDomainName : LPCWSTR optional -> "char*"
# Flags : DWORD -> "dword"
# ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "netapi32" fn DsGetForestTrustInformationW(
ServerName: [*c]const u16, // LPCWSTR optional
TrustedDomainName: [*c]const u16, // LPCWSTR optional
Flags: u32, // DWORD
ForestTrustInfo: [*c][*c]LSA_FOREST_TRUST_INFORMATION // LSA_FOREST_TRUST_INFORMATION** out
) callconv(std.os.windows.WINAPI) u32;proc DsGetForestTrustInformationW(
ServerName: WideCString, # LPCWSTR optional
TrustedDomainName: WideCString, # LPCWSTR optional
Flags: uint32, # DWORD
ForestTrustInfo: ptr LSA_FOREST_TRUST_INFORMATION # LSA_FOREST_TRUST_INFORMATION** out
): uint32 {.importc: "DsGetForestTrustInformationW", stdcall, dynlib: "NETAPI32.dll".}pragma(lib, "netapi32");
extern(Windows)
uint DsGetForestTrustInformationW(
const(wchar)* ServerName, // LPCWSTR optional
const(wchar)* TrustedDomainName, // LPCWSTR optional
uint Flags, // DWORD
LSA_FOREST_TRUST_INFORMATION** ForestTrustInfo // LSA_FOREST_TRUST_INFORMATION** out
);ccall((:DsGetForestTrustInformationW, "NETAPI32.dll"), stdcall, UInt32,
(Cwstring, Cwstring, UInt32, Ptr{LSA_FOREST_TRUST_INFORMATION}),
ServerName, TrustedDomainName, Flags, ForestTrustInfo)
# ServerName : LPCWSTR optional -> Cwstring
# TrustedDomainName : LPCWSTR optional -> Cwstring
# Flags : DWORD -> UInt32
# ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> Ptr{LSA_FOREST_TRUST_INFORMATION}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t DsGetForestTrustInformationW(
const uint16_t* ServerName,
const uint16_t* TrustedDomainName,
uint32_t Flags,
void* ForestTrustInfo);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo)
-- ServerName : LPCWSTR optional
-- TrustedDomainName : LPCWSTR optional
-- Flags : DWORD
-- ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const DsGetForestTrustInformationW = lib.func('__stdcall', 'DsGetForestTrustInformationW', 'uint32_t', ['str16', 'str16', 'uint32_t', 'void *']);
// DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo)
// ServerName : LPCWSTR optional -> 'str16'
// TrustedDomainName : LPCWSTR optional -> 'str16'
// Flags : DWORD -> 'uint32_t'
// ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NETAPI32.dll", {
DsGetForestTrustInformationW: { parameters: ["buffer", "buffer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo)
// ServerName : LPCWSTR optional -> "buffer"
// TrustedDomainName : LPCWSTR optional -> "buffer"
// Flags : DWORD -> "u32"
// ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DsGetForestTrustInformationW(
const uint16_t* ServerName,
const uint16_t* TrustedDomainName,
uint32_t Flags,
void* ForestTrustInfo);
C, "NETAPI32.dll");
// $ffi->DsGetForestTrustInformationW(ServerName, TrustedDomainName, Flags, ForestTrustInfo);
// ServerName : LPCWSTR optional
// TrustedDomainName : LPCWSTR optional
// Flags : DWORD
// ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out
// 構造体/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 Netapi32 extends StdCallLibrary {
Netapi32 INSTANCE = Native.load("netapi32", Netapi32.class);
int DsGetForestTrustInformationW(
WString ServerName, // LPCWSTR optional
WString TrustedDomainName, // LPCWSTR optional
int Flags, // DWORD
Pointer ForestTrustInfo // LSA_FOREST_TRUST_INFORMATION** out
);
}@[Link("netapi32")]
lib LibNETAPI32
fun DsGetForestTrustInformationW = DsGetForestTrustInformationW(
ServerName : UInt16*, # LPCWSTR optional
TrustedDomainName : UInt16*, # LPCWSTR optional
Flags : UInt32, # DWORD
ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** # LSA_FOREST_TRUST_INFORMATION** out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DsGetForestTrustInformationWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Void>);
typedef DsGetForestTrustInformationWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Void>);
final DsGetForestTrustInformationW = DynamicLibrary.open('NETAPI32.dll')
.lookupFunction<DsGetForestTrustInformationWNative, DsGetForestTrustInformationWDart>('DsGetForestTrustInformationW');
// ServerName : LPCWSTR optional -> Pointer<Utf16>
// TrustedDomainName : LPCWSTR optional -> Pointer<Utf16>
// Flags : DWORD -> Uint32
// ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DsGetForestTrustInformationW(
ServerName: PWideChar; // LPCWSTR optional
TrustedDomainName: PWideChar; // LPCWSTR optional
Flags: DWORD; // DWORD
ForestTrustInfo: Pointer // LSA_FOREST_TRUST_INFORMATION** out
): DWORD; stdcall;
external 'NETAPI32.dll' name 'DsGetForestTrustInformationW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DsGetForestTrustInformationW"
c_DsGetForestTrustInformationW :: CWString -> CWString -> Word32 -> Ptr () -> IO Word32
-- ServerName : LPCWSTR optional -> CWString
-- TrustedDomainName : LPCWSTR optional -> CWString
-- Flags : DWORD -> Word32
-- ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dsgetforesttrustinformationw =
foreign "DsGetForestTrustInformationW"
((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* ServerName : LPCWSTR optional -> (ptr uint16_t) *)
(* TrustedDomainName : LPCWSTR optional -> (ptr uint16_t) *)
(* Flags : DWORD -> uint32_t *)
(* ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)
(cffi:defcfun ("DsGetForestTrustInformationW" ds-get-forest-trust-information-w :convention :stdcall) :uint32
(server-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(trusted-domain-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(flags :uint32) ; DWORD
(forest-trust-info :pointer)) ; LSA_FOREST_TRUST_INFORMATION** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DsGetForestTrustInformationW = Win32::API::More->new('NETAPI32',
'DWORD DsGetForestTrustInformationW(LPCWSTR ServerName, LPCWSTR TrustedDomainName, DWORD Flags, LPVOID ForestTrustInfo)');
# my $ret = $DsGetForestTrustInformationW->Call($ServerName, $TrustedDomainName, $Flags, $ForestTrustInfo);
# ServerName : LPCWSTR optional -> LPCWSTR
# TrustedDomainName : LPCWSTR optional -> LPCWSTR
# Flags : DWORD -> DWORD
# ForestTrustInfo : LSA_FOREST_TRUST_INFORMATION** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。