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

RpcBindingSetAuthInfoA

関数
バインディングに認証情報を設定する(ANSI版)。
DLLRPCRT4.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

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

パラメーター

名前方向説明
Bindingvoid*in認証情報を設定する対象のクライアントバインディングハンドル。
ServerPrincNameLPSTRinoptional期待するサーバープリンシパル名(ANSI)。相互認証に使用。NULL可。
AuthnLevelDWORDin適用する認証レベル(RPC_C_AUTHN_LEVEL_*)を指定する。
AuthnSvcDWORDin使用する認証サービス(RPC_C_AUTHN_*)を指定する。
AuthIdentityvoid*inoptional認証に用いる資格情報構造体へのポインタ。NULLで現在のログオンコンテキスト。
AuthzSvcDWORDin使用する認可サービス(RPC_C_AUTHZ_*)を指定する。

戻り値の型: RPC_STATUS

各言語での呼び出し定義

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

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

RpcBindingSetAuthInfoA = ctypes.windll.rpcrt4.RpcBindingSetAuthInfoA
RpcBindingSetAuthInfoA.restype = ctypes.c_int
RpcBindingSetAuthInfoA.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
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
RpcBindingSetAuthInfoA = Fiddle::Function.new(
  lib['RpcBindingSetAuthInfoA'],
  [
    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_INT)
#[link(name = "rpcrt4")]
extern "system" {
    fn RpcBindingSetAuthInfoA(
        Binding: *mut (),  // void*
        ServerPrincName: *mut u8,  // LPSTR 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.Ansi)]
public static extern int RpcBindingSetAuthInfoA(IntPtr Binding, [MarshalAs(UnmanagedType.LPStr)] string ServerPrincName, uint AuthnLevel, uint AuthnSvc, IntPtr AuthIdentity, uint AuthzSvc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcBindingSetAuthInfoA' -Namespace Win32 -PassThru
# $api::RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
#uselib "RPCRT4.dll"
#func global RpcBindingSetAuthInfoA "RpcBindingSetAuthInfoA" sptr, sptr, sptr, sptr, sptr, sptr
; RpcBindingSetAuthInfoA Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc   ; 戻り値は stat
; Binding : void* -> "sptr"
; ServerPrincName : LPSTR optional -> "sptr"
; AuthnLevel : DWORD -> "sptr"
; AuthnSvc : DWORD -> "sptr"
; AuthIdentity : void* optional -> "sptr"
; AuthzSvc : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetAuthInfoA "RpcBindingSetAuthInfoA" sptr, str, int, int, sptr, int
; res = RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
; Binding : void* -> "sptr"
; ServerPrincName : LPSTR optional -> "str"
; AuthnLevel : DWORD -> "int"
; AuthnSvc : DWORD -> "int"
; AuthIdentity : void* optional -> "sptr"
; AuthzSvc : DWORD -> "int"
; RPC_STATUS RpcBindingSetAuthInfoA(void* Binding, LPSTR ServerPrincName, DWORD AuthnLevel, DWORD AuthnSvc, void* AuthIdentity, DWORD AuthzSvc)
#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetAuthInfoA "RpcBindingSetAuthInfoA" intptr, str, int, int, intptr, int
; res = RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
; Binding : void* -> "intptr"
; ServerPrincName : LPSTR optional -> "str"
; 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")
	procRpcBindingSetAuthInfoA = rpcrt4.NewProc("RpcBindingSetAuthInfoA")
)

// Binding (void*), ServerPrincName (LPSTR optional), AuthnLevel (DWORD), AuthnSvc (DWORD), AuthIdentity (void* optional), AuthzSvc (DWORD)
r1, _, err := procRpcBindingSetAuthInfoA.Call(
	uintptr(Binding),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(ServerPrincName))),
	uintptr(AuthnLevel),
	uintptr(AuthnSvc),
	uintptr(AuthIdentity),
	uintptr(AuthzSvc),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcBindingSetAuthInfoA(
  Binding: Pointer;   // void*
  ServerPrincName: PAnsiChar;   // LPSTR optional
  AuthnLevel: DWORD;   // DWORD
  AuthnSvc: DWORD;   // DWORD
  AuthIdentity: Pointer;   // void* optional
  AuthzSvc: DWORD   // DWORD
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcBindingSetAuthInfoA';
result := DllCall("RPCRT4\RpcBindingSetAuthInfoA"
    , "Ptr", Binding   ; void*
    , "AStr", ServerPrincName   ; LPSTR optional
    , "UInt", AuthnLevel   ; DWORD
    , "UInt", AuthnSvc   ; DWORD
    , "Ptr", AuthIdentity   ; void* optional
    , "UInt", AuthzSvc   ; DWORD
    , "Int")   ; return: RPC_STATUS
●RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc) = DLL("RPCRT4.dll", "int RpcBindingSetAuthInfoA(void*, char*, dword, dword, void*, dword)")
# 呼び出し: RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
# Binding : void* -> "void*"
# ServerPrincName : LPSTR optional -> "char*"
# AuthnLevel : DWORD -> "dword"
# AuthnSvc : DWORD -> "dword"
# AuthIdentity : void* optional -> "void*"
# AuthzSvc : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "rpcrt4" fn RpcBindingSetAuthInfoA(
    Binding: ?*anyopaque, // void*
    ServerPrincName: [*c]const u8, // LPSTR optional
    AuthnLevel: u32, // DWORD
    AuthnSvc: u32, // DWORD
    AuthIdentity: ?*anyopaque, // void* optional
    AuthzSvc: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc RpcBindingSetAuthInfoA(
    Binding: pointer,  # void*
    ServerPrincName: cstring,  # LPSTR optional
    AuthnLevel: uint32,  # DWORD
    AuthnSvc: uint32,  # DWORD
    AuthIdentity: pointer,  # void* optional
    AuthzSvc: uint32  # DWORD
): int32 {.importc: "RpcBindingSetAuthInfoA", stdcall, dynlib: "RPCRT4.dll".}
pragma(lib, "rpcrt4");
extern(Windows)
int RpcBindingSetAuthInfoA(
    void* Binding,   // void*
    const(char)* ServerPrincName,   // LPSTR optional
    uint AuthnLevel,   // DWORD
    uint AuthnSvc,   // DWORD
    void* AuthIdentity,   // void* optional
    uint AuthzSvc   // DWORD
);
ccall((:RpcBindingSetAuthInfoA, "RPCRT4.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cstring, UInt32, UInt32, Ptr{Cvoid}, UInt32),
      Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
# Binding : void* -> Ptr{Cvoid}
# ServerPrincName : LPSTR optional -> Cstring
# AuthnLevel : DWORD -> UInt32
# AuthnSvc : DWORD -> UInt32
# AuthIdentity : void* optional -> Ptr{Cvoid}
# AuthzSvc : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t RpcBindingSetAuthInfoA(
    void* Binding,
    const char* ServerPrincName,
    uint32_t AuthnLevel,
    uint32_t AuthnSvc,
    void* AuthIdentity,
    uint32_t AuthzSvc);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
-- Binding : void*
-- ServerPrincName : LPSTR optional
-- AuthnLevel : DWORD
-- AuthnSvc : DWORD
-- AuthIdentity : void* optional
-- AuthzSvc : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcBindingSetAuthInfoA = lib.func('__stdcall', 'RpcBindingSetAuthInfoA', 'int32_t', ['void *', 'str', 'uint32_t', 'uint32_t', 'void *', 'uint32_t']);
// RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
// Binding : void* -> 'void *'
// ServerPrincName : LPSTR optional -> 'str'
// AuthnLevel : DWORD -> 'uint32_t'
// AuthnSvc : DWORD -> 'uint32_t'
// AuthIdentity : void* optional -> 'void *'
// AuthzSvc : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RPCRT4.dll", {
  RpcBindingSetAuthInfoA: { parameters: ["pointer", "buffer", "u32", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc)
// Binding : void* -> "pointer"
// ServerPrincName : LPSTR optional -> "buffer"
// AuthnLevel : DWORD -> "u32"
// AuthnSvc : DWORD -> "u32"
// AuthIdentity : void* optional -> "pointer"
// AuthzSvc : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RpcBindingSetAuthInfoA(
    void* Binding,
    const char* ServerPrincName,
    uint32_t AuthnLevel,
    uint32_t AuthnSvc,
    void* AuthIdentity,
    uint32_t AuthzSvc);
C, "RPCRT4.dll");
// $ffi->RpcBindingSetAuthInfoA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc);
// Binding : void*
// ServerPrincName : LPSTR optional
// AuthnLevel : DWORD
// AuthnSvc : DWORD
// AuthIdentity : void* optional
// AuthzSvc : DWORD
// 構造体/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 RpcBindingSetAuthInfoA(
        Pointer Binding,   // void*
        String ServerPrincName,   // LPSTR optional
        int AuthnLevel,   // DWORD
        int AuthnSvc,   // DWORD
        Pointer AuthIdentity,   // void* optional
        int AuthzSvc   // DWORD
    );
}
@[Link("rpcrt4")]
lib LibRPCRT4
  fun RpcBindingSetAuthInfoA = RpcBindingSetAuthInfoA(
    Binding : Void*,   # void*
    ServerPrincName : UInt8*,   # LPSTR optional
    AuthnLevel : UInt32,   # DWORD
    AuthnSvc : UInt32,   # DWORD
    AuthIdentity : Void*,   # void* optional
    AuthzSvc : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RpcBindingSetAuthInfoANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Uint32, Uint32, Pointer<Void>, Uint32);
typedef RpcBindingSetAuthInfoADart = int Function(Pointer<Void>, Pointer<Utf8>, int, int, Pointer<Void>, int);
final RpcBindingSetAuthInfoA = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<RpcBindingSetAuthInfoANative, RpcBindingSetAuthInfoADart>('RpcBindingSetAuthInfoA');
// Binding : void* -> Pointer<Void>
// ServerPrincName : LPSTR optional -> Pointer<Utf8>
// AuthnLevel : DWORD -> Uint32
// AuthnSvc : DWORD -> Uint32
// AuthIdentity : void* optional -> Pointer<Void>
// AuthzSvc : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RpcBindingSetAuthInfoA(
  Binding: Pointer;   // void*
  ServerPrincName: PAnsiChar;   // LPSTR optional
  AuthnLevel: DWORD;   // DWORD
  AuthnSvc: DWORD;   // DWORD
  AuthIdentity: Pointer;   // void* optional
  AuthzSvc: DWORD   // DWORD
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcBindingSetAuthInfoA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RpcBindingSetAuthInfoA"
  c_RpcBindingSetAuthInfoA :: Ptr () -> CString -> Word32 -> Word32 -> Ptr () -> Word32 -> IO Int32
-- Binding : void* -> Ptr ()
-- ServerPrincName : LPSTR optional -> CString
-- AuthnLevel : DWORD -> Word32
-- AuthnSvc : DWORD -> Word32
-- AuthIdentity : void* optional -> Ptr ()
-- AuthzSvc : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rpcbindingsetauthinfoa =
  foreign "RpcBindingSetAuthInfoA"
    ((ptr void) @-> string @-> uint32_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> 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 *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)

(cffi:defcfun ("RpcBindingSetAuthInfoA" rpc-binding-set-auth-info-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
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RpcBindingSetAuthInfoA = Win32::API::More->new('RPCRT4',
    'int RpcBindingSetAuthInfoA(LPVOID Binding, LPCSTR ServerPrincName, DWORD AuthnLevel, DWORD AuthnSvc, LPVOID AuthIdentity, DWORD AuthzSvc)');
# my $ret = $RpcBindingSetAuthInfoA->Call($Binding, $ServerPrincName, $AuthnLevel, $AuthnSvc, $AuthIdentity, $AuthzSvc);
# Binding : void* -> LPVOID
# ServerPrincName : LPSTR optional -> LPCSTR
# AuthnLevel : DWORD -> DWORD
# AuthnSvc : DWORD -> DWORD
# AuthIdentity : void* optional -> LPVOID
# AuthzSvc : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
類似 API
使用する型