ホーム › Security.Authentication.Identity › SspiEncodeAuthIdentityAsStrings
SspiEncodeAuthIdentityAsStrings
関数認証情報構造体をユーザー名やドメイン名などの文字列に展開する。
シグネチャ
// SECUR32.dll
#include <windows.h>
HRESULT SspiEncodeAuthIdentityAsStrings(
void* pAuthIdentity,
LPCWSTR* ppszUserName,
LPCWSTR* ppszDomainName,
LPCWSTR* ppszPackedCredentialsString // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pAuthIdentity | void* | in |
| ppszUserName | LPCWSTR* | out |
| ppszDomainName | LPCWSTR* | out |
| ppszPackedCredentialsString | LPCWSTR* | outoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// SECUR32.dll
#include <windows.h>
HRESULT SspiEncodeAuthIdentityAsStrings(
void* pAuthIdentity,
LPCWSTR* ppszUserName,
LPCWSTR* ppszDomainName,
LPCWSTR* ppszPackedCredentialsString // optional
);[DllImport("SECUR32.dll", ExactSpelling = true)]
static extern int SspiEncodeAuthIdentityAsStrings(
IntPtr pAuthIdentity, // void*
IntPtr ppszUserName, // LPCWSTR* out
IntPtr ppszDomainName, // LPCWSTR* out
IntPtr ppszPackedCredentialsString // LPCWSTR* optional, out
);<DllImport("SECUR32.dll", ExactSpelling:=True)>
Public Shared Function SspiEncodeAuthIdentityAsStrings(
pAuthIdentity As IntPtr, ' void*
ppszUserName As IntPtr, ' LPCWSTR* out
ppszDomainName As IntPtr, ' LPCWSTR* out
ppszPackedCredentialsString As IntPtr ' LPCWSTR* optional, out
) As Integer
End Function' pAuthIdentity : void*
' ppszUserName : LPCWSTR* out
' ppszDomainName : LPCWSTR* out
' ppszPackedCredentialsString : LPCWSTR* optional, out
Declare PtrSafe Function SspiEncodeAuthIdentityAsStrings Lib "secur32" ( _
ByVal pAuthIdentity As LongPtr, _
ByVal ppszUserName As LongPtr, _
ByVal ppszDomainName As LongPtr, _
ByVal ppszPackedCredentialsString As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SspiEncodeAuthIdentityAsStrings = ctypes.windll.secur32.SspiEncodeAuthIdentityAsStrings
SspiEncodeAuthIdentityAsStrings.restype = ctypes.c_int
SspiEncodeAuthIdentityAsStrings.argtypes = [
ctypes.POINTER(None), # pAuthIdentity : void*
ctypes.c_void_p, # ppszUserName : LPCWSTR* out
ctypes.c_void_p, # ppszDomainName : LPCWSTR* out
ctypes.c_void_p, # ppszPackedCredentialsString : LPCWSTR* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SECUR32.dll')
SspiEncodeAuthIdentityAsStrings = Fiddle::Function.new(
lib['SspiEncodeAuthIdentityAsStrings'],
[
Fiddle::TYPE_VOIDP, # pAuthIdentity : void*
Fiddle::TYPE_VOIDP, # ppszUserName : LPCWSTR* out
Fiddle::TYPE_VOIDP, # ppszDomainName : LPCWSTR* out
Fiddle::TYPE_VOIDP, # ppszPackedCredentialsString : LPCWSTR* optional, out
],
Fiddle::TYPE_INT)#[link(name = "secur32")]
extern "system" {
fn SspiEncodeAuthIdentityAsStrings(
pAuthIdentity: *mut (), // void*
ppszUserName: *const *const u16, // LPCWSTR* out
ppszDomainName: *const *const u16, // LPCWSTR* out
ppszPackedCredentialsString: *const *const u16 // LPCWSTR* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SECUR32.dll")]
public static extern int SspiEncodeAuthIdentityAsStrings(IntPtr pAuthIdentity, IntPtr ppszUserName, IntPtr ppszDomainName, IntPtr ppszPackedCredentialsString);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_SspiEncodeAuthIdentityAsStrings' -Namespace Win32 -PassThru
# $api::SspiEncodeAuthIdentityAsStrings(pAuthIdentity, ppszUserName, ppszDomainName, ppszPackedCredentialsString)#uselib "SECUR32.dll"
#func global SspiEncodeAuthIdentityAsStrings "SspiEncodeAuthIdentityAsStrings" sptr, sptr, sptr, sptr
; SspiEncodeAuthIdentityAsStrings pAuthIdentity, varptr(ppszUserName), varptr(ppszDomainName), varptr(ppszPackedCredentialsString) ; 戻り値は stat
; pAuthIdentity : void* -> "sptr"
; ppszUserName : LPCWSTR* out -> "sptr"
; ppszDomainName : LPCWSTR* out -> "sptr"
; ppszPackedCredentialsString : LPCWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SECUR32.dll" #cfunc global SspiEncodeAuthIdentityAsStrings "SspiEncodeAuthIdentityAsStrings" sptr, var, var, var ; res = SspiEncodeAuthIdentityAsStrings(pAuthIdentity, ppszUserName, ppszDomainName, ppszPackedCredentialsString) ; pAuthIdentity : void* -> "sptr" ; ppszUserName : LPCWSTR* out -> "var" ; ppszDomainName : LPCWSTR* out -> "var" ; ppszPackedCredentialsString : LPCWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SECUR32.dll" #cfunc global SspiEncodeAuthIdentityAsStrings "SspiEncodeAuthIdentityAsStrings" sptr, sptr, sptr, sptr ; res = SspiEncodeAuthIdentityAsStrings(pAuthIdentity, varptr(ppszUserName), varptr(ppszDomainName), varptr(ppszPackedCredentialsString)) ; pAuthIdentity : void* -> "sptr" ; ppszUserName : LPCWSTR* out -> "sptr" ; ppszDomainName : LPCWSTR* out -> "sptr" ; ppszPackedCredentialsString : LPCWSTR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SspiEncodeAuthIdentityAsStrings(void* pAuthIdentity, LPCWSTR* ppszUserName, LPCWSTR* ppszDomainName, LPCWSTR* ppszPackedCredentialsString) #uselib "SECUR32.dll" #cfunc global SspiEncodeAuthIdentityAsStrings "SspiEncodeAuthIdentityAsStrings" intptr, var, var, var ; res = SspiEncodeAuthIdentityAsStrings(pAuthIdentity, ppszUserName, ppszDomainName, ppszPackedCredentialsString) ; pAuthIdentity : void* -> "intptr" ; ppszUserName : LPCWSTR* out -> "var" ; ppszDomainName : LPCWSTR* out -> "var" ; ppszPackedCredentialsString : LPCWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SspiEncodeAuthIdentityAsStrings(void* pAuthIdentity, LPCWSTR* ppszUserName, LPCWSTR* ppszDomainName, LPCWSTR* ppszPackedCredentialsString) #uselib "SECUR32.dll" #cfunc global SspiEncodeAuthIdentityAsStrings "SspiEncodeAuthIdentityAsStrings" intptr, intptr, intptr, intptr ; res = SspiEncodeAuthIdentityAsStrings(pAuthIdentity, varptr(ppszUserName), varptr(ppszDomainName), varptr(ppszPackedCredentialsString)) ; pAuthIdentity : void* -> "intptr" ; ppszUserName : LPCWSTR* out -> "intptr" ; ppszDomainName : LPCWSTR* out -> "intptr" ; ppszPackedCredentialsString : LPCWSTR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
secur32 = windows.NewLazySystemDLL("SECUR32.dll")
procSspiEncodeAuthIdentityAsStrings = secur32.NewProc("SspiEncodeAuthIdentityAsStrings")
)
// pAuthIdentity (void*), ppszUserName (LPCWSTR* out), ppszDomainName (LPCWSTR* out), ppszPackedCredentialsString (LPCWSTR* optional, out)
r1, _, err := procSspiEncodeAuthIdentityAsStrings.Call(
uintptr(pAuthIdentity),
uintptr(ppszUserName),
uintptr(ppszDomainName),
uintptr(ppszPackedCredentialsString),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SspiEncodeAuthIdentityAsStrings(
pAuthIdentity: Pointer; // void*
ppszUserName: PPWideChar; // LPCWSTR* out
ppszDomainName: PPWideChar; // LPCWSTR* out
ppszPackedCredentialsString: PPWideChar // LPCWSTR* optional, out
): Integer; stdcall;
external 'SECUR32.dll' name 'SspiEncodeAuthIdentityAsStrings';result := DllCall("SECUR32\SspiEncodeAuthIdentityAsStrings"
, "Ptr", pAuthIdentity ; void*
, "Ptr", ppszUserName ; LPCWSTR* out
, "Ptr", ppszDomainName ; LPCWSTR* out
, "Ptr", ppszPackedCredentialsString ; LPCWSTR* optional, out
, "Int") ; return: HRESULT●SspiEncodeAuthIdentityAsStrings(pAuthIdentity, ppszUserName, ppszDomainName, ppszPackedCredentialsString) = DLL("SECUR32.dll", "int SspiEncodeAuthIdentityAsStrings(void*, void*, void*, void*)")
# 呼び出し: SspiEncodeAuthIdentityAsStrings(pAuthIdentity, ppszUserName, ppszDomainName, ppszPackedCredentialsString)
# pAuthIdentity : void* -> "void*"
# ppszUserName : LPCWSTR* out -> "void*"
# ppszDomainName : LPCWSTR* out -> "void*"
# ppszPackedCredentialsString : LPCWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。