RpcBindingSetAuthInfoExA
関数シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Binding | void* | in | 認証情報と承認情報の設定先となるサーバーバインディングハンドル。 |
| ServerPrincName | LPSTR | inoptional | Binding が参照するサーバーについて、想定されるプリンシパル名へのポインター。名前の内容とその構文は、使用する認証サービスによって定義されます。 メモ SSP に指定できるターゲット名の一覧については、InitializeSecurityContext のドキュメントにあるコメントを参照してください。
|
| AuthnLevel | DWORD | in | Binding を使用して行うリモートプロシージャコールに対して実行される認証のレベル。RPC がサポートする認証レベルの一覧については、 Authentication-Level Constants を参照してください。 |
| AuthnSvc | DWORD | in | 使用する認証サービス。 Binding を使用して行うリモートプロシージャコールの認証を無効にするには、RPC_C_AUTHN_NONE を指定します。 RPC_C_AUTHN_DEFAULT を指定した場合、RPC ランタイムライブラリは、Binding を使用して行うリモートプロシージャコールに RPC_C_AUTHN_WINNT 認証サービスを使用します。 |
| AuthIdentity | void* | inoptional | 選択した認証サービスおよび承認サービスに対応する、クライアントの認証資格情報と承認資格情報を格納する構造体のハンドル。 RPC_C_AUTHN_WINNT 認証サービスを使用する場合、AuthIdentity は SEC_WINNT_AUTH_IDENTITY 構造体 (Rpcdce.h で定義) へのポインターである必要があります。Kerberos および Negotiate 認証サービスも SEC_WINNT_AUTH_IDENTITY 構造体を使用します。 現在のアドレス空間のセキュリティログインコンテキストを使用するには、null 値を指定します。匿名のログインコンテキストを使用するには、値 RPC_C_NO_CREDENTIALS を渡します。RPC_C_NO_CREDENTIALS が有効なのは、認証サービスとして RPC_C_AUTHN_GSS_SCHANNEL を選択した場合のみである点に注意してください。 |
| AuthzSvc | DWORD | in | 対象のインターフェイスについてサーバーが実装している承認サービス。承認データの有効性と信頼性は、他のアプリケーションデータと同様に、選択した認証サービスと認証レベルに依存します。RPC_C_AUTHN_WINNT 認証サービスを使用する場合、このパラメーターは無視されます。メモを参照してください。 |
| SecurityQos | RPC_SECURITY_QOS* | inoptional | セキュリティのサービス品質を定義する RPC_SECURITY_QOS 構造体へのポインター。 メモ RPC がサポートする認証サービスの一覧については、
Authentication-Service Constants を参照してください。
|
戻り値の型: RPC_STATUS
公式ドキュメント
RpcBindingSetAuthInfoEx 関数は、バインディングハンドルに認証、承認、およびセキュリティのサービス品質 (quality of service) の情報を設定します。(ANSI)
戻り値
| 値 | 意味 |
|---|---|
| 呼び出しに成功しました。 | |
| バインディングハンドルが無効でした。 | |
| この操作に対して不適切な種類のバインディングでした。 | |
| 不明な認証サービスです。 |
解説(Remarks)
クライアントアプリケーションは、認証されたリモートプロシージャコールを行うためのサーバーバインディングハンドルを設定するために RpcBindingSetAuthInfoEx 関数を呼び出します。この関数は、バインディングハンドルにセキュリティのサービス品質情報を設定する機能を提供します。それ以外の点では RpcBindingSetAuthInfo と同一です。
クライアントが RpcBindingSetAuthInfoEx を呼び出さない限り、Binding 上のすべてのリモートプロシージャコールは認証されません。クライアントがこの関数を呼び出すことは必須ではありません。
RpcBindingSetAuthInfoEx 関数は資格情報のスナップショットを取得します。そのため、AuthIdentity パラメーターに割り当てたメモリは、バインディングハンドルよりも先に解放できます。ただし、アプリケーションが RpcBindingSetAuthInfoEx を RPC_C_QOS_IDENTITY_DYNAMIC と共に使用し、かつ AuthIdentity に NULL 以外の値を指定する場合は例外です。
Windows Server 2003 with SP1 および Windows XP with SP2: Windows XP SP2 および Windows Server 2003 SP1 では、AuthIdentity パラメーターへのポインターをバインディングハンドルの有効期間中保持する必要はありません。このポインターを保持する必要があるのは、その後に RpcBindingInqAuthInfo または RpcBindingInqAuthInfoEx を呼び出す場合だけです。
rpcdce.h ヘッダーは、UNICODE プリプロセッサ定数の定義に応じてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして RpcBindingSetAuthInfoEx を定義しています。エンコーディング非依存のエイリアスの使用と、エンコーディング非依存でないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーの原因になることがあります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 方式にも切替可。#uselib "RPCRT4.dll" #cfunc global RpcBindingSetAuthInfoExA "RpcBindingSetAuthInfoExA" sptr, str, int, int, sptr, int, sptr ; res = RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, varptr(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 -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr ; res = RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, varptr(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 -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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_STATUSfunction 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)。const std = @import("std");
extern "rpcrt4" fn RpcBindingSetAuthInfoExA(
Binding: ?*anyopaque, // void*
ServerPrincName: [*c]const u8, // LPSTR optional
AuthnLevel: u32, // DWORD
AuthnSvc: u32, // DWORD
AuthIdentity: ?*anyopaque, // void* optional
AuthzSvc: u32, // DWORD
SecurityQos: [*c]RPC_SECURITY_QOS // RPC_SECURITY_QOS* optional
) callconv(std.os.windows.WINAPI) i32;proc RpcBindingSetAuthInfoExA(
Binding: pointer, # void*
ServerPrincName: cstring, # LPSTR optional
AuthnLevel: uint32, # DWORD
AuthnSvc: uint32, # DWORD
AuthIdentity: pointer, # void* optional
AuthzSvc: uint32, # DWORD
SecurityQos: ptr RPC_SECURITY_QOS # RPC_SECURITY_QOS* optional
): int32 {.importc: "RpcBindingSetAuthInfoExA", stdcall, dynlib: "RPCRT4.dll".}pragma(lib, "rpcrt4");
extern(Windows)
int RpcBindingSetAuthInfoExA(
void* Binding, // void*
const(char)* ServerPrincName, // LPSTR optional
uint AuthnLevel, // DWORD
uint AuthnSvc, // DWORD
void* AuthIdentity, // void* optional
uint AuthzSvc, // DWORD
RPC_SECURITY_QOS* SecurityQos // RPC_SECURITY_QOS* optional
);ccall((:RpcBindingSetAuthInfoExA, "RPCRT4.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cstring, UInt32, UInt32, Ptr{Cvoid}, UInt32, Ptr{RPC_SECURITY_QOS}),
Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos)
# Binding : void* -> Ptr{Cvoid}
# ServerPrincName : LPSTR optional -> Cstring
# AuthnLevel : DWORD -> UInt32
# AuthnSvc : DWORD -> UInt32
# AuthIdentity : void* optional -> Ptr{Cvoid}
# AuthzSvc : DWORD -> UInt32
# SecurityQos : RPC_SECURITY_QOS* optional -> Ptr{RPC_SECURITY_QOS}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RpcBindingSetAuthInfoExA(
void* Binding,
const char* ServerPrincName,
uint32_t AuthnLevel,
uint32_t AuthnSvc,
void* AuthIdentity,
uint32_t AuthzSvc,
void* SecurityQos);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos)
-- Binding : void*
-- ServerPrincName : LPSTR optional
-- AuthnLevel : DWORD
-- AuthnSvc : DWORD
-- AuthIdentity : void* optional
-- AuthzSvc : DWORD
-- SecurityQos : RPC_SECURITY_QOS* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcBindingSetAuthInfoExA = lib.func('__stdcall', 'RpcBindingSetAuthInfoExA', 'int32_t', ['void *', 'str', 'uint32_t', 'uint32_t', 'void *', 'uint32_t', 'void *']);
// RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos)
// Binding : void* -> 'void *'
// ServerPrincName : LPSTR optional -> 'str'
// AuthnLevel : DWORD -> 'uint32_t'
// AuthnSvc : DWORD -> 'uint32_t'
// AuthIdentity : void* optional -> 'void *'
// AuthzSvc : DWORD -> 'uint32_t'
// SecurityQos : RPC_SECURITY_QOS* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RPCRT4.dll", {
RpcBindingSetAuthInfoExA: { parameters: ["pointer", "buffer", "u32", "u32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos)
// Binding : void* -> "pointer"
// ServerPrincName : LPSTR optional -> "buffer"
// AuthnLevel : DWORD -> "u32"
// AuthnSvc : DWORD -> "u32"
// AuthIdentity : void* optional -> "pointer"
// AuthzSvc : DWORD -> "u32"
// SecurityQos : RPC_SECURITY_QOS* optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RpcBindingSetAuthInfoExA(
void* Binding,
const char* ServerPrincName,
uint32_t AuthnLevel,
uint32_t AuthnSvc,
void* AuthIdentity,
uint32_t AuthzSvc,
void* SecurityQos);
C, "RPCRT4.dll");
// $ffi->RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, SecurityQos);
// Binding : void*
// ServerPrincName : LPSTR optional
// AuthnLevel : DWORD
// AuthnSvc : DWORD
// AuthIdentity : void* optional
// AuthzSvc : DWORD
// SecurityQos : RPC_SECURITY_QOS* optional
// 構造体/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 Rpcrt4 extends StdCallLibrary {
Rpcrt4 INSTANCE = Native.load("rpcrt4", Rpcrt4.class, W32APIOptions.ASCII_OPTIONS);
int RpcBindingSetAuthInfoExA(
Pointer Binding, // void*
String ServerPrincName, // LPSTR optional
int AuthnLevel, // DWORD
int AuthnSvc, // DWORD
Pointer AuthIdentity, // void* optional
int AuthzSvc, // DWORD
Pointer SecurityQos // RPC_SECURITY_QOS* optional
);
}@[Link("rpcrt4")]
lib LibRPCRT4
fun RpcBindingSetAuthInfoExA = RpcBindingSetAuthInfoExA(
Binding : Void*, # void*
ServerPrincName : UInt8*, # LPSTR optional
AuthnLevel : UInt32, # DWORD
AuthnSvc : UInt32, # DWORD
AuthIdentity : Void*, # void* optional
AuthzSvc : UInt32, # DWORD
SecurityQos : RPC_SECURITY_QOS* # RPC_SECURITY_QOS* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RpcBindingSetAuthInfoExANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Uint32, Uint32, Pointer<Void>, Uint32, Pointer<Void>);
typedef RpcBindingSetAuthInfoExADart = int Function(Pointer<Void>, Pointer<Utf8>, int, int, Pointer<Void>, int, Pointer<Void>);
final RpcBindingSetAuthInfoExA = DynamicLibrary.open('RPCRT4.dll')
.lookupFunction<RpcBindingSetAuthInfoExANative, RpcBindingSetAuthInfoExADart>('RpcBindingSetAuthInfoExA');
// Binding : void* -> Pointer<Void>
// ServerPrincName : LPSTR optional -> Pointer<Utf8>
// AuthnLevel : DWORD -> Uint32
// AuthnSvc : DWORD -> Uint32
// AuthIdentity : void* optional -> Pointer<Void>
// AuthzSvc : DWORD -> Uint32
// SecurityQos : RPC_SECURITY_QOS* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RpcBindingSetAuthInfoExA"
c_RpcBindingSetAuthInfoExA :: Ptr () -> CString -> Word32 -> Word32 -> Ptr () -> Word32 -> Ptr () -> IO Int32
-- Binding : void* -> Ptr ()
-- ServerPrincName : LPSTR optional -> CString
-- AuthnLevel : DWORD -> Word32
-- AuthnSvc : DWORD -> Word32
-- AuthIdentity : void* optional -> Ptr ()
-- AuthzSvc : DWORD -> Word32
-- SecurityQos : RPC_SECURITY_QOS* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rpcbindingsetauthinfoexa =
foreign "RpcBindingSetAuthInfoExA"
((ptr void) @-> string @-> uint32_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* Binding : void* -> (ptr void) *)
(* ServerPrincName : LPSTR optional -> string *)
(* AuthnLevel : DWORD -> uint32_t *)
(* AuthnSvc : DWORD -> uint32_t *)
(* AuthIdentity : void* optional -> (ptr void) *)
(* AuthzSvc : DWORD -> uint32_t *)
(* SecurityQos : RPC_SECURITY_QOS* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)
(cffi:defcfun ("RpcBindingSetAuthInfoExA" rpc-binding-set-auth-info-ex-a :convention :stdcall) :int32
(binding :pointer) ; void*
(server-princ-name :string) ; LPSTR optional
(authn-level :uint32) ; DWORD
(authn-svc :uint32) ; DWORD
(auth-identity :pointer) ; void* optional
(authz-svc :uint32) ; DWORD
(security-qos :pointer)) ; RPC_SECURITY_QOS* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RpcBindingSetAuthInfoExA = Win32::API::More->new('RPCRT4',
'int RpcBindingSetAuthInfoExA(LPVOID Binding, LPCSTR ServerPrincName, DWORD AuthnLevel, DWORD AuthnSvc, LPVOID AuthIdentity, DWORD AuthzSvc, LPVOID SecurityQos)');
# my $ret = $RpcBindingSetAuthInfoExA->Call($Binding, $ServerPrincName, $AuthnLevel, $AuthnSvc, $AuthIdentity, $AuthzSvc, $SecurityQos);
# Binding : void* -> LPVOID
# ServerPrincName : LPSTR optional -> LPCSTR
# AuthnLevel : DWORD -> DWORD
# AuthnSvc : DWORD -> DWORD
# AuthIdentity : void* optional -> LPVOID
# AuthzSvc : DWORD -> DWORD
# SecurityQos : RPC_SECURITY_QOS* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f RpcBindingSetAuthInfoExW (Unicode版) — RPCバインディングハンドルに認証・認可情報とセキュリティQOSを設定する(Unicode版)。
- f RpcBindingSetAuthInfoA — バインディングに認証情報を設定する(ANSI版)。
- f RpcBindingInqAuthInfoExA — RPCバインディングに設定された認証情報とセキュリティQOSを問い合わせる(ANSI版)。