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