ホーム › NetworkManagement.NetManagement › NetIsServiceAccount
NetIsServiceAccount
関数指定アカウントが管理されたサービスアカウントか判定する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
NTSTATUS NetIsServiceAccount(
LPWSTR ServerName, // optional
LPWSTR AccountName,
BOOL* IsService
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerName | LPWSTR | inoptional |
| AccountName | LPWSTR | in |
| IsService | BOOL* | out |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
NTSTATUS NetIsServiceAccount(
LPWSTR ServerName, // optional
LPWSTR AccountName,
BOOL* IsService
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern int NetIsServiceAccount(
[MarshalAs(UnmanagedType.LPWStr)] string ServerName, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string AccountName, // LPWSTR
out int IsService // BOOL* out
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetIsServiceAccount(
<MarshalAs(UnmanagedType.LPWStr)> ServerName As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> AccountName As String, ' LPWSTR
<Out> ByRef IsService As Integer ' BOOL* out
) As Integer
End Function' ServerName : LPWSTR optional
' AccountName : LPWSTR
' IsService : BOOL* out
Declare PtrSafe Function NetIsServiceAccount Lib "netapi32" ( _
ByVal ServerName As LongPtr, _
ByVal AccountName As LongPtr, _
ByRef IsService As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetIsServiceAccount = ctypes.windll.netapi32.NetIsServiceAccount
NetIsServiceAccount.restype = ctypes.c_int
NetIsServiceAccount.argtypes = [
wintypes.LPCWSTR, # ServerName : LPWSTR optional
wintypes.LPCWSTR, # AccountName : LPWSTR
ctypes.c_void_p, # IsService : BOOL* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetIsServiceAccount = Fiddle::Function.new(
lib['NetIsServiceAccount'],
[
Fiddle::TYPE_VOIDP, # ServerName : LPWSTR optional
Fiddle::TYPE_VOIDP, # AccountName : LPWSTR
Fiddle::TYPE_VOIDP, # IsService : BOOL* out
],
Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetIsServiceAccount(
ServerName: *mut u16, // LPWSTR optional
AccountName: *mut u16, // LPWSTR
IsService: *mut i32 // BOOL* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern int NetIsServiceAccount([MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string AccountName, out int IsService);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetIsServiceAccount' -Namespace Win32 -PassThru
# $api::NetIsServiceAccount(ServerName, AccountName, IsService)#uselib "NETAPI32.dll"
#func global NetIsServiceAccount "NetIsServiceAccount" sptr, sptr, sptr
; NetIsServiceAccount ServerName, AccountName, IsService ; 戻り値は stat
; ServerName : LPWSTR optional -> "sptr"
; AccountName : LPWSTR -> "sptr"
; IsService : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NETAPI32.dll"
#cfunc global NetIsServiceAccount "NetIsServiceAccount" wstr, wstr, int
; res = NetIsServiceAccount(ServerName, AccountName, IsService)
; ServerName : LPWSTR optional -> "wstr"
; AccountName : LPWSTR -> "wstr"
; IsService : BOOL* out -> "int"; NTSTATUS NetIsServiceAccount(LPWSTR ServerName, LPWSTR AccountName, BOOL* IsService)
#uselib "NETAPI32.dll"
#cfunc global NetIsServiceAccount "NetIsServiceAccount" wstr, wstr, int
; res = NetIsServiceAccount(ServerName, AccountName, IsService)
; ServerName : LPWSTR optional -> "wstr"
; AccountName : LPWSTR -> "wstr"
; IsService : BOOL* out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetIsServiceAccount = netapi32.NewProc("NetIsServiceAccount")
)
// ServerName (LPWSTR optional), AccountName (LPWSTR), IsService (BOOL* out)
r1, _, err := procNetIsServiceAccount.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(AccountName))),
uintptr(IsService),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction NetIsServiceAccount(
ServerName: PWideChar; // LPWSTR optional
AccountName: PWideChar; // LPWSTR
IsService: Pointer // BOOL* out
): Integer; stdcall;
external 'NETAPI32.dll' name 'NetIsServiceAccount';result := DllCall("NETAPI32\NetIsServiceAccount"
, "WStr", ServerName ; LPWSTR optional
, "WStr", AccountName ; LPWSTR
, "Ptr", IsService ; BOOL* out
, "Int") ; return: NTSTATUS●NetIsServiceAccount(ServerName, AccountName, IsService) = DLL("NETAPI32.dll", "int NetIsServiceAccount(char*, char*, void*)")
# 呼び出し: NetIsServiceAccount(ServerName, AccountName, IsService)
# ServerName : LPWSTR optional -> "char*"
# AccountName : LPWSTR -> "char*"
# IsService : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。