ホーム › System.Rpc › RpcBindingSetAuthInfoW
RpcBindingSetAuthInfoW
関数RPCバインディングハンドルに認証レベルや認証サービスなどの認証情報を設定する(Unicode版)。
シグネチャ
// RPCRT4.dll (Unicode / -W)
#include <windows.h>
RPC_STATUS RpcBindingSetAuthInfoW(
void* Binding,
LPWSTR ServerPrincName, // optional
DWORD AuthnLevel,
DWORD AuthnSvc,
void* AuthIdentity, // optional
DWORD AuthzSvc
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Binding | void* | in |
| ServerPrincName | LPWSTR | inoptional |
| AuthnLevel | DWORD | in |
| AuthnSvc | DWORD | in |
| AuthIdentity | void* | inoptional |
| AuthzSvc | DWORD | in |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCRT4.dll (Unicode / -W)
#include <windows.h>
RPC_STATUS RpcBindingSetAuthInfoW(
void* Binding,
LPWSTR ServerPrincName, // optional
DWORD AuthnLevel,
DWORD AuthnSvc,
void* AuthIdentity, // optional
DWORD AuthzSvc
);[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcBindingSetAuthInfoW(
IntPtr Binding, // void*
[MarshalAs(UnmanagedType.LPWStr)] string ServerPrincName, // LPWSTR optional
uint AuthnLevel, // DWORD
uint AuthnSvc, // DWORD
IntPtr AuthIdentity, // void* optional
uint AuthzSvc // DWORD
);<DllImport("RPCRT4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcBindingSetAuthInfoW(
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
) As Integer
End Function' Binding : void*
' ServerPrincName : LPWSTR optional
' AuthnLevel : DWORD
' AuthnSvc : DWORD
' AuthIdentity : void* optional
' AuthzSvc : DWORD
Declare PtrSafe Function RpcBindingSetAuthInfoW 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) 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
RpcBindingSetAuthInfoW = ctypes.windll.rpcrt4.RpcBindingSetAuthInfoW
RpcBindingSetAuthInfoW.restype = ctypes.c_int
RpcBindingSetAuthInfoW.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
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
RpcBindingSetAuthInfoW = Fiddle::Function.new(
lib['RpcBindingSetAuthInfoW'],
[
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_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "rpcrt4")]
extern "system" {
fn RpcBindingSetAuthInfoW(
Binding: *mut (), // void*
ServerPrincName: *mut u16, // LPWSTR optional
AuthnLevel: u32, // DWORD
AuthnSvc: u32, // DWORD
AuthIdentity: *mut (), // void* optional
AuthzSvc: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode)]
public static extern int RpcBindingSetAuthInfoW(IntPtr Binding, [MarshalAs(UnmanagedType.LPWStr)] string ServerPrincName, uint AuthnLevel, uint AuthnSvc, IntPtr AuthIdentity, uint AuthzSvc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcBindingSetAuthInfoW' -Namespace Win32 -PassThru
# $api::RpcBindingSetAuthInfoW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)#uselib "RPCRT4.dll"
#func global RpcBindingSetAuthInfoW "RpcBindingSetAuthInfoW" wptr, wptr, wptr, wptr, wptr, wptr
; RpcBindingSetAuthInfoW Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc ; 戻り値は stat
; Binding : void* -> "wptr"
; ServerPrincName : LPWSTR optional -> "wptr"
; AuthnLevel : DWORD -> "wptr"
; AuthnSvc : DWORD -> "wptr"
; AuthIdentity : void* optional -> "wptr"
; AuthzSvc : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetAuthInfoW "RpcBindingSetAuthInfoW" sptr, wstr, int, int, sptr, int
; res = RpcBindingSetAuthInfoW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
; Binding : void* -> "sptr"
; ServerPrincName : LPWSTR optional -> "wstr"
; AuthnLevel : DWORD -> "int"
; AuthnSvc : DWORD -> "int"
; AuthIdentity : void* optional -> "sptr"
; AuthzSvc : DWORD -> "int"; RPC_STATUS RpcBindingSetAuthInfoW(void* Binding, LPWSTR ServerPrincName, DWORD AuthnLevel, DWORD AuthnSvc, void* AuthIdentity, DWORD AuthzSvc)
#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetAuthInfoW "RpcBindingSetAuthInfoW" intptr, wstr, int, int, intptr, int
; res = RpcBindingSetAuthInfoW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
; Binding : void* -> "intptr"
; ServerPrincName : LPWSTR optional -> "wstr"
; AuthnLevel : DWORD -> "int"
; AuthnSvc : DWORD -> "int"
; AuthIdentity : void* optional -> "intptr"
; AuthzSvc : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procRpcBindingSetAuthInfoW = rpcrt4.NewProc("RpcBindingSetAuthInfoW")
)
// Binding (void*), ServerPrincName (LPWSTR optional), AuthnLevel (DWORD), AuthnSvc (DWORD), AuthIdentity (void* optional), AuthzSvc (DWORD)
r1, _, err := procRpcBindingSetAuthInfoW.Call(
uintptr(Binding),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerPrincName))),
uintptr(AuthnLevel),
uintptr(AuthnSvc),
uintptr(AuthIdentity),
uintptr(AuthzSvc),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcBindingSetAuthInfoW(
Binding: Pointer; // void*
ServerPrincName: PWideChar; // LPWSTR optional
AuthnLevel: DWORD; // DWORD
AuthnSvc: DWORD; // DWORD
AuthIdentity: Pointer; // void* optional
AuthzSvc: DWORD // DWORD
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcBindingSetAuthInfoW';result := DllCall("RPCRT4\RpcBindingSetAuthInfoW"
, "Ptr", Binding ; void*
, "WStr", ServerPrincName ; LPWSTR optional
, "UInt", AuthnLevel ; DWORD
, "UInt", AuthnSvc ; DWORD
, "Ptr", AuthIdentity ; void* optional
, "UInt", AuthzSvc ; DWORD
, "Int") ; return: RPC_STATUS●RpcBindingSetAuthInfoW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc) = DLL("RPCRT4.dll", "int RpcBindingSetAuthInfoW(void*, char*, dword, dword, void*, dword)")
# 呼び出し: RpcBindingSetAuthInfoW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
# Binding : void* -> "void*"
# ServerPrincName : LPWSTR optional -> "char*"
# AuthnLevel : DWORD -> "dword"
# AuthnSvc : DWORD -> "dword"
# AuthIdentity : void* optional -> "void*"
# AuthzSvc : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。