Win32 API 日本語リファレンス
ホームSystem.Rpc › RpcBindingSetAuthInfoExW

RpcBindingSetAuthInfoExW

関数
RPCバインディングハンドルに認証・認可情報とセキュリティQOSを設定する(Unicode版)。
DLLRPCRT4.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// RPCRT4.dll  (Unicode / -W)
#include <windows.h>

RPC_STATUS RpcBindingSetAuthInfoExW(
    void* Binding,
    LPWSTR ServerPrincName,   // optional
    DWORD AuthnLevel,
    DWORD AuthnSvc,
    void* AuthIdentity,   // optional
    DWORD AuthzSvc,
    RPC_SECURITY_QOS* SecurityQOS   // optional
);

パラメーター

名前方向
Bindingvoid*in
ServerPrincNameLPWSTRinoptional
AuthnLevelDWORDin
AuthnSvcDWORDin
AuthIdentityvoid*inoptional
AuthzSvcDWORDin
SecurityQOSRPC_SECURITY_QOS*inoptional

戻り値の型: RPC_STATUS

各言語での呼び出し定義

// RPCRT4.dll  (Unicode / -W)
#include <windows.h>

RPC_STATUS RpcBindingSetAuthInfoExW(
    void* Binding,
    LPWSTR ServerPrincName,   // optional
    DWORD AuthnLevel,
    DWORD AuthnSvc,
    void* AuthIdentity,   // optional
    DWORD AuthzSvc,
    RPC_SECURITY_QOS* SecurityQOS   // optional
);
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcBindingSetAuthInfoExW(
    IntPtr Binding,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string ServerPrincName,   // LPWSTR optional
    uint AuthnLevel,   // DWORD
    uint AuthnSvc,   // DWORD
    IntPtr AuthIdentity,   // void* optional
    uint AuthzSvc,   // DWORD
    IntPtr SecurityQOS   // RPC_SECURITY_QOS* optional
);
<DllImport("RPCRT4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcBindingSetAuthInfoExW(
    Binding As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> ServerPrincName As String,   ' LPWSTR optional
    AuthnLevel As UInteger,   ' DWORD
    AuthnSvc As UInteger,   ' DWORD
    AuthIdentity As IntPtr,   ' void* optional
    AuthzSvc As UInteger,   ' DWORD
    SecurityQOS As IntPtr   ' RPC_SECURITY_QOS* optional
) As Integer
End Function
' Binding : void*
' ServerPrincName : LPWSTR optional
' AuthnLevel : DWORD
' AuthnSvc : DWORD
' AuthIdentity : void* optional
' AuthzSvc : DWORD
' SecurityQOS : RPC_SECURITY_QOS* optional
Declare PtrSafe Function RpcBindingSetAuthInfoExW Lib "rpcrt4" ( _
    ByVal Binding As LongPtr, _
    ByVal ServerPrincName As LongPtr, _
    ByVal AuthnLevel As Long, _
    ByVal AuthnSvc As Long, _
    ByVal AuthIdentity As LongPtr, _
    ByVal AuthzSvc As Long, _
    ByVal SecurityQOS As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RpcBindingSetAuthInfoExW = ctypes.windll.rpcrt4.RpcBindingSetAuthInfoExW
RpcBindingSetAuthInfoExW.restype = ctypes.c_int
RpcBindingSetAuthInfoExW.argtypes = [
    ctypes.POINTER(None),  # Binding : void*
    wintypes.LPCWSTR,  # ServerPrincName : LPWSTR optional
    wintypes.DWORD,  # AuthnLevel : DWORD
    wintypes.DWORD,  # AuthnSvc : DWORD
    ctypes.POINTER(None),  # AuthIdentity : void* optional
    wintypes.DWORD,  # AuthzSvc : DWORD
    ctypes.c_void_p,  # SecurityQOS : RPC_SECURITY_QOS* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
RpcBindingSetAuthInfoExW = Fiddle::Function.new(
  lib['RpcBindingSetAuthInfoExW'],
  [
    Fiddle::TYPE_VOIDP,  # Binding : void*
    Fiddle::TYPE_VOIDP,  # ServerPrincName : LPWSTR optional
    -Fiddle::TYPE_INT,  # AuthnLevel : DWORD
    -Fiddle::TYPE_INT,  # AuthnSvc : DWORD
    Fiddle::TYPE_VOIDP,  # AuthIdentity : void* optional
    -Fiddle::TYPE_INT,  # AuthzSvc : DWORD
    Fiddle::TYPE_VOIDP,  # SecurityQOS : RPC_SECURITY_QOS* optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "rpcrt4")]
extern "system" {
    fn RpcBindingSetAuthInfoExW(
        Binding: *mut (),  // void*
        ServerPrincName: *mut u16,  // LPWSTR optional
        AuthnLevel: u32,  // DWORD
        AuthnSvc: u32,  // DWORD
        AuthIdentity: *mut (),  // void* optional
        AuthzSvc: u32,  // DWORD
        SecurityQOS: *mut RPC_SECURITY_QOS  // RPC_SECURITY_QOS* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode)]
public static extern int RpcBindingSetAuthInfoExW(IntPtr Binding, [MarshalAs(UnmanagedType.LPWStr)] string ServerPrincName, uint AuthnLevel, uint AuthnSvc, IntPtr AuthIdentity, uint AuthzSvc, IntPtr SecurityQOS);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcBindingSetAuthInfoExW' -Namespace Win32 -PassThru
# $api::RpcBindingSetAuthInfoExW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQOS)
#uselib "RPCRT4.dll"
#func global RpcBindingSetAuthInfoExW "RpcBindingSetAuthInfoExW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; RpcBindingSetAuthInfoExW Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, varptr(SecurityQOS)   ; 戻り値は stat
; Binding : void* -> "wptr"
; ServerPrincName : LPWSTR optional -> "wptr"
; AuthnLevel : DWORD -> "wptr"
; AuthnSvc : DWORD -> "wptr"
; AuthIdentity : void* optional -> "wptr"
; AuthzSvc : DWORD -> "wptr"
; SecurityQOS : RPC_SECURITY_QOS* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetAuthInfoExW "RpcBindingSetAuthInfoExW" sptr, wstr, int, int, sptr, int, var
; res = RpcBindingSetAuthInfoExW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQOS)
; Binding : void* -> "sptr"
; ServerPrincName : LPWSTR optional -> "wstr"
; AuthnLevel : DWORD -> "int"
; AuthnSvc : DWORD -> "int"
; AuthIdentity : void* optional -> "sptr"
; AuthzSvc : DWORD -> "int"
; SecurityQOS : RPC_SECURITY_QOS* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS RpcBindingSetAuthInfoExW(void* Binding, LPWSTR ServerPrincName, DWORD AuthnLevel, DWORD AuthnSvc, void* AuthIdentity, DWORD AuthzSvc, RPC_SECURITY_QOS* SecurityQOS)
#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetAuthInfoExW "RpcBindingSetAuthInfoExW" intptr, wstr, int, int, intptr, int, var
; res = RpcBindingSetAuthInfoExW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQOS)
; Binding : void* -> "intptr"
; ServerPrincName : LPWSTR optional -> "wstr"
; AuthnLevel : DWORD -> "int"
; AuthnSvc : DWORD -> "int"
; AuthIdentity : void* optional -> "intptr"
; AuthzSvc : DWORD -> "int"
; SecurityQOS : RPC_SECURITY_QOS* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procRpcBindingSetAuthInfoExW = rpcrt4.NewProc("RpcBindingSetAuthInfoExW")
)

// Binding (void*), ServerPrincName (LPWSTR optional), AuthnLevel (DWORD), AuthnSvc (DWORD), AuthIdentity (void* optional), AuthzSvc (DWORD), SecurityQOS (RPC_SECURITY_QOS* optional)
r1, _, err := procRpcBindingSetAuthInfoExW.Call(
	uintptr(Binding),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerPrincName))),
	uintptr(AuthnLevel),
	uintptr(AuthnSvc),
	uintptr(AuthIdentity),
	uintptr(AuthzSvc),
	uintptr(SecurityQOS),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcBindingSetAuthInfoExW(
  Binding: Pointer;   // void*
  ServerPrincName: PWideChar;   // LPWSTR optional
  AuthnLevel: DWORD;   // DWORD
  AuthnSvc: DWORD;   // DWORD
  AuthIdentity: Pointer;   // void* optional
  AuthzSvc: DWORD;   // DWORD
  SecurityQOS: Pointer   // RPC_SECURITY_QOS* optional
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcBindingSetAuthInfoExW';
result := DllCall("RPCRT4\RpcBindingSetAuthInfoExW"
    , "Ptr", Binding   ; void*
    , "WStr", ServerPrincName   ; LPWSTR optional
    , "UInt", AuthnLevel   ; DWORD
    , "UInt", AuthnSvc   ; DWORD
    , "Ptr", AuthIdentity   ; void* optional
    , "UInt", AuthzSvc   ; DWORD
    , "Ptr", SecurityQOS   ; RPC_SECURITY_QOS* optional
    , "Int")   ; return: RPC_STATUS
●RpcBindingSetAuthInfoExW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQOS) = DLL("RPCRT4.dll", "int RpcBindingSetAuthInfoExW(void*, char*, dword, dword, void*, dword, void*)")
# 呼び出し: RpcBindingSetAuthInfoExW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQOS)
# Binding : void* -> "void*"
# ServerPrincName : LPWSTR optional -> "char*"
# AuthnLevel : DWORD -> "dword"
# AuthnSvc : DWORD -> "dword"
# AuthIdentity : void* optional -> "void*"
# AuthzSvc : DWORD -> "dword"
# SecurityQOS : RPC_SECURITY_QOS* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。