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

KERB_QUERY_TKT_CACHE_EX3_RESPONSE

構造体
サイズx64: 136 バイト / x86: 96 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
MessageTypeKERB_PROTOCOL_MESSAGE_TYPE4+0+0Kerberosプロトコルメッセージ種別を示す列挙値。
CountOfTicketsDWORD4+4+4Tickets配列に含まれるチケット数。
TicketsKERB_TICKET_CACHE_INFO_EX3128/88+8+8キャッシュ内チケット情報(拡張3)の配列(可変長)。

各言語での定義

#include <windows.h>

// LSA_UNICODE_STRING  (x64 16 / x86 8 バイト)
typedef struct LSA_UNICODE_STRING {
    WORD Length;
    WORD MaximumLength;
    LPWSTR Buffer;
} LSA_UNICODE_STRING;

// KERB_TICKET_CACHE_INFO_EX3  (x64 128 / x86 88 バイト)
typedef struct KERB_TICKET_CACHE_INFO_EX3 {
    LSA_UNICODE_STRING ClientName;
    LSA_UNICODE_STRING ClientRealm;
    LSA_UNICODE_STRING ServerName;
    LSA_UNICODE_STRING ServerRealm;
    LONGLONG StartTime;
    LONGLONG EndTime;
    LONGLONG RenewTime;
    INT EncryptionType;
    DWORD TicketFlags;
    DWORD SessionKeyType;
    DWORD BranchId;
    DWORD CacheFlags;
    LSA_UNICODE_STRING KdcCalled;
} KERB_TICKET_CACHE_INFO_EX3;

// KERB_QUERY_TKT_CACHE_EX3_RESPONSE  (x64 136 / x86 96 バイト)
typedef struct KERB_QUERY_TKT_CACHE_EX3_RESPONSE {
    KERB_PROTOCOL_MESSAGE_TYPE MessageType;
    DWORD CountOfTickets;
    KERB_TICKET_CACHE_INFO_EX3 Tickets[1];
} KERB_QUERY_TKT_CACHE_EX3_RESPONSE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LSA_UNICODE_STRING
{
    public ushort Length;
    public ushort MaximumLength;
    public IntPtr Buffer;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KERB_TICKET_CACHE_INFO_EX3
{
    public LSA_UNICODE_STRING ClientName;
    public LSA_UNICODE_STRING ClientRealm;
    public LSA_UNICODE_STRING ServerName;
    public LSA_UNICODE_STRING ServerRealm;
    public long StartTime;
    public long EndTime;
    public long RenewTime;
    public int EncryptionType;
    public uint TicketFlags;
    public uint SessionKeyType;
    public uint BranchId;
    public uint CacheFlags;
    public LSA_UNICODE_STRING KdcCalled;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KERB_QUERY_TKT_CACHE_EX3_RESPONSE
{
    public int MessageType;
    public uint CountOfTickets;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public KERB_TICKET_CACHE_INFO_EX3[] Tickets;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LSA_UNICODE_STRING
    Public Length As UShort
    Public MaximumLength As UShort
    Public Buffer As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KERB_TICKET_CACHE_INFO_EX3
    Public ClientName As LSA_UNICODE_STRING
    Public ClientRealm As LSA_UNICODE_STRING
    Public ServerName As LSA_UNICODE_STRING
    Public ServerRealm As LSA_UNICODE_STRING
    Public StartTime As Long
    Public EndTime As Long
    Public RenewTime As Long
    Public EncryptionType As Integer
    Public TicketFlags As UInteger
    Public SessionKeyType As UInteger
    Public BranchId As UInteger
    Public CacheFlags As UInteger
    Public KdcCalled As LSA_UNICODE_STRING
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KERB_QUERY_TKT_CACHE_EX3_RESPONSE
    Public MessageType As Integer
    Public CountOfTickets As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Tickets() As KERB_TICKET_CACHE_INFO_EX3
End Structure
import ctypes
from ctypes import wintypes

class LSA_UNICODE_STRING(ctypes.Structure):
    _fields_ = [
        ("Length", ctypes.c_ushort),
        ("MaximumLength", ctypes.c_ushort),
        ("Buffer", ctypes.c_void_p),
    ]

class KERB_TICKET_CACHE_INFO_EX3(ctypes.Structure):
    _fields_ = [
        ("ClientName", LSA_UNICODE_STRING),
        ("ClientRealm", LSA_UNICODE_STRING),
        ("ServerName", LSA_UNICODE_STRING),
        ("ServerRealm", LSA_UNICODE_STRING),
        ("StartTime", ctypes.c_longlong),
        ("EndTime", ctypes.c_longlong),
        ("RenewTime", ctypes.c_longlong),
        ("EncryptionType", ctypes.c_int),
        ("TicketFlags", wintypes.DWORD),
        ("SessionKeyType", wintypes.DWORD),
        ("BranchId", wintypes.DWORD),
        ("CacheFlags", wintypes.DWORD),
        ("KdcCalled", LSA_UNICODE_STRING),
    ]

class KERB_QUERY_TKT_CACHE_EX3_RESPONSE(ctypes.Structure):
    _fields_ = [
        ("MessageType", ctypes.c_int),
        ("CountOfTickets", wintypes.DWORD),
        ("Tickets", KERB_TICKET_CACHE_INFO_EX3 * 1),
    ]
#[repr(C)]
pub struct LSA_UNICODE_STRING {
    pub Length: u16,
    pub MaximumLength: u16,
    pub Buffer: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct KERB_TICKET_CACHE_INFO_EX3 {
    pub ClientName: LSA_UNICODE_STRING,
    pub ClientRealm: LSA_UNICODE_STRING,
    pub ServerName: LSA_UNICODE_STRING,
    pub ServerRealm: LSA_UNICODE_STRING,
    pub StartTime: i64,
    pub EndTime: i64,
    pub RenewTime: i64,
    pub EncryptionType: i32,
    pub TicketFlags: u32,
    pub SessionKeyType: u32,
    pub BranchId: u32,
    pub CacheFlags: u32,
    pub KdcCalled: LSA_UNICODE_STRING,
}

#[repr(C)]
pub struct KERB_QUERY_TKT_CACHE_EX3_RESPONSE {
    pub MessageType: i32,
    pub CountOfTickets: u32,
    pub Tickets: [KERB_TICKET_CACHE_INFO_EX3; 1],
}
import "golang.org/x/sys/windows"

type LSA_UNICODE_STRING struct {
	Length uint16
	MaximumLength uint16
	Buffer uintptr
}

type KERB_TICKET_CACHE_INFO_EX3 struct {
	ClientName LSA_UNICODE_STRING
	ClientRealm LSA_UNICODE_STRING
	ServerName LSA_UNICODE_STRING
	ServerRealm LSA_UNICODE_STRING
	StartTime int64
	EndTime int64
	RenewTime int64
	EncryptionType int32
	TicketFlags uint32
	SessionKeyType uint32
	BranchId uint32
	CacheFlags uint32
	KdcCalled LSA_UNICODE_STRING
}

type KERB_QUERY_TKT_CACHE_EX3_RESPONSE struct {
	MessageType int32
	CountOfTickets uint32
	Tickets [1]KERB_TICKET_CACHE_INFO_EX3
}
type
  LSA_UNICODE_STRING = record
    Length: Word;
    MaximumLength: Word;
    Buffer: Pointer;
  end;

  KERB_TICKET_CACHE_INFO_EX3 = record
    ClientName: LSA_UNICODE_STRING;
    ClientRealm: LSA_UNICODE_STRING;
    ServerName: LSA_UNICODE_STRING;
    ServerRealm: LSA_UNICODE_STRING;
    StartTime: Int64;
    EndTime: Int64;
    RenewTime: Int64;
    EncryptionType: Integer;
    TicketFlags: DWORD;
    SessionKeyType: DWORD;
    BranchId: DWORD;
    CacheFlags: DWORD;
    KdcCalled: LSA_UNICODE_STRING;
  end;

  KERB_QUERY_TKT_CACHE_EX3_RESPONSE = record
    MessageType: Integer;
    CountOfTickets: DWORD;
    Tickets: array[0..0] of KERB_TICKET_CACHE_INFO_EX3;
  end;
const LSA_UNICODE_STRING = extern struct {
    Length: u16,
    MaximumLength: u16,
    Buffer: ?*anyopaque,
};

const KERB_TICKET_CACHE_INFO_EX3 = extern struct {
    ClientName: LSA_UNICODE_STRING,
    ClientRealm: LSA_UNICODE_STRING,
    ServerName: LSA_UNICODE_STRING,
    ServerRealm: LSA_UNICODE_STRING,
    StartTime: i64,
    EndTime: i64,
    RenewTime: i64,
    EncryptionType: i32,
    TicketFlags: u32,
    SessionKeyType: u32,
    BranchId: u32,
    CacheFlags: u32,
    KdcCalled: LSA_UNICODE_STRING,
};

const KERB_QUERY_TKT_CACHE_EX3_RESPONSE = extern struct {
    MessageType: i32,
    CountOfTickets: u32,
    Tickets: [1]KERB_TICKET_CACHE_INFO_EX3,
};
type
  LSA_UNICODE_STRING {.bycopy.} = object
    Length: uint16
    MaximumLength: uint16
    Buffer: pointer

  KERB_TICKET_CACHE_INFO_EX3 {.bycopy.} = object
    ClientName: LSA_UNICODE_STRING
    ClientRealm: LSA_UNICODE_STRING
    ServerName: LSA_UNICODE_STRING
    ServerRealm: LSA_UNICODE_STRING
    StartTime: int64
    EndTime: int64
    RenewTime: int64
    EncryptionType: int32
    TicketFlags: uint32
    SessionKeyType: uint32
    BranchId: uint32
    CacheFlags: uint32
    KdcCalled: LSA_UNICODE_STRING

  KERB_QUERY_TKT_CACHE_EX3_RESPONSE {.bycopy.} = object
    MessageType: int32
    CountOfTickets: uint32
    Tickets: array[1, KERB_TICKET_CACHE_INFO_EX3]
struct LSA_UNICODE_STRING
{
    ushort Length;
    ushort MaximumLength;
    void* Buffer;
}

struct KERB_TICKET_CACHE_INFO_EX3
{
    LSA_UNICODE_STRING ClientName;
    LSA_UNICODE_STRING ClientRealm;
    LSA_UNICODE_STRING ServerName;
    LSA_UNICODE_STRING ServerRealm;
    long StartTime;
    long EndTime;
    long RenewTime;
    int EncryptionType;
    uint TicketFlags;
    uint SessionKeyType;
    uint BranchId;
    uint CacheFlags;
    LSA_UNICODE_STRING KdcCalled;
}

struct KERB_QUERY_TKT_CACHE_EX3_RESPONSE
{
    int MessageType;
    uint CountOfTickets;
    KERB_TICKET_CACHE_INFO_EX3[1] Tickets;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; KERB_QUERY_TKT_CACHE_EX3_RESPONSE サイズ: 96 バイト(x86)
dim st, 24    ; 4byte整数×24(構造体サイズ 96 / 4 切り上げ)
; MessageType : KERB_PROTOCOL_MESSAGE_TYPE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; CountOfTickets : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Tickets : KERB_TICKET_CACHE_INFO_EX3 (+8, 88byte)  varptr(st)+8 を基点に操作(88byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; KERB_QUERY_TKT_CACHE_EX3_RESPONSE サイズ: 136 バイト(x64)
dim st, 34    ; 4byte整数×34(構造体サイズ 136 / 4 切り上げ)
; MessageType : KERB_PROTOCOL_MESSAGE_TYPE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; CountOfTickets : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Tickets : KERB_TICKET_CACHE_INFO_EX3 (+8, 128byte)  varptr(st)+8 を基点に操作(128byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global LSA_UNICODE_STRING
    #field short Length
    #field short MaximumLength
    #field intptr Buffer
#endstruct

#defstruct global KERB_TICKET_CACHE_INFO_EX3
    #field LSA_UNICODE_STRING ClientName
    #field LSA_UNICODE_STRING ClientRealm
    #field LSA_UNICODE_STRING ServerName
    #field LSA_UNICODE_STRING ServerRealm
    #field int64 StartTime
    #field int64 EndTime
    #field int64 RenewTime
    #field int EncryptionType
    #field int TicketFlags
    #field int SessionKeyType
    #field int BranchId
    #field int CacheFlags
    #field LSA_UNICODE_STRING KdcCalled
#endstruct

#defstruct global KERB_QUERY_TKT_CACHE_EX3_RESPONSE
    #field int MessageType
    #field int CountOfTickets
    #field KERB_TICKET_CACHE_INFO_EX3 Tickets 1
#endstruct

stdim st, KERB_QUERY_TKT_CACHE_EX3_RESPONSE        ; NSTRUCT 変数を確保
st->MessageType = 100
mes "MessageType=" + st->MessageType