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

RpcBindingSetAuthInfoExA

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

シグネチャ

// RPCRT4.dll  (ANSI / -A)
#include <windows.h>

RPC_STATUS RpcBindingSetAuthInfoExA(
    void* Binding,
    LPSTR ServerPrincName,   // optional
    DWORD AuthnLevel,
    DWORD AuthnSvc,
    void* AuthIdentity,   // optional
    DWORD AuthzSvc,
    RPC_SECURITY_QOS* SecurityQos   // optional
);

パラメーター

名前方向
Bindingvoid*in
ServerPrincNameLPSTRinoptional
AuthnLevelDWORDin
AuthnSvcDWORDin
AuthIdentityvoid*inoptional
AuthzSvcDWORDin
SecurityQosRPC_SECURITY_QOS*inoptional

戻り値の型: RPC_STATUS

各言語での呼び出し定義

// RPCRT4.dll  (ANSI / -A)
#include <windows.h>

RPC_STATUS RpcBindingSetAuthInfoExA(
    void* Binding,
    LPSTR ServerPrincName,   // optional
    DWORD AuthnLevel,
    DWORD AuthnSvc,
    void* AuthIdentity,   // optional
    DWORD AuthzSvc,
    RPC_SECURITY_QOS* SecurityQos   // optional
);
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RpcBindingSetAuthInfoExA(
    IntPtr Binding,   // void*
    [MarshalAs(UnmanagedType.LPStr)] string ServerPrincName,   // LPSTR 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.Ansi, ExactSpelling:=True)>
Public Shared Function RpcBindingSetAuthInfoExA(
    Binding As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPStr)> ServerPrincName As String,   ' LPSTR 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 : LPSTR optional
' AuthnLevel : DWORD
' AuthnSvc : DWORD
' AuthIdentity : void* optional
' AuthzSvc : DWORD
' SecurityQos : RPC_SECURITY_QOS* optional
Declare PtrSafe Function RpcBindingSetAuthInfoExA Lib "rpcrt4" ( _
    ByVal Binding As LongPtr, _
    ByVal ServerPrincName As String, _
    ByVal AuthnLevel As Long, _
    ByVal AuthnSvc As Long, _
    ByVal AuthIdentity As LongPtr, _
    ByVal AuthzSvc As Long, _
    ByVal SecurityQos As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RpcBindingSetAuthInfoExA = ctypes.windll.rpcrt4.RpcBindingSetAuthInfoExA
RpcBindingSetAuthInfoExA.restype = ctypes.c_int
RpcBindingSetAuthInfoExA.argtypes = [
    ctypes.POINTER(None),  # Binding : void*
    wintypes.LPCSTR,  # ServerPrincName : LPSTR 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')
RpcBindingSetAuthInfoExA = Fiddle::Function.new(
  lib['RpcBindingSetAuthInfoExA'],
  [
    Fiddle::TYPE_VOIDP,  # Binding : void*
    Fiddle::TYPE_VOIDP,  # ServerPrincName : LPSTR 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)
#[link(name = "rpcrt4")]
extern "system" {
    fn RpcBindingSetAuthInfoExA(
        Binding: *mut (),  // void*
        ServerPrincName: *mut u8,  // LPSTR 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.Ansi)]
public static extern int RpcBindingSetAuthInfoExA(IntPtr Binding, [MarshalAs(UnmanagedType.LPStr)] string ServerPrincName, uint AuthnLevel, uint AuthnSvc, IntPtr AuthIdentity, uint AuthzSvc, IntPtr SecurityQos);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcBindingSetAuthInfoExA' -Namespace Win32 -PassThru
# $api::RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos)
#uselib "RPCRT4.dll"
#func global RpcBindingSetAuthInfoExA "RpcBindingSetAuthInfoExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; RpcBindingSetAuthInfoExA Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, varptr(SecurityQos)   ; 戻り値は stat
; Binding : void* -> "sptr"
; ServerPrincName : LPSTR optional -> "sptr"
; AuthnLevel : DWORD -> "sptr"
; AuthnSvc : DWORD -> "sptr"
; AuthIdentity : void* optional -> "sptr"
; AuthzSvc : DWORD -> "sptr"
; SecurityQos : RPC_SECURITY_QOS* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetAuthInfoExA "RpcBindingSetAuthInfoExA" sptr, str, int, int, sptr, int, var
; res = RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos)
; Binding : void* -> "sptr"
; ServerPrincName : LPSTR optional -> "str"
; AuthnLevel : DWORD -> "int"
; AuthnSvc : DWORD -> "int"
; AuthIdentity : void* optional -> "sptr"
; AuthzSvc : DWORD -> "int"
; SecurityQos : RPC_SECURITY_QOS* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS RpcBindingSetAuthInfoExA(void* Binding, LPSTR ServerPrincName, DWORD AuthnLevel, DWORD AuthnSvc, void* AuthIdentity, DWORD AuthzSvc, RPC_SECURITY_QOS* SecurityQos)
#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetAuthInfoExA "RpcBindingSetAuthInfoExA" intptr, str, int, int, intptr, int, var
; res = RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos)
; Binding : void* -> "intptr"
; ServerPrincName : LPSTR optional -> "str"
; 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")
	procRpcBindingSetAuthInfoExA = rpcrt4.NewProc("RpcBindingSetAuthInfoExA")
)

// Binding (void*), ServerPrincName (LPSTR optional), AuthnLevel (DWORD), AuthnSvc (DWORD), AuthIdentity (void* optional), AuthzSvc (DWORD), SecurityQos (RPC_SECURITY_QOS* optional)
r1, _, err := procRpcBindingSetAuthInfoExA.Call(
	uintptr(Binding),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(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 RpcBindingSetAuthInfoExA(
  Binding: Pointer;   // void*
  ServerPrincName: PAnsiChar;   // LPSTR 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 'RpcBindingSetAuthInfoExA';
result := DllCall("RPCRT4\RpcBindingSetAuthInfoExA"
    , "Ptr", Binding   ; void*
    , "AStr", ServerPrincName   ; LPSTR optional
    , "UInt", AuthnLevel   ; DWORD
    , "UInt", AuthnSvc   ; DWORD
    , "Ptr", AuthIdentity   ; void* optional
    , "UInt", AuthzSvc   ; DWORD
    , "Ptr", SecurityQos   ; RPC_SECURITY_QOS* optional
    , "Int")   ; return: RPC_STATUS
●RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos) = DLL("RPCRT4.dll", "int RpcBindingSetAuthInfoExA(void*, char*, dword, dword, void*, dword, void*)")
# 呼び出し: RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos)
# Binding : void* -> "void*"
# ServerPrincName : LPSTR 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)。