Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › SspiUnmarshalAuthIdentity

SspiUnmarshalAuthIdentity

関数
マーシャリング済みバイト配列からSSPI認証アイデンティティ構造体を復元する。
DLLSECUR32.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

// SECUR32.dll
#include <windows.h>

HRESULT SspiUnmarshalAuthIdentity(
    DWORD AuthIdentityLength,
    LPSTR AuthIdentityByteArray,
    void** ppAuthIdentity
);

パラメーター

名前方向
AuthIdentityLengthDWORDin
AuthIdentityByteArrayLPSTRin
ppAuthIdentityvoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

// SECUR32.dll
#include <windows.h>

HRESULT SspiUnmarshalAuthIdentity(
    DWORD AuthIdentityLength,
    LPSTR AuthIdentityByteArray,
    void** ppAuthIdentity
);
[DllImport("SECUR32.dll", ExactSpelling = true)]
static extern int SspiUnmarshalAuthIdentity(
    uint AuthIdentityLength,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string AuthIdentityByteArray,   // LPSTR
    IntPtr ppAuthIdentity   // void** out
);
<DllImport("SECUR32.dll", ExactSpelling:=True)>
Public Shared Function SspiUnmarshalAuthIdentity(
    AuthIdentityLength As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> AuthIdentityByteArray As String,   ' LPSTR
    ppAuthIdentity As IntPtr   ' void** out
) As Integer
End Function
' AuthIdentityLength : DWORD
' AuthIdentityByteArray : LPSTR
' ppAuthIdentity : void** out
Declare PtrSafe Function SspiUnmarshalAuthIdentity Lib "secur32" ( _
    ByVal AuthIdentityLength As Long, _
    ByVal AuthIdentityByteArray As String, _
    ByVal ppAuthIdentity As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SspiUnmarshalAuthIdentity = ctypes.windll.secur32.SspiUnmarshalAuthIdentity
SspiUnmarshalAuthIdentity.restype = ctypes.c_int
SspiUnmarshalAuthIdentity.argtypes = [
    wintypes.DWORD,  # AuthIdentityLength : DWORD
    wintypes.LPCSTR,  # AuthIdentityByteArray : LPSTR
    ctypes.c_void_p,  # ppAuthIdentity : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SECUR32.dll')
SspiUnmarshalAuthIdentity = Fiddle::Function.new(
  lib['SspiUnmarshalAuthIdentity'],
  [
    -Fiddle::TYPE_INT,  # AuthIdentityLength : DWORD
    Fiddle::TYPE_VOIDP,  # AuthIdentityByteArray : LPSTR
    Fiddle::TYPE_VOIDP,  # ppAuthIdentity : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "secur32")]
extern "system" {
    fn SspiUnmarshalAuthIdentity(
        AuthIdentityLength: u32,  // DWORD
        AuthIdentityByteArray: *mut u8,  // LPSTR
        ppAuthIdentity: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SECUR32.dll")]
public static extern int SspiUnmarshalAuthIdentity(uint AuthIdentityLength, [MarshalAs(UnmanagedType.LPStr)] string AuthIdentityByteArray, IntPtr ppAuthIdentity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_SspiUnmarshalAuthIdentity' -Namespace Win32 -PassThru
# $api::SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
#uselib "SECUR32.dll"
#func global SspiUnmarshalAuthIdentity "SspiUnmarshalAuthIdentity" sptr, sptr, sptr
; SspiUnmarshalAuthIdentity AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity   ; 戻り値は stat
; AuthIdentityLength : DWORD -> "sptr"
; AuthIdentityByteArray : LPSTR -> "sptr"
; ppAuthIdentity : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SECUR32.dll"
#cfunc global SspiUnmarshalAuthIdentity "SspiUnmarshalAuthIdentity" int, str, sptr
; res = SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
; AuthIdentityLength : DWORD -> "int"
; AuthIdentityByteArray : LPSTR -> "str"
; ppAuthIdentity : void** out -> "sptr"
; HRESULT SspiUnmarshalAuthIdentity(DWORD AuthIdentityLength, LPSTR AuthIdentityByteArray, void** ppAuthIdentity)
#uselib "SECUR32.dll"
#cfunc global SspiUnmarshalAuthIdentity "SspiUnmarshalAuthIdentity" int, str, intptr
; res = SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
; AuthIdentityLength : DWORD -> "int"
; AuthIdentityByteArray : LPSTR -> "str"
; ppAuthIdentity : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	secur32 = windows.NewLazySystemDLL("SECUR32.dll")
	procSspiUnmarshalAuthIdentity = secur32.NewProc("SspiUnmarshalAuthIdentity")
)

// AuthIdentityLength (DWORD), AuthIdentityByteArray (LPSTR), ppAuthIdentity (void** out)
r1, _, err := procSspiUnmarshalAuthIdentity.Call(
	uintptr(AuthIdentityLength),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(AuthIdentityByteArray))),
	uintptr(ppAuthIdentity),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SspiUnmarshalAuthIdentity(
  AuthIdentityLength: DWORD;   // DWORD
  AuthIdentityByteArray: PAnsiChar;   // LPSTR
  ppAuthIdentity: Pointer   // void** out
): Integer; stdcall;
  external 'SECUR32.dll' name 'SspiUnmarshalAuthIdentity';
result := DllCall("SECUR32\SspiUnmarshalAuthIdentity"
    , "UInt", AuthIdentityLength   ; DWORD
    , "AStr", AuthIdentityByteArray   ; LPSTR
    , "Ptr", ppAuthIdentity   ; void** out
    , "Int")   ; return: HRESULT
●SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity) = DLL("SECUR32.dll", "int SspiUnmarshalAuthIdentity(dword, char*, void*)")
# 呼び出し: SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
# AuthIdentityLength : DWORD -> "dword"
# AuthIdentityByteArray : LPSTR -> "char*"
# ppAuthIdentity : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。