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