Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WsCreateXmlSecurityToken

WsCreateXmlSecurityToken

関数
XMLバッファとキーからXMLセキュリティトークンを生成する。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WsCreateXmlSecurityToken(
    WS_XML_BUFFER* tokenXml,   // optional
    WS_SECURITY_KEY_HANDLE* tokenKey,   // optional
    const WS_XML_SECURITY_TOKEN_PROPERTY* properties,   // optional
    DWORD propertyCount,
    WS_SECURITY_TOKEN** token,
    WS_ERROR* error   // optional
);

パラメーター

名前方向
tokenXmlWS_XML_BUFFER*inoptional
tokenKeyWS_SECURITY_KEY_HANDLE*inoptional
propertiesWS_XML_SECURITY_TOKEN_PROPERTY*inoptional
propertyCountDWORDin
tokenWS_SECURITY_TOKEN**out
errorWS_ERROR*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsCreateXmlSecurityToken(
    WS_XML_BUFFER* tokenXml,   // optional
    WS_SECURITY_KEY_HANDLE* tokenKey,   // optional
    const WS_XML_SECURITY_TOKEN_PROPERTY* properties,   // optional
    DWORD propertyCount,
    WS_SECURITY_TOKEN** token,
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsCreateXmlSecurityToken(
    IntPtr tokenXml,   // WS_XML_BUFFER* optional
    IntPtr tokenKey,   // WS_SECURITY_KEY_HANDLE* optional
    IntPtr properties,   // WS_XML_SECURITY_TOKEN_PROPERTY* optional
    uint propertyCount,   // DWORD
    IntPtr token,   // WS_SECURITY_TOKEN** out
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsCreateXmlSecurityToken(
    tokenXml As IntPtr,   ' WS_XML_BUFFER* optional
    tokenKey As IntPtr,   ' WS_SECURITY_KEY_HANDLE* optional
    properties As IntPtr,   ' WS_XML_SECURITY_TOKEN_PROPERTY* optional
    propertyCount As UInteger,   ' DWORD
    token As IntPtr,   ' WS_SECURITY_TOKEN** out
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' tokenXml : WS_XML_BUFFER* optional
' tokenKey : WS_SECURITY_KEY_HANDLE* optional
' properties : WS_XML_SECURITY_TOKEN_PROPERTY* optional
' propertyCount : DWORD
' token : WS_SECURITY_TOKEN** out
' error : WS_ERROR* optional
Declare PtrSafe Function WsCreateXmlSecurityToken Lib "webservices" ( _
    ByVal tokenXml As LongPtr, _
    ByVal tokenKey As LongPtr, _
    ByVal properties As LongPtr, _
    ByVal propertyCount As Long, _
    ByVal token As LongPtr, _
    ByVal error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WsCreateXmlSecurityToken = ctypes.windll.webservices.WsCreateXmlSecurityToken
WsCreateXmlSecurityToken.restype = ctypes.c_int
WsCreateXmlSecurityToken.argtypes = [
    ctypes.c_void_p,  # tokenXml : WS_XML_BUFFER* optional
    ctypes.c_void_p,  # tokenKey : WS_SECURITY_KEY_HANDLE* optional
    ctypes.c_void_p,  # properties : WS_XML_SECURITY_TOKEN_PROPERTY* optional
    wintypes.DWORD,  # propertyCount : DWORD
    ctypes.c_void_p,  # token : WS_SECURITY_TOKEN** out
    ctypes.c_void_p,  # error : WS_ERROR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webservices.dll')
WsCreateXmlSecurityToken = Fiddle::Function.new(
  lib['WsCreateXmlSecurityToken'],
  [
    Fiddle::TYPE_VOIDP,  # tokenXml : WS_XML_BUFFER* optional
    Fiddle::TYPE_VOIDP,  # tokenKey : WS_SECURITY_KEY_HANDLE* optional
    Fiddle::TYPE_VOIDP,  # properties : WS_XML_SECURITY_TOKEN_PROPERTY* optional
    -Fiddle::TYPE_INT,  # propertyCount : DWORD
    Fiddle::TYPE_VOIDP,  # token : WS_SECURITY_TOKEN** out
    Fiddle::TYPE_VOIDP,  # error : WS_ERROR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "webservices")]
extern "system" {
    fn WsCreateXmlSecurityToken(
        tokenXml: *mut isize,  // WS_XML_BUFFER* optional
        tokenKey: *mut WS_SECURITY_KEY_HANDLE,  // WS_SECURITY_KEY_HANDLE* optional
        properties: *const WS_XML_SECURITY_TOKEN_PROPERTY,  // WS_XML_SECURITY_TOKEN_PROPERTY* optional
        propertyCount: u32,  // DWORD
        token: *mut *mut isize,  // WS_SECURITY_TOKEN** out
        error: *mut isize  // WS_ERROR* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("webservices.dll")]
public static extern int WsCreateXmlSecurityToken(IntPtr tokenXml, IntPtr tokenKey, IntPtr properties, uint propertyCount, IntPtr token, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsCreateXmlSecurityToken' -Namespace Win32 -PassThru
# $api::WsCreateXmlSecurityToken(tokenXml, tokenKey, properties, propertyCount, token, error)
#uselib "webservices.dll"
#func global WsCreateXmlSecurityToken "WsCreateXmlSecurityToken" sptr, sptr, sptr, sptr, sptr, sptr
; WsCreateXmlSecurityToken tokenXml, varptr(tokenKey), varptr(properties), propertyCount, token, error   ; 戻り値は stat
; tokenXml : WS_XML_BUFFER* optional -> "sptr"
; tokenKey : WS_SECURITY_KEY_HANDLE* optional -> "sptr"
; properties : WS_XML_SECURITY_TOKEN_PROPERTY* optional -> "sptr"
; propertyCount : DWORD -> "sptr"
; token : WS_SECURITY_TOKEN** out -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "webservices.dll"
#cfunc global WsCreateXmlSecurityToken "WsCreateXmlSecurityToken" int, var, var, int, int, int
; res = WsCreateXmlSecurityToken(tokenXml, tokenKey, properties, propertyCount, token, error)
; tokenXml : WS_XML_BUFFER* optional -> "int"
; tokenKey : WS_SECURITY_KEY_HANDLE* optional -> "var"
; properties : WS_XML_SECURITY_TOKEN_PROPERTY* optional -> "var"
; propertyCount : DWORD -> "int"
; token : WS_SECURITY_TOKEN** out -> "int"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WsCreateXmlSecurityToken(WS_XML_BUFFER* tokenXml, WS_SECURITY_KEY_HANDLE* tokenKey, WS_XML_SECURITY_TOKEN_PROPERTY* properties, DWORD propertyCount, WS_SECURITY_TOKEN** token, WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsCreateXmlSecurityToken "WsCreateXmlSecurityToken" int, var, var, int, int, int
; res = WsCreateXmlSecurityToken(tokenXml, tokenKey, properties, propertyCount, token, error)
; tokenXml : WS_XML_BUFFER* optional -> "int"
; tokenKey : WS_SECURITY_KEY_HANDLE* optional -> "var"
; properties : WS_XML_SECURITY_TOKEN_PROPERTY* optional -> "var"
; propertyCount : DWORD -> "int"
; token : WS_SECURITY_TOKEN** out -> "int"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsCreateXmlSecurityToken = webservices.NewProc("WsCreateXmlSecurityToken")
)

// tokenXml (WS_XML_BUFFER* optional), tokenKey (WS_SECURITY_KEY_HANDLE* optional), properties (WS_XML_SECURITY_TOKEN_PROPERTY* optional), propertyCount (DWORD), token (WS_SECURITY_TOKEN** out), error (WS_ERROR* optional)
r1, _, err := procWsCreateXmlSecurityToken.Call(
	uintptr(tokenXml),
	uintptr(tokenKey),
	uintptr(properties),
	uintptr(propertyCount),
	uintptr(token),
	uintptr(error),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WsCreateXmlSecurityToken(
  tokenXml: Pointer;   // WS_XML_BUFFER* optional
  tokenKey: Pointer;   // WS_SECURITY_KEY_HANDLE* optional
  properties: Pointer;   // WS_XML_SECURITY_TOKEN_PROPERTY* optional
  propertyCount: DWORD;   // DWORD
  token: Pointer;   // WS_SECURITY_TOKEN** out
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsCreateXmlSecurityToken';
result := DllCall("webservices\WsCreateXmlSecurityToken"
    , "Ptr", tokenXml   ; WS_XML_BUFFER* optional
    , "Ptr", tokenKey   ; WS_SECURITY_KEY_HANDLE* optional
    , "Ptr", properties   ; WS_XML_SECURITY_TOKEN_PROPERTY* optional
    , "UInt", propertyCount   ; DWORD
    , "Ptr", token   ; WS_SECURITY_TOKEN** out
    , "Ptr", error   ; WS_ERROR* optional
    , "Int")   ; return: HRESULT
●WsCreateXmlSecurityToken(tokenXml, tokenKey, properties, propertyCount, token, error) = DLL("webservices.dll", "int WsCreateXmlSecurityToken(void*, void*, void*, dword, void*, void*)")
# 呼び出し: WsCreateXmlSecurityToken(tokenXml, tokenKey, properties, propertyCount, token, error)
# tokenXml : WS_XML_BUFFER* optional -> "void*"
# tokenKey : WS_SECURITY_KEY_HANDLE* optional -> "void*"
# properties : WS_XML_SECURITY_TOKEN_PROPERTY* optional -> "void*"
# propertyCount : DWORD -> "dword"
# token : WS_SECURITY_TOKEN** out -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。