JwaNtSecApi.pas
上传用户:davidchvip
上传日期:2009-07-28
资源大小:1749k
文件大小:146k
源码类别:

Windows编程

开发平台:

Delphi

  1.   MSV1_0_DONT_TRY_GUEST_ACCOUNT     = $10;
  2.   {$EXTERNALSYM MSV1_0_DONT_TRY_GUEST_ACCOUNT}
  3.   MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT = $20;
  4.   {$EXTERNALSYM MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT}
  5.   MSV1_0_RETURN_PASSWORD_EXPIRY     = $40;
  6.   {$EXTERNALSYM MSV1_0_RETURN_PASSWORD_EXPIRY}
  7. // this next flag says that CaseInsensitiveChallengeResponse
  8. //  (aka LmResponse) contains a client challenge in the first 8 bytes
  9.   MSV1_0_USE_CLIENT_CHALLENGE            = $80;
  10.   {$EXTERNALSYM MSV1_0_USE_CLIENT_CHALLENGE}
  11.   MSV1_0_TRY_GUEST_ACCOUNT_ONLY          = $100;
  12.   {$EXTERNALSYM MSV1_0_TRY_GUEST_ACCOUNT_ONLY}
  13.   MSV1_0_RETURN_PROFILE_PATH             = $200;
  14.   {$EXTERNALSYM MSV1_0_RETURN_PROFILE_PATH}
  15.   MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY       = $400;
  16.   {$EXTERNALSYM MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY}
  17.   MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT = $800;
  18.   {$EXTERNALSYM MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT}
  19.   MSV1_0_DISABLE_PERSONAL_FALLBACK       = $00001000;
  20.   {$EXTERNALSYM MSV1_0_DISABLE_PERSONAL_FALLBACK}
  21.   MSV1_0_ALLOW_FORCE_GUEST          = $00002000;
  22.   {$EXTERNALSYM MSV1_0_ALLOW_FORCE_GUEST}
  23.   MSV1_0_CLEARTEXT_PASSWORD_SUPPLIED     = $00004000;
  24.   {$EXTERNALSYM MSV1_0_CLEARTEXT_PASSWORD_SUPPLIED}
  25.   MSV1_0_SUBAUTHENTICATION_DLL_EX        = $00100000;
  26.   {$EXTERNALSYM MSV1_0_SUBAUTHENTICATION_DLL_EX}
  27. //
  28. // The high order byte is a value indicating the SubAuthentication DLL.
  29. //  Zero indicates no SubAuthentication DLL.
  30. //
  31.   MSV1_0_SUBAUTHENTICATION_DLL       = DWORD($FF000000);
  32.   {$EXTERNALSYM MSV1_0_SUBAUTHENTICATION_DLL}
  33.   MSV1_0_SUBAUTHENTICATION_DLL_SHIFT = 24;
  34.   {$EXTERNALSYM MSV1_0_SUBAUTHENTICATION_DLL_SHIFT}
  35.   MSV1_0_MNS_LOGON                   = $01000000;
  36.   {$EXTERNALSYM MSV1_0_MNS_LOGON}
  37. //
  38. // This is the list of subauthentication dlls used in MS
  39. //
  40.   MSV1_0_SUBAUTHENTICATION_DLL_RAS = 2;
  41.   {$EXTERNALSYM MSV1_0_SUBAUTHENTICATION_DLL_RAS}
  42.   MSV1_0_SUBAUTHENTICATION_DLL_IIS = 132;
  43.   {$EXTERNALSYM MSV1_0_SUBAUTHENTICATION_DLL_IIS}
  44. type
  45.   PMSV1_0_LM20_LOGON = ^MSV1_0_LM20_LOGON;
  46.   {$EXTERNALSYM PMSV1_0_LM20_LOGON}
  47.   _MSV1_0_LM20_LOGON = record
  48.     MessageType: MSV1_0_LOGON_SUBMIT_TYPE;
  49.     LogonDomainName: UNICODE_STRING;
  50.     UserName: UNICODE_STRING;
  51.     Workstation: UNICODE_STRING;
  52.     ChallengeToClient: array [0..MSV1_0_CHALLENGE_LENGTH - 1] of UCHAR;
  53.     CaseSensitiveChallengeResponse: STRING;
  54.     CaseInsensitiveChallengeResponse: STRING;
  55.     ParameterControl: ULONG;
  56.   end;
  57.   {$EXTERNALSYM _MSV1_0_LM20_LOGON}
  58.   MSV1_0_LM20_LOGON = _MSV1_0_LM20_LOGON;
  59.   {$EXTERNALSYM MSV1_0_LM20_LOGON}
  60.   TMsv10Lm20Logon = MSV1_0_LM20_LOGON;
  61.   PMsv10Lm20Logon = PMSV1_0_LM20_LOGON;
  62. //
  63. // NT 5.0 SubAuth dlls can use this struct
  64. //
  65.   PMSV1_0_SUBAUTH_LOGON = ^MSV1_0_SUBAUTH_LOGON;
  66.   {$EXTERNALSYM PMSV1_0_SUBAUTH_LOGON}
  67.   _MSV1_0_SUBAUTH_LOGON = record
  68.     MessageType: MSV1_0_LOGON_SUBMIT_TYPE;
  69.     LogonDomainName: UNICODE_STRING;
  70.     UserName: UNICODE_STRING;
  71.     Workstation: UNICODE_STRING;
  72.     ChallengeToClient: array [0..MSV1_0_CHALLENGE_LENGTH - 1] of UCHAR;
  73.     AuthenticationInfo1: STRING;
  74.     AuthenticationInfo2: STRING;
  75.     ParameterControl: ULONG;
  76.     SubAuthPackageId: ULONG;
  77.   end;
  78.   {$EXTERNALSYM _MSV1_0_SUBAUTH_LOGON}
  79.   MSV1_0_SUBAUTH_LOGON = _MSV1_0_SUBAUTH_LOGON;
  80.   {$EXTERNALSYM MSV1_0_SUBAUTH_LOGON}
  81.   TMsv10SubauthLogon = MSV1_0_SUBAUTH_LOGON;
  82.   PMsv10SubauthLogon = PMSV1_0_SUBAUTH_LOGON;
  83. //
  84. // Values for UserFlags.
  85. //
  86. const
  87.   LOGON_GUEST                 = $01;
  88.   {$EXTERNALSYM LOGON_GUEST}
  89.   LOGON_NOENCRYPTION          = $02;
  90.   {$EXTERNALSYM LOGON_NOENCRYPTION}
  91.   LOGON_CACHED_ACCOUNT        = $04;
  92.   {$EXTERNALSYM LOGON_CACHED_ACCOUNT}
  93.   LOGON_USED_LM_PASSWORD      = $08;
  94.   {$EXTERNALSYM LOGON_USED_LM_PASSWORD}
  95.   LOGON_EXTRA_SIDS            = $20;
  96.   {$EXTERNALSYM LOGON_EXTRA_SIDS}
  97.   LOGON_SUBAUTH_SESSION_KEY   = $40;
  98.   {$EXTERNALSYM LOGON_SUBAUTH_SESSION_KEY}
  99.   LOGON_SERVER_TRUST_ACCOUNT  = $80;
  100.   {$EXTERNALSYM LOGON_SERVER_TRUST_ACCOUNT}
  101.   LOGON_NTLMV2_ENABLED        = $100; // says DC understands NTLMv2
  102.   {$EXTERNALSYM LOGON_NTLMV2_ENABLED}
  103.   LOGON_RESOURCE_GROUPS       = $200;
  104.   {$EXTERNALSYM LOGON_RESOURCE_GROUPS}
  105.   LOGON_PROFILE_PATH_RETURNED = $400;
  106.   {$EXTERNALSYM LOGON_PROFILE_PATH_RETURNED}
  107. //
  108. // The high order byte is reserved for return by SubAuthentication DLLs.
  109. //
  110.   MSV1_0_SUBAUTHENTICATION_FLAGS = DWORD($FF000000);
  111.   {$EXTERNALSYM MSV1_0_SUBAUTHENTICATION_FLAGS}
  112. // Values returned by the MSV1_0_MNS_LOGON SubAuthentication DLL
  113.   LOGON_GRACE_LOGON = $01000000;
  114.   {$EXTERNALSYM LOGON_GRACE_LOGON}
  115. type
  116.   PMSV1_0_LM20_LOGON_PROFILE = ^MSV1_0_LM20_LOGON_PROFILE;
  117.   {$EXTERNALSYM PMSV1_0_LM20_LOGON_PROFILE}
  118.   _MSV1_0_LM20_LOGON_PROFILE = record
  119.     MessageType: MSV1_0_PROFILE_BUFFER_TYPE;
  120.     KickOffTime: LARGE_INTEGER;
  121.     LogoffTime: LARGE_INTEGER;
  122.     UserFlags: ULONG;
  123.     UserSessionKey: array [0..MSV1_0_USER_SESSION_KEY_LENGTH - 1] of UCHAR;
  124.     LogonDomainName: UNICODE_STRING;
  125.     LanmanSessionKey: array [0..MSV1_0_LANMAN_SESSION_KEY_LENGTH - 1] of UCHAR;
  126.     LogonServer: UNICODE_STRING;
  127.     UserParameters: UNICODE_STRING;
  128.   end;
  129.   {$EXTERNALSYM _MSV1_0_LM20_LOGON_PROFILE}
  130.   MSV1_0_LM20_LOGON_PROFILE = _MSV1_0_LM20_LOGON_PROFILE;
  131.   {$EXTERNALSYM MSV1_0_LM20_LOGON_PROFILE}
  132.   TMsv10Lm20LogonProfile = MSV1_0_LM20_LOGON_PROFILE;
  133.   PMsv10Lm20LogonProfile = PMSV1_0_LM20_LOGON_PROFILE;
  134. //
  135. // Supplemental credentials structure used for passing credentials into
  136. // MSV1_0 from other packages
  137. //
  138. const
  139.   MSV1_0_OWF_PASSWORD_LENGTH = 16;
  140.   {$EXTERNALSYM MSV1_0_OWF_PASSWORD_LENGTH}
  141.   MSV1_0_CRED_LM_PRESENT     = $1;
  142.   {$EXTERNALSYM MSV1_0_CRED_LM_PRESENT}
  143.   MSV1_0_CRED_NT_PRESENT     = $2;
  144.   {$EXTERNALSYM MSV1_0_CRED_NT_PRESENT}
  145.   MSV1_0_CRED_VERSION        = 0;
  146.   {$EXTERNALSYM MSV1_0_CRED_VERSION}
  147. type
  148.   PMSV1_0_SUPPLEMENTAL_CREDENTIAL = ^MSV1_0_SUPPLEMENTAL_CREDENTIAL;
  149.   {$EXTERNALSYM PMSV1_0_SUPPLEMENTAL_CREDENTIAL}
  150.   _MSV1_0_SUPPLEMENTAL_CREDENTIAL = record
  151.     Version: ULONG;
  152.     Flags: ULONG;
  153.     LmPassword: array [0..MSV1_0_OWF_PASSWORD_LENGTH - 1] of UCHAR;
  154.     NtPassword: array [0..MSV1_0_OWF_PASSWORD_LENGTH - 1] of UCHAR;
  155.   end;
  156.   {$EXTERNALSYM _MSV1_0_SUPPLEMENTAL_CREDENTIAL}
  157.   MSV1_0_SUPPLEMENTAL_CREDENTIAL = _MSV1_0_SUPPLEMENTAL_CREDENTIAL;
  158.   {$EXTERNALSYM MSV1_0_SUPPLEMENTAL_CREDENTIAL}
  159.   TMsv10SupplementalCredential = MSV1_0_SUPPLEMENTAL_CREDENTIAL;
  160.   PMsv10SupplementalCredential = PMSV1_0_SUPPLEMENTAL_CREDENTIAL;
  161. //
  162. // NTLM3 definitions.
  163. //
  164. const
  165.   MSV1_0_NTLM3_RESPONSE_LENGTH = 16;
  166.   {$EXTERNALSYM MSV1_0_NTLM3_RESPONSE_LENGTH}
  167.   MSV1_0_NTLM3_OWF_LENGTH      = 16;
  168.   {$EXTERNALSYM MSV1_0_NTLM3_OWF_LENGTH}
  169. //
  170. // this is the longest amount of time we'll allow challenge response
  171. // pairs to be used. Note that this also has to allow for worst case clock skew
  172. //
  173.   MSV1_0_MAX_NTLM3_LIFE = 129600;     // 36 hours (in seconds)
  174.   {$EXTERNALSYM MSV1_0_MAX_NTLM3_LIFE}
  175.   MSV1_0_MAX_AVL_SIZE   = 64000;
  176.   {$EXTERNALSYM MSV1_0_MAX_AVL_SIZE}
  177. //
  178. // MsvAvFlags bit values
  179. //
  180.   MSV1_0_AV_FLAG_FORCE_GUEST = $00000001;
  181.   {$EXTERNALSYM MSV1_0_AV_FLAG_FORCE_GUEST}
  182. // this is an MSV1_0 private data structure, defining the layout of an NTLM3 response, as sent by a
  183. //  client in the NtChallengeResponse field of the NETLOGON_NETWORK_INFO structure. If can be differentiated
  184. //  from an old style NT response by its length. This is crude, but it needs to pass through servers and
  185. //  the servers' DCs that do not understand NTLM3 but that are willing to pass longer responses.
  186. type
  187.   PMSV1_0_NTLM3_RESPONSE = ^MSV1_0_NTLM3_RESPONSE;
  188.   {$EXTERNALSYM PMSV1_0_NTLM3_RESPONSE}
  189.   _MSV1_0_NTLM3_RESPONSE = record
  190.     Response: array [0..MSV1_0_NTLM3_RESPONSE_LENGTH - 1] of UCHAR; // hash of OWF of password with all the following fields
  191.     RespType: UCHAR; // id number of response; current is 1
  192.     HiRespType: UCHAR; // highest id number understood by client
  193.     Flags: USHORT; // reserved; must be sent as zero at this version
  194.     MsgWord: ULONG; // 32 bit message from client to server (for use by auth protocol)
  195.     TimeStamp: ULONGLONG; // time stamp when client generated response -- NT system time, quad part
  196.     ChallengeFromClient: array [0..MSV1_0_CHALLENGE_LENGTH - 1] of UCHAR;
  197.     AvPairsOff: ULONG; // offset to start of AvPairs (to allow future expansion)
  198.     Buffer: array [0..0] of UCHAR; // start of buffer with AV pairs (or future stuff -- so use the offset)
  199.   end;
  200.   {$EXTERNALSYM _MSV1_0_NTLM3_RESPONSE}
  201.   MSV1_0_NTLM3_RESPONSE = _MSV1_0_NTLM3_RESPONSE;
  202.   {$EXTERNALSYM MSV1_0_NTLM3_RESPONSE}
  203.   TMsv10Ntlm3Response = MSV1_0_NTLM3_RESPONSE;
  204.   PMsv10Ntlm3Response = PMSV1_0_NTLM3_RESPONSE;
  205. const
  206.   MSV1_0_NTLM3_INPUT_LENGTH = (SizeOf(MSV1_0_NTLM3_RESPONSE) - MSV1_0_NTLM3_RESPONSE_LENGTH);
  207.   {$EXTERNALSYM MSV1_0_NTLM3_INPUT_LENGTH}
  208. type
  209.   MSV1_0_AVID = (
  210.     MsvAvEOL,                 // end of list
  211.     MsvAvNbComputerName,      // server's computer name -- NetBIOS
  212.     MsvAvNbDomainName,        // server's domain name -- NetBIOS
  213.     MsvAvDnsComputerName,     // server's computer name -- DNS
  214.     MsvAvDnsDomainName,       // server's domain name -- DNS
  215.     MsvAvDnsTreeName,         // server's tree name -- DNS
  216.     MsvAvFlags);              // server's extended flags -- DWORD mask
  217.   {$EXTERNALSYM MSV1_0_AVID}
  218.   PMSV1_0_AV_PAIR = ^MSV1_0_AV_PAIR;
  219.   {$EXTERNALSYM PMSV1_0_AV_PAIR}
  220.   _MSV1_0_AV_PAIR = record
  221.     AvId: USHORT;
  222.     AvLen: USHORT;
  223.     // Data is treated as byte array following structure
  224.   end;
  225.   {$EXTERNALSYM _MSV1_0_AV_PAIR}
  226.   MSV1_0_AV_PAIR = _MSV1_0_AV_PAIR;
  227.   {$EXTERNALSYM MSV1_0_AV_PAIR}
  228.   TMsv10AvPair = MSV1_0_AV_PAIR;
  229.   PMsv10AvPair = PMSV1_0_AV_PAIR;
  230. ///////////////////////////////////////////////////////////////////////////////
  231. //                                                                           //
  232. //       CALL PACKAGE Related Data Structures                                //
  233. //                                                                           //
  234. ///////////////////////////////////////////////////////////////////////////////
  235. //
  236. //  MSV1.0 LsaCallAuthenticationPackage() submission and response
  237. //  message types.
  238. //
  239.   _MSV1_0_PROTOCOL_MESSAGE_TYPE = (
  240.     MsV1_0Lm20ChallengeRequest,              // Both submission and response
  241.     MsV1_0Lm20GetChallengeResponse,          // Both submission and response
  242.     MsV1_0EnumerateUsers,                    // Both submission and response
  243.     MsV1_0GetUserInfo,                       // Both submission and response
  244.     MsV1_0ReLogonUsers,                      // Submission only
  245.     MsV1_0ChangePassword,                    // Both submission and response
  246.     MsV1_0ChangeCachedPassword,              // Both submission and response
  247.     MsV1_0GenericPassthrough,                // Both submission and response
  248.     MsV1_0CacheLogon,                        // Submission only, no response
  249.     MsV1_0SubAuth,                           // Both submission and response
  250.     MsV1_0DeriveCredential,                  // Both submission and response
  251.     MsV1_0CacheLookup,                       // Both submission and response
  252.     MsV1_0SetProcessOption);                 // Submission only, no response
  253.   {$EXTERNALSYM _MSV1_0_PROTOCOL_MESSAGE_TYPE}
  254.   MSV1_0_PROTOCOL_MESSAGE_TYPE = _MSV1_0_PROTOCOL_MESSAGE_TYPE;
  255.   {$EXTERNALSYM MSV1_0_PROTOCOL_MESSAGE_TYPE}
  256.   PMSV1_0_PROTOCOL_MESSAGE_TYPE = ^MSV1_0_PROTOCOL_MESSAGE_TYPE;
  257.   {$EXTERNALSYM PMSV1_0_PROTOCOL_MESSAGE_TYPE}
  258.   TMsv1_0ProtocolMessageType = MSV1_0_PROTOCOL_MESSAGE_TYPE;
  259.   PMsv1_0ProtocolMessageType = PMSV1_0_PROTOCOL_MESSAGE_TYPE;
  260.   PMSV1_0_CHANGEPASSWORD_REQUEST = ^MSV1_0_CHANGEPASSWORD_REQUEST;
  261.   {$EXTERNALSYM PMSV1_0_CHANGEPASSWORD_REQUEST}
  262.   _MSV1_0_CHANGEPASSWORD_REQUEST = record
  263.     MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE;
  264.     DomainName: UNICODE_STRING;
  265.     AccountName: UNICODE_STRING;
  266.     OldPassword: UNICODE_STRING;
  267.     NewPassword: UNICODE_STRING;
  268.     Impersonating: ByteBool;
  269.   end;
  270.   {$EXTERNALSYM _MSV1_0_CHANGEPASSWORD_REQUEST}
  271.   MSV1_0_CHANGEPASSWORD_REQUEST = _MSV1_0_CHANGEPASSWORD_REQUEST;
  272.   {$EXTERNALSYM MSV1_0_CHANGEPASSWORD_REQUEST}
  273.   TMsv10ChangepasswordRequest = MSV1_0_CHANGEPASSWORD_REQUEST;
  274.   PMsv10ChangepasswordRequest = PMSV1_0_CHANGEPASSWORD_REQUEST;
  275.   PMSV1_0_CHANGEPASSWORD_RESPONSE = ^MSV1_0_CHANGEPASSWORD_RESPONSE;
  276.   {$EXTERNALSYM PMSV1_0_CHANGEPASSWORD_RESPONSE}
  277.   _MSV1_0_CHANGEPASSWORD_RESPONSE = record
  278.     MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE;
  279.     PasswordInfoValid: ByteBool;
  280.     DomainPasswordInfo: DOMAIN_PASSWORD_INFORMATION;
  281.   end;
  282.   {$EXTERNALSYM _MSV1_0_CHANGEPASSWORD_RESPONSE}
  283.   MSV1_0_CHANGEPASSWORD_RESPONSE = _MSV1_0_CHANGEPASSWORD_RESPONSE;
  284.   {$EXTERNALSYM MSV1_0_CHANGEPASSWORD_RESPONSE}
  285.   TMsv10ChangepasswordResponse = MSV1_0_CHANGEPASSWORD_RESPONSE;
  286.   PMsv10ChangepasswordResponse = PMSV1_0_CHANGEPASSWORD_RESPONSE;
  287. //
  288. // MsV1_0GenericPassthrough - for remoting a CallPackage to
  289. // a domain controller on the specified domain
  290. //
  291.   _MSV1_0_PASSTHROUGH_REQUEST = record
  292.     MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE;
  293.     DomainName: UNICODE_STRING;
  294.     PackageName: UNICODE_STRING;
  295.     DataLength: ULONG;
  296.     LogonData: PUCHAR;
  297.     Pad: ULONG;
  298.   end;
  299.   {$EXTERNALSYM _MSV1_0_PASSTHROUGH_REQUEST}
  300.   MSV1_0_PASSTHROUGH_REQUEST = _MSV1_0_PASSTHROUGH_REQUEST;
  301.   {$EXTERNALSYM MSV1_0_PASSTHROUGH_REQUEST}
  302.   PMSV1_0_PASSTHROUGH_REQUEST = ^MSV1_0_PASSTHROUGH_REQUEST;
  303.   {$EXTERNALSYM PMSV1_0_PASSTHROUGH_REQUEST}
  304.   TMsv10PassThroughRequest = MSV1_0_PASSTHROUGH_REQUEST;
  305.   PMsv10PassThroughRequest = PMSV1_0_PASSTHROUGH_REQUEST;  
  306.   _MSV1_0_PASSTHROUGH_RESPONSE = record
  307.     MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE;
  308.     Pad: ULONG;
  309.     DataLength: ULONG;
  310.     ValidationData: PUCHAR;
  311.   end;
  312.   {$EXTERNALSYM _MSV1_0_PASSTHROUGH_RESPONSE}
  313.   MSV1_0_PASSTHROUGH_RESPONSE = _MSV1_0_PASSTHROUGH_RESPONSE;
  314.   {$EXTERNALSYM MSV1_0_PASSTHROUGH_RESPONSE}
  315.   PMSV1_0_PASSTHROUGH_RESPONSE = ^MSV1_0_PASSTHROUGH_RESPONSE;
  316.   {$EXTERNALSYM PMSV1_0_PASSTHROUGH_RESPONSE}
  317.   TMsv10PassThroughResponse = MSV1_0_PASSTHROUGH_RESPONSE;
  318.   PMsv10PassThroughResponse = PMSV1_0_PASSTHROUGH_RESPONSE;
  319. //
  320. // MsV1_0SubAuthInfo submit buffer and response - for submitting a buffer to a
  321. // specified Subauthentication Package during an LsaCallAuthenticationPackage().
  322. // If this Subauthentication is to be done locally, then package this message
  323. // in LsaCallAuthenticationPackage(). If this SubAuthentication needs to be done
  324. // on the domain controller, then call LsaCallauthenticationPackage with the
  325. // message type being MsV1_0GenericPassThrough and the LogonData in this struct
  326. // should be a PMSV1_0_SUBAUTH_REQUEST
  327. //
  328.   PMSV1_0_SUBAUTH_REQUEST = ^MSV1_0_SUBAUTH_REQUEST;
  329.   {$EXTERNALSYM PMSV1_0_SUBAUTH_REQUEST}
  330.   _MSV1_0_SUBAUTH_REQUEST = record
  331.     MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE;
  332.     SubAuthPackageId: ULONG;
  333.     SubAuthInfoLength: ULONG;
  334.     SubAuthSubmitBuffer: PUCHAR;
  335.   end;
  336.   {$EXTERNALSYM _MSV1_0_SUBAUTH_REQUEST}
  337.   MSV1_0_SUBAUTH_REQUEST = _MSV1_0_SUBAUTH_REQUEST;
  338.   {$EXTERNALSYM MSV1_0_SUBAUTH_REQUEST}
  339.   TMsv10SubauthRequest = MSV1_0_SUBAUTH_REQUEST;
  340.   PMsv10SubauthRequest = PMSV1_0_SUBAUTH_REQUEST;
  341.   PMSV1_0_SUBAUTH_RESPONSE = ^MSV1_0_SUBAUTH_RESPONSE;
  342.   {$EXTERNALSYM PMSV1_0_SUBAUTH_RESPONSE}
  343.   _MSV1_0_SUBAUTH_RESPONSE = record
  344.     MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE;
  345.     SubAuthInfoLength: ULONG;
  346.     SubAuthReturnBuffer: PUCHAR;
  347.   end;
  348.   {$EXTERNALSYM _MSV1_0_SUBAUTH_RESPONSE}
  349.   MSV1_0_SUBAUTH_RESPONSE = _MSV1_0_SUBAUTH_RESPONSE;
  350.   {$EXTERNALSYM MSV1_0_SUBAUTH_RESPONSE}
  351.   TMsv10SubauthResponse = MSV1_0_SUBAUTH_RESPONSE;
  352.   PMsv10SubauthResponse = PMSV1_0_SUBAUTH_RESPONSE;
  353. //
  354. // Credential Derivation types for MsV1_0DeriveCredential Submit DeriveCredType
  355. //
  356. //
  357. // Derive Credential using SHA-1 and Request buffer DeriveCredSubmitBuffer of
  358. // length DeriveCredInfoLength mixing bytes.
  359. // Response buffer DeriveCredReturnBuffer will contain SHA-1 hash of size
  360. // A_SHA_DIGEST_LEN (20)
  361. //
  362. const
  363.   MSV1_0_DERIVECRED_TYPE_SHA1 = 0;
  364.   {$EXTERNALSYM MSV1_0_DERIVECRED_TYPE_SHA1}
  365. //
  366. // MsV1_0DeriveCredential submit buffer and response - for submitting a buffer
  367. // an call to LsaCallAuthenticationPackage().
  368. //
  369. type
  370.   PMSV1_0_DERIVECRED_REQUEST = ^MSV1_0_DERIVECRED_REQUEST;
  371.   {$EXTERNALSYM PMSV1_0_DERIVECRED_REQUEST}
  372.   _MSV1_0_DERIVECRED_REQUEST = record
  373.     MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE;
  374.     LogonId: LUID;
  375.     DeriveCredType: ULONG;
  376.     DeriveCredInfoLength: ULONG;
  377.     DeriveCredSubmitBuffer: array [0..0] of UCHAR; // in-place array of length DeriveCredInfoLength
  378.   end;
  379.   {$EXTERNALSYM _MSV1_0_DERIVECRED_REQUEST}
  380.   MSV1_0_DERIVECRED_REQUEST = _MSV1_0_DERIVECRED_REQUEST;
  381.   {$EXTERNALSYM MSV1_0_DERIVECRED_REQUEST}
  382.   TMsv10DeriveCredRequest = MSV1_0_DERIVECRED_REQUEST;
  383.   PMsv10DeriveCredRequest = PMSV1_0_DERIVECRED_REQUEST;
  384.   PMSV1_0_DERIVECRED_RESPONSE = ^MSV1_0_DERIVECRED_RESPONSE;
  385.   {$EXTERNALSYM PMSV1_0_DERIVECRED_RESPONSE}
  386.   _MSV1_0_DERIVECRED_RESPONSE = record
  387.     MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE;
  388.     DeriveCredInfoLength: ULONG;
  389.     DeriveCredReturnBuffer: array [0..0] of UCHAR; // in-place array of length DeriveCredInfoLength
  390.   end;
  391.   {$EXTERNALSYM _MSV1_0_DERIVECRED_RESPONSE}
  392.   MSV1_0_DERIVECRED_RESPONSE = _MSV1_0_DERIVECRED_RESPONSE;
  393.   {$EXTERNALSYM MSV1_0_DERIVECRED_RESPONSE}
  394.   TMsv10DeriveCredResponse = MSV1_0_DERIVECRED_RESPONSE;
  395.   PMsv10DeriveCredResponse = PMSV1_0_DERIVECRED_RESPONSE;
  396. // Revision of the Kerberos Protocol.  MS uses Version 5, Revision 6
  397. const
  398.   KERBEROS_VERSION  = 5;
  399.   {$EXTERNALSYM KERBEROS_VERSION}
  400.   KERBEROS_REVISION = 6;
  401.   {$EXTERNALSYM KERBEROS_REVISION}
  402. // Encryption Types:
  403. // These encryption types are supported by the default MS KERBSUPP DLL
  404. // as crypto systems.  Values over 127 are local values, and may be changed
  405. // without notice.
  406.   KERB_ETYPE_NULL        = 0;
  407.   {$EXTERNALSYM KERB_ETYPE_NULL}
  408.   KERB_ETYPE_DES_CBC_CRC = 1;
  409.   {$EXTERNALSYM KERB_ETYPE_DES_CBC_CRC}
  410.   KERB_ETYPE_DES_CBC_MD4 = 2;
  411.   {$EXTERNALSYM KERB_ETYPE_DES_CBC_MD4}
  412.   KERB_ETYPE_DES_CBC_MD5 = 3;
  413.   {$EXTERNALSYM KERB_ETYPE_DES_CBC_MD5}
  414.   KERB_ETYPE_RC4_MD4           = -128;
  415.   {$EXTERNALSYM KERB_ETYPE_RC4_MD4}
  416.   KERB_ETYPE_RC4_PLAIN2        = -129;
  417.   {$EXTERNALSYM KERB_ETYPE_RC4_PLAIN2}
  418.   KERB_ETYPE_RC4_LM            = -130;
  419.   {$EXTERNALSYM KERB_ETYPE_RC4_LM}
  420.   KERB_ETYPE_RC4_SHA           = -131;
  421.   {$EXTERNALSYM KERB_ETYPE_RC4_SHA}
  422.   KERB_ETYPE_DES_PLAIN         = -132;
  423.   {$EXTERNALSYM KERB_ETYPE_DES_PLAIN}
  424.   KERB_ETYPE_RC4_HMAC_OLD      = -133;
  425.   {$EXTERNALSYM KERB_ETYPE_RC4_HMAC_OLD}
  426.   KERB_ETYPE_RC4_PLAIN_OLD     = -134;
  427.   {$EXTERNALSYM KERB_ETYPE_RC4_PLAIN_OLD}
  428.   KERB_ETYPE_RC4_HMAC_OLD_EXP  = -135;
  429.   {$EXTERNALSYM KERB_ETYPE_RC4_HMAC_OLD_EXP}
  430.   KERB_ETYPE_RC4_PLAIN_OLD_EXP = -136;
  431.   {$EXTERNALSYM KERB_ETYPE_RC4_PLAIN_OLD_EXP}
  432.   KERB_ETYPE_RC4_PLAIN         = -140;
  433.   {$EXTERNALSYM KERB_ETYPE_RC4_PLAIN}
  434.   KERB_ETYPE_RC4_PLAIN_EXP     = -141;
  435.   {$EXTERNALSYM KERB_ETYPE_RC4_PLAIN_EXP}
  436. //
  437. // Pkinit encryption types
  438. //
  439.   KERB_ETYPE_DSA_SHA1_CMS     = 9;
  440.   {$EXTERNALSYM KERB_ETYPE_DSA_SHA1_CMS}
  441.   KERB_ETYPE_RSA_MD5_CMS      = 10;
  442.   {$EXTERNALSYM KERB_ETYPE_RSA_MD5_CMS}
  443.   KERB_ETYPE_RSA_SHA1_CMS     = 11;
  444.   {$EXTERNALSYM KERB_ETYPE_RSA_SHA1_CMS}
  445.   KERB_ETYPE_RC2_CBC_ENV      = 12;
  446.   {$EXTERNALSYM KERB_ETYPE_RC2_CBC_ENV}
  447.   KERB_ETYPE_RSA_ENV          = 13;
  448.   {$EXTERNALSYM KERB_ETYPE_RSA_ENV}
  449.   KERB_ETYPE_RSA_ES_OEAP_ENV  = 14;
  450.   {$EXTERNALSYM KERB_ETYPE_RSA_ES_OEAP_ENV}
  451.   KERB_ETYPE_DES_EDE3_CBC_ENV = 15;
  452.   {$EXTERNALSYM KERB_ETYPE_DES_EDE3_CBC_ENV}
  453. //
  454. // Deprecated
  455. //
  456.   KERB_ETYPE_DSA_SIGN     = 8;
  457.   {$EXTERNALSYM KERB_ETYPE_DSA_SIGN}
  458.   KERB_ETYPE_RSA_PRIV     = 9;
  459.   {$EXTERNALSYM KERB_ETYPE_RSA_PRIV}
  460.   KERB_ETYPE_RSA_PUB      = 10;
  461.   {$EXTERNALSYM KERB_ETYPE_RSA_PUB}
  462.   KERB_ETYPE_RSA_PUB_MD5  = 11;
  463.   {$EXTERNALSYM KERB_ETYPE_RSA_PUB_MD5}
  464.   KERB_ETYPE_RSA_PUB_SHA1 = 12;
  465.   {$EXTERNALSYM KERB_ETYPE_RSA_PUB_SHA1}
  466.   KERB_ETYPE_PKCS7_PUB    = 13;
  467.   {$EXTERNALSYM KERB_ETYPE_PKCS7_PUB}
  468. //
  469. // In use types
  470. //
  471.   KERB_ETYPE_DES_CBC_MD5_NT  = 20;
  472.   {$EXTERNALSYM KERB_ETYPE_DES_CBC_MD5_NT}
  473.   KERB_ETYPE_RC4_HMAC_NT     = 23;
  474.   {$EXTERNALSYM KERB_ETYPE_RC4_HMAC_NT}
  475.   KERB_ETYPE_RC4_HMAC_NT_EXP = 24;
  476.   {$EXTERNALSYM KERB_ETYPE_RC4_HMAC_NT_EXP}
  477. // Checksum algorithms.
  478. // These algorithms are keyed internally for our use.
  479.   KERB_CHECKSUM_NONE        = 0;
  480.   {$EXTERNALSYM KERB_CHECKSUM_NONE}
  481.   KERB_CHECKSUM_CRC32       = 1;
  482.   {$EXTERNALSYM KERB_CHECKSUM_CRC32}
  483.   KERB_CHECKSUM_MD4         = 2;
  484.   {$EXTERNALSYM KERB_CHECKSUM_MD4}
  485.   KERB_CHECKSUM_KRB_DES_MAC = 4;
  486.   {$EXTERNALSYM KERB_CHECKSUM_KRB_DES_MAC}
  487.   KERB_CHECKSUM_KRB_DES_MAC_K = 5;
  488.   {$EXTERNALSYM KERB_CHECKSUM_KRB_DES_MAC_K}  
  489.   KERB_CHECKSUM_MD5         = 7;
  490.   {$EXTERNALSYM KERB_CHECKSUM_MD5}
  491.   KERB_CHECKSUM_MD5_DES     = 8;
  492.   {$EXTERNALSYM KERB_CHECKSUM_MD5_DES}
  493.   KERB_CHECKSUM_LM          = -130;
  494.   {$EXTERNALSYM KERB_CHECKSUM_LM}
  495.   KERB_CHECKSUM_SHA1        = -131;
  496.   {$EXTERNALSYM KERB_CHECKSUM_SHA1}
  497.   KERB_CHECKSUM_REAL_CRC32  = -132;
  498.   {$EXTERNALSYM KERB_CHECKSUM_REAL_CRC32}
  499.   KERB_CHECKSUM_DES_MAC     = -133;
  500.   {$EXTERNALSYM KERB_CHECKSUM_DES_MAC}
  501.   KERB_CHECKSUM_DES_MAC_MD5 = -134;
  502.   {$EXTERNALSYM KERB_CHECKSUM_DES_MAC_MD5}
  503.   KERB_CHECKSUM_MD25        = -135;
  504.   {$EXTERNALSYM KERB_CHECKSUM_MD25}
  505.   KERB_CHECKSUM_RC4_MD5     = -136;
  506.   {$EXTERNALSYM KERB_CHECKSUM_RC4_MD5}
  507.   KERB_CHECKSUM_MD5_HMAC    = -137; // used by netlogon
  508.   {$EXTERNALSYM KERB_CHECKSUM_MD5_HMAC}
  509.   KERB_CHECKSUM_HMAC_MD5    = -138; // used by Kerberos
  510.   {$EXTERNALSYM KERB_CHECKSUM_HMAC_MD5}
  511.   AUTH_REQ_ALLOW_FORWARDABLE     = $00000001;
  512.   {$EXTERNALSYM AUTH_REQ_ALLOW_FORWARDABLE}
  513.   AUTH_REQ_ALLOW_PROXIABLE       = $00000002;
  514.   {$EXTERNALSYM AUTH_REQ_ALLOW_PROXIABLE}
  515.   AUTH_REQ_ALLOW_POSTDATE        = $00000004;
  516.   {$EXTERNALSYM AUTH_REQ_ALLOW_POSTDATE}
  517.   AUTH_REQ_ALLOW_RENEWABLE       = $00000008;
  518.   {$EXTERNALSYM AUTH_REQ_ALLOW_RENEWABLE}
  519.   AUTH_REQ_ALLOW_NOADDRESS       = $00000010;
  520.   {$EXTERNALSYM AUTH_REQ_ALLOW_NOADDRESS}
  521.   AUTH_REQ_ALLOW_ENC_TKT_IN_SKEY = $00000020;
  522.   {$EXTERNALSYM AUTH_REQ_ALLOW_ENC_TKT_IN_SKEY}
  523.   AUTH_REQ_ALLOW_VALIDATE        = $00000040;
  524.   {$EXTERNALSYM AUTH_REQ_ALLOW_VALIDATE}
  525.   AUTH_REQ_VALIDATE_CLIENT       = $00000080;
  526.   {$EXTERNALSYM AUTH_REQ_VALIDATE_CLIENT}
  527.   AUTH_REQ_OK_AS_DELEGATE        = $00000100;
  528.   {$EXTERNALSYM AUTH_REQ_OK_AS_DELEGATE}
  529.   AUTH_REQ_PREAUTH_REQUIRED      = $00000200;
  530.   {$EXTERNALSYM AUTH_REQ_PREAUTH_REQUIRED}
  531.   AUTH_REQ_TRANSITIVE_TRUST      = $00000400;
  532.   {$EXTERNALSYM AUTH_REQ_TRANSITIVE_TRUST}
  533.   AUTH_REQ_ALLOW_S4U_DELEGATE    = $00000800;
  534.   {$EXTERNALSYM AUTH_REQ_ALLOW_S4U_DELEGATE}
  535.   AUTH_REQ_PER_USER_FLAGS        = (AUTH_REQ_ALLOW_FORWARDABLE or
  536.                                     AUTH_REQ_ALLOW_PROXIABLE or
  537.                                     AUTH_REQ_ALLOW_POSTDATE or
  538.                                     AUTH_REQ_ALLOW_RENEWABLE or
  539.                                     AUTH_REQ_ALLOW_VALIDATE);
  540.   {$EXTERNALSYM AUTH_REQ_PER_USER_FLAGS}
  541. //
  542. // Ticket Flags:
  543. //
  544.   KERB_TICKET_FLAGS_reserved          = DWORD($80000000);
  545.   {$EXTERNALSYM KERB_TICKET_FLAGS_reserved}
  546.   KERB_TICKET_FLAGS_forwardable       = $40000000;
  547.   {$EXTERNALSYM KERB_TICKET_FLAGS_forwardable}
  548.   KERB_TICKET_FLAGS_forwarded         = $20000000;
  549.   {$EXTERNALSYM KERB_TICKET_FLAGS_forwarded}
  550.   KERB_TICKET_FLAGS_proxiable         = $10000000;
  551.   {$EXTERNALSYM KERB_TICKET_FLAGS_proxiable}
  552.   KERB_TICKET_FLAGS_proxy             = $08000000;
  553.   {$EXTERNALSYM KERB_TICKET_FLAGS_proxy}
  554.   KERB_TICKET_FLAGS_may_postdate      = $04000000;
  555.   {$EXTERNALSYM KERB_TICKET_FLAGS_may_postdate}
  556.   KERB_TICKET_FLAGS_postdated         = $02000000;
  557.   {$EXTERNALSYM KERB_TICKET_FLAGS_postdated}
  558.   KERB_TICKET_FLAGS_invalid           = $01000000;
  559.   {$EXTERNALSYM KERB_TICKET_FLAGS_invalid}
  560.   KERB_TICKET_FLAGS_renewable         = $00800000;
  561.   {$EXTERNALSYM KERB_TICKET_FLAGS_renewable}
  562.   KERB_TICKET_FLAGS_initial           = $00400000;
  563.   {$EXTERNALSYM KERB_TICKET_FLAGS_initial}
  564.   KERB_TICKET_FLAGS_pre_authent       = $00200000;
  565.   {$EXTERNALSYM KERB_TICKET_FLAGS_pre_authent}
  566.   KERB_TICKET_FLAGS_hw_authent        = $00100000;
  567.   {$EXTERNALSYM KERB_TICKET_FLAGS_hw_authent}
  568.   KERB_TICKET_FLAGS_ok_as_delegate    = $00040000;
  569.   {$EXTERNALSYM KERB_TICKET_FLAGS_ok_as_delegate}
  570.   KERB_TICKET_FLAGS_name_canonicalize = $00010000;
  571.   {$EXTERNALSYM KERB_TICKET_FLAGS_name_canonicalize}
  572.   KERB_TICKET_FLAGS_reserved1         = $00000001;
  573.   {$EXTERNALSYM KERB_TICKET_FLAGS_reserved1}
  574. //
  575. // Name types
  576. //
  577.   KRB_NT_UNKNOWN              = 0; // Name type not known
  578.   {$EXTERNALSYM KRB_NT_UNKNOWN}
  579.   KRB_NT_PRINCIPAL            = 1; // Just the name of the principal as in DCE, or for users
  580.   {$EXTERNALSYM KRB_NT_PRINCIPAL}
  581.   KRB_NT_PRINCIPAL_AND_ID     = -131; // Name of the principal and its SID.
  582.   {$EXTERNALSYM KRB_NT_PRINCIPAL_AND_ID}
  583.   KRB_NT_SRV_INST             = 2; // Service and other unique instance (krbtgt)
  584.   {$EXTERNALSYM KRB_NT_SRV_INST}
  585.   KRB_NT_SRV_INST_AND_ID      = -132; // SPN and SID
  586.   {$EXTERNALSYM KRB_NT_SRV_INST_AND_ID}
  587.   KRB_NT_SRV_HST              = 3; // Service with host name as instance (telnet, rcommands)
  588.   {$EXTERNALSYM KRB_NT_SRV_HST}
  589.   KRB_NT_SRV_XHST             = 4; // Service with host as remaining components
  590.   {$EXTERNALSYM KRB_NT_SRV_XHST}
  591.   KRB_NT_UID                  = 5; // Unique ID
  592.   {$EXTERNALSYM KRB_NT_UID}
  593.   KRB_NT_ENTERPRISE_PRINCIPAL = 10; // UPN or SPN
  594.   {$EXTERNALSYM KRB_NT_ENTERPRISE_PRINCIPAL}
  595.   KRB_NT_ENT_PRINCIPAL_AND_ID = -130; // UPN and SID
  596.   {$EXTERNALSYM KRB_NT_ENT_PRINCIPAL_AND_ID}
  597. //
  598. // MS extensions, negative according to the RFC
  599. //
  600.   KRB_NT_MS_PRINCIPAL = -128; // NT4 style name
  601.   {$EXTERNALSYM KRB_NT_MS_PRINCIPAL}
  602.   KRB_NT_MS_PRINCIPAL_AND_ID = -129; // nt4 style name with sid
  603.   {$EXTERNALSYM KRB_NT_MS_PRINCIPAL_AND_ID}
  604. // todo #define KERB_IS_MS_PRINCIPAL(_x_) (((_x_) <= KRB_NT_MS_PRINCIPAL) || ((_x_) >= KRB_NT_ENTERPRISE_PRINCIPAL))
  605.   MICROSOFT_KERBEROS_NAME_A = 'Kerberos';
  606.   {$EXTERNALSYM MICROSOFT_KERBEROS_NAME_A}
  607.   MICROSOFT_KERBEROS_NAME_W = WideString('Kerberos');
  608.   {$EXTERNALSYM MICROSOFT_KERBEROS_NAME_W}
  609. {$IFDEF UNICODE}
  610.   MICROSOFT_KERBEROS_NAME = MICROSOFT_KERBEROS_NAME_W;
  611.   {$EXTERNALSYM MICROSOFT_KERBEROS_NAME}
  612. {$ELSE}
  613.   MICROSOFT_KERBEROS_NAME = MICROSOFT_KERBEROS_NAME_A;
  614.   {$EXTERNALSYM MICROSOFT_KERBEROS_NAME}
  615. {$ENDIF}
  616. /////////////////////////////////////////////////////////////////////////
  617. //
  618. // Quality of protection parameters for MakeSignature / EncryptMessage
  619. //
  620. /////////////////////////////////////////////////////////////////////////
  621. //
  622. // This flag indicates to EncryptMessage that the message is not to actually
  623. // be encrypted, but a header/trailer are to be produced.
  624. //
  625.   KERB_WRAP_NO_ENCRYPT = DWORD($80000001);
  626.   {$EXTERNALSYM KERB_WRAP_NO_ENCRYPT}
  627. /////////////////////////////////////////////////////////////////////////
  628. //
  629. // LsaLogonUser parameters
  630. //
  631. /////////////////////////////////////////////////////////////////////////
  632. const
  633.   KerbInteractiveLogon = 2;
  634.   KerbSmartCardLogon = 6;
  635.   KerbWorkstationUnlockLogon = 7;
  636.   KerbSmartCardUnlockLogon = 8;
  637.   KerbProxyLogon = 9;
  638.   KerbTicketLogon = 10;
  639.   KerbTicketUnlockLogon = 11;
  640.   KerbS4ULogon = 12; 
  641. type
  642.   KERB_LOGON_SUBMIT_TYPE = DWORD;
  643.   {$EXTERNALSYM KERB_LOGON_SUBMIT_TYPE}
  644.   PKERB_LOGON_SUBMIT_TYPE = ^KERB_LOGON_SUBMIT_TYPE;
  645.   {$EXTERNALSYM PKERB_LOGON_SUBMIT_TYPE}
  646.   PKERB_INTERACTIVE_LOGON = ^KERB_INTERACTIVE_LOGON;
  647.   {$EXTERNALSYM PKERB_INTERACTIVE_LOGON}
  648.   _KERB_INTERACTIVE_LOGON = record
  649.     MessageType: KERB_LOGON_SUBMIT_TYPE;
  650.     LogonDomainName: UNICODE_STRING;
  651.     UserName: UNICODE_STRING;
  652.     Password: UNICODE_STRING;
  653.   end;
  654.   {$EXTERNALSYM _KERB_INTERACTIVE_LOGON}
  655.   KERB_INTERACTIVE_LOGON = _KERB_INTERACTIVE_LOGON;
  656.   {$EXTERNALSYM KERB_INTERACTIVE_LOGON}
  657.   TKerbInteractiveLogon = KERB_INTERACTIVE_LOGON;
  658.   PKerbInteractiveLogon = PKERB_INTERACTIVE_LOGON;
  659.   PKERB_INTERACTIVE_UNLOCK_LOGON = ^KERB_INTERACTIVE_UNLOCK_LOGON;
  660.   {$EXTERNALSYM PKERB_INTERACTIVE_UNLOCK_LOGON}
  661.   _KERB_INTERACTIVE_UNLOCK_LOGON = record
  662.     Logon: KERB_INTERACTIVE_LOGON;
  663.     LogonId: LUID;
  664.   end;
  665.   {$EXTERNALSYM _KERB_INTERACTIVE_UNLOCK_LOGON}
  666.   KERB_INTERACTIVE_UNLOCK_LOGON = _KERB_INTERACTIVE_UNLOCK_LOGON;
  667.   {$EXTERNALSYM KERB_INTERACTIVE_UNLOCK_LOGON}
  668.   TKerbInteractiveUnlockLogon = KERB_INTERACTIVE_UNLOCK_LOGON;
  669.   PKerbInteractiveUnlockLogon = PKERB_INTERACTIVE_UNLOCK_LOGON;
  670.   PKERB_SMART_CARD_LOGON = ^KERB_SMART_CARD_LOGON;
  671.   {$EXTERNALSYM PKERB_SMART_CARD_LOGON}
  672.   _KERB_SMART_CARD_LOGON = record
  673.     MessageType: KERB_LOGON_SUBMIT_TYPE;
  674.     Pin: UNICODE_STRING;
  675.     CspDataLength: ULONG;
  676.     CspData: PUCHAR;
  677.   end;
  678.   {$EXTERNALSYM _KERB_SMART_CARD_LOGON}
  679.   KERB_SMART_CARD_LOGON = _KERB_SMART_CARD_LOGON;
  680.   {$EXTERNALSYM KERB_SMART_CARD_LOGON}
  681.   TKerbSmartCardLogon = KERB_SMART_CARD_LOGON;
  682.   PKerbSmartCardLogon = PKERB_SMART_CARD_LOGON;
  683.   PKERB_SMART_CARD_UNLOCK_LOGON = ^KERB_SMART_CARD_UNLOCK_LOGON;
  684.   {$EXTERNALSYM PKERB_SMART_CARD_UNLOCK_LOGON}
  685.   _KERB_SMART_CARD_UNLOCK_LOGON = record
  686.     Logon: KERB_SMART_CARD_LOGON;
  687.     LogonId: LUID;
  688.   end;
  689.   {$EXTERNALSYM _KERB_SMART_CARD_UNLOCK_LOGON}
  690.   KERB_SMART_CARD_UNLOCK_LOGON = _KERB_SMART_CARD_UNLOCK_LOGON;
  691.   {$EXTERNALSYM KERB_SMART_CARD_UNLOCK_LOGON}
  692.   TKerbSmartCardUnlockLogon = KERB_SMART_CARD_UNLOCK_LOGON;
  693.   PKerbSmartCardUnlockLogon = PKERB_SMART_CARD_UNLOCK_LOGON;
  694. //
  695. // Structure used for a ticket-only logon
  696. //
  697.   PKERB_TICKET_LOGON = ^KERB_TICKET_LOGON;
  698.   {$EXTERNALSYM PKERB_TICKET_LOGON}
  699.   _KERB_TICKET_LOGON = record
  700.     MessageType: KERB_LOGON_SUBMIT_TYPE;
  701.     Flags: ULONG;
  702.     ServiceTicketLength: ULONG;
  703.     TicketGrantingTicketLength: ULONG;
  704.     ServiceTicket: PUCHAR; // REQUIRED: Service ticket "host"
  705.     TicketGrantingTicket: PUCHAR; // OPTIONAL: User's encdoded in a KERB_CRED message, encrypted with session key from service ticket
  706.   end;
  707.   {$EXTERNALSYM _KERB_TICKET_LOGON}
  708.   KERB_TICKET_LOGON = _KERB_TICKET_LOGON;
  709.   {$EXTERNALSYM KERB_TICKET_LOGON}
  710.   TKerbTicketLogon = KERB_TICKET_LOGON;
  711.   PKerbTicketLogon = PKERB_TICKET_LOGON;
  712. //
  713. // Flags for the ticket logon flags field
  714. //
  715. const
  716.   KERB_LOGON_FLAG_ALLOW_EXPIRED_TICKET = $1;
  717.   {$EXTERNALSYM KERB_LOGON_FLAG_ALLOW_EXPIRED_TICKET}
  718. type
  719.   PKERB_TICKET_UNLOCK_LOGON = ^KERB_TICKET_UNLOCK_LOGON;
  720.   {$EXTERNALSYM PKERB_TICKET_UNLOCK_LOGON}
  721.   _KERB_TICKET_UNLOCK_LOGON = record
  722.     Logon: KERB_TICKET_LOGON;
  723.     LogonId: LUID;
  724.   end;
  725.   {$EXTERNALSYM _KERB_TICKET_UNLOCK_LOGON}
  726.   KERB_TICKET_UNLOCK_LOGON = _KERB_TICKET_UNLOCK_LOGON;
  727.   {$EXTERNALSYM KERB_TICKET_UNLOCK_LOGON}
  728.   TKerbTicketUnlockLogon = KERB_TICKET_UNLOCK_LOGON;
  729.   PKerbTicketUnlockLogon = PKERB_TICKET_UNLOCK_LOGON;
  730. //
  731. //  Used for S4U Client requests
  732. //
  733. //
  734.   _KERB_S4U_LOGON = record
  735.     MessageType: KERB_LOGON_SUBMIT_TYPE;
  736.     Flags: ULONG;
  737.     ClientUpn: UNICODE_STRING;   // REQUIRED: UPN for client
  738.     ClientRealm: UNICODE_STRING; // Optional: Client Realm, if known
  739.   end;
  740.   {$EXTERNALSYM _KERB_S4U_LOGON}
  741.   KERB_S4U_LOGON = _KERB_S4U_LOGON;
  742.   {$EXTERNALSYM KERB_S4U_LOGON}
  743.   PKERB_S4U_LOGON = ^KERB_S4U_LOGON;
  744.   {$EXTERNALSYM PKERB_S4U_LOGON}
  745.   TKerbS4ULogon = KERB_S4U_LOGON;
  746.   PKerbS4ULogon = PKERB_S4U_LOGON;  
  747. //
  748. // Use the same profile structure as MSV1_0
  749. //
  750. type
  751.   _KERB_PROFILE_BUFFER_TYPE = (
  752.     kpbtFiller0, kpbtFiller1,
  753.     KerbInteractiveProfile,
  754.     kpbtFiller3,
  755.     KerbSmartCardProfile,
  756.     kpbtFiller5,
  757.     KerbTicketProfile);
  758.   {$EXTERNALSYM _KERB_PROFILE_BUFFER_TYPE}
  759.   KERB_PROFILE_BUFFER_TYPE = _KERB_PROFILE_BUFFER_TYPE;
  760.   {$EXTERNALSYM KERB_PROFILE_BUFFER_TYPE}
  761.   PKERB_PROFILE_BUFFER_TYPE = ^KERB_PROFILE_BUFFER_TYPE;
  762.   {$EXTERNALSYM PKERB_PROFILE_BUFFER_TYPE}
  763.   TKerbProfileBufferType = KERB_PROFILE_BUFFER_TYPE;
  764.   PKerbProfileBufferType = PKERB_PROFILE_BUFFER_TYPE;
  765.   PKERB_INTERACTIVE_PROFILE = ^KERB_INTERACTIVE_PROFILE;
  766.   {$EXTERNALSYM PKERB_INTERACTIVE_PROFILE}
  767.   _KERB_INTERACTIVE_PROFILE = record
  768.     MessageType: KERB_PROFILE_BUFFER_TYPE;
  769.     LogonCount: USHORT;
  770.     BadPasswordCount: USHORT;
  771.     LogonTime: LARGE_INTEGER;
  772.     LogoffTime: LARGE_INTEGER;
  773.     KickOffTime: LARGE_INTEGER;
  774.     PasswordLastSet: LARGE_INTEGER;
  775.     PasswordCanChange: LARGE_INTEGER;
  776.     PasswordMustChange: LARGE_INTEGER;
  777.     LogonScript: UNICODE_STRING;
  778.     HomeDirectory: UNICODE_STRING;
  779.     FullName: UNICODE_STRING;
  780.     ProfilePath: UNICODE_STRING;
  781.     HomeDirectoryDrive: UNICODE_STRING;
  782.     LogonServer: UNICODE_STRING;
  783.     UserFlags: ULONG;
  784.   end;
  785.   {$EXTERNALSYM _KERB_INTERACTIVE_PROFILE}
  786.   KERB_INTERACTIVE_PROFILE = _KERB_INTERACTIVE_PROFILE;
  787.   {$EXTERNALSYM KERB_INTERACTIVE_PROFILE}
  788.   TKerbInteractiveProfile = KERB_INTERACTIVE_PROFILE;
  789.   PKerbInteractiveProfile = PKERB_INTERACTIVE_PROFILE;
  790. //
  791. // For smart card, we return a smart card profile, which is an interactive
  792. // profile plus a certificate
  793. //
  794.   PKERB_SMART_CARD_PROFILE = ^KERB_SMART_CARD_PROFILE;
  795.   {$EXTERNALSYM PKERB_SMART_CARD_PROFILE}
  796.   _KERB_SMART_CARD_PROFILE = record
  797.     Profile: KERB_INTERACTIVE_PROFILE;
  798.     CertificateSize: ULONG;
  799.     CertificateData: PUCHAR;
  800.   end;
  801.   {$EXTERNALSYM _KERB_SMART_CARD_PROFILE}
  802.   KERB_SMART_CARD_PROFILE = _KERB_SMART_CARD_PROFILE;
  803.   {$EXTERNALSYM KERB_SMART_CARD_PROFILE}
  804.   TKerbSmartCardProfile = KERB_SMART_CARD_PROFILE;
  805.   PKerbSmartCardProfile = PKERB_SMART_CARD_PROFILE;
  806. //
  807. // For a ticket logon profile, we return the session key from the ticket
  808. //
  809.   PKERB_CRYPTO_KEY = ^KERB_CRYPTO_KEY;
  810.   {$EXTERNALSYM PKERB_CRYPTO_KEY}
  811.   KERB_CRYPTO_KEY = record
  812.     KeyType: LONG;
  813.     Length: ULONG;
  814.     Value: PUCHAR;
  815.   end;
  816.   {$EXTERNALSYM KERB_CRYPTO_KEY}
  817.   TKerbCryptoKey = KERB_CRYPTO_KEY;
  818.   PKerbCryptoKey = PKERB_CRYPTO_KEY;
  819.   PKERB_TICKET_PROFILE = ^KERB_TICKET_PROFILE;
  820.   {$EXTERNALSYM PKERB_TICKET_PROFILE}
  821.   _KERB_TICKET_PROFILE = record
  822.     Profile: KERB_INTERACTIVE_PROFILE;
  823.     SessionKey: KERB_CRYPTO_KEY;
  824.   end;
  825.   {$EXTERNALSYM _KERB_TICKET_PROFILE}
  826.   KERB_TICKET_PROFILE = _KERB_TICKET_PROFILE;
  827.   {$EXTERNALSYM KERB_TICKET_PROFILE}
  828.   TKerbTicketProfile = KERB_TICKET_PROFILE;
  829.   PKerbTicketProfile = PKERB_TICKET_PROFILE;
  830.   _KERB_PROTOCOL_MESSAGE_TYPE = (
  831.     KerbDebugRequestMessage,
  832.     KerbQueryTicketCacheMessage,
  833.     KerbChangeMachinePasswordMessage,
  834.     KerbVerifyPacMessage,
  835.     KerbRetrieveTicketMessage,
  836.     KerbUpdateAddressesMessage,
  837.     KerbPurgeTicketCacheMessage,
  838.     KerbChangePasswordMessage,
  839.     KerbRetrieveEncodedTicketMessage,
  840.     KerbDecryptDataMessage,
  841.     KerbAddBindingCacheEntryMessage,
  842.     KerbSetPasswordMessage,
  843.     KerbSetPasswordExMessage,
  844.     KerbVerifyCredentialsMessage,
  845.     KerbQueryTicketCacheExMessage,
  846.     KerbPurgeTicketCacheExMessage,
  847.     KerbRefreshSmartcardCredentialsMessage,
  848.     KerbAddExtraCredentialsMessage,
  849.     KerbQuerySupplementalCredentialsMessage);
  850.   {$EXTERNALSYM _KERB_PROTOCOL_MESSAGE_TYPE}
  851.   KERB_PROTOCOL_MESSAGE_TYPE = _KERB_PROTOCOL_MESSAGE_TYPE;
  852.   {$EXTERNALSYM KERB_PROTOCOL_MESSAGE_TYPE}
  853.   PKERB_PROTOCOL_MESSAGE_TYPE = ^KERB_PROTOCOL_MESSAGE_TYPE;
  854.   {$EXTERNALSYM PKERB_PROTOCOL_MESSAGE_TYPE}
  855.   TKerbProtocolMessageType = KERB_PROTOCOL_MESSAGE_TYPE;
  856.   PKerbProtocolMessageType = PKERB_PROTOCOL_MESSAGE_TYPE;  
  857. //
  858. // Used both for retrieving tickets and for querying ticket cache
  859. //
  860.   PKERB_QUERY_TKT_CACHE_REQUEST = ^KERB_QUERY_TKT_CACHE_REQUEST;
  861.   {$EXTERNALSYM PKERB_QUERY_TKT_CACHE_REQUEST}
  862.   _KERB_QUERY_TKT_CACHE_REQUEST = record
  863.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  864.     LogonId: LUID;
  865.   end;
  866.   {$EXTERNALSYM _KERB_QUERY_TKT_CACHE_REQUEST}
  867.   KERB_QUERY_TKT_CACHE_REQUEST = _KERB_QUERY_TKT_CACHE_REQUEST;
  868.   {$EXTERNALSYM KERB_QUERY_TKT_CACHE_REQUEST}
  869.   TKerbQueryTktCacheRequest = KERB_QUERY_TKT_CACHE_REQUEST;
  870.   PKerbQueryTktCacheRequest = PKERB_QUERY_TKT_CACHE_REQUEST;
  871.   PKERB_TICKET_CACHE_INFO = ^KERB_TICKET_CACHE_INFO;
  872.   {$EXTERNALSYM PKERB_TICKET_CACHE_INFO}
  873.   _KERB_TICKET_CACHE_INFO = record
  874.     ServerName: UNICODE_STRING;
  875.     RealmName: UNICODE_STRING;
  876.     StartTime: LARGE_INTEGER;
  877.     EndTime: LARGE_INTEGER;
  878.     RenewTime: LARGE_INTEGER;
  879.     EncryptionType: LONG;
  880.     TicketFlags: ULONG;
  881.   end;
  882.   {$EXTERNALSYM _KERB_TICKET_CACHE_INFO}
  883.   KERB_TICKET_CACHE_INFO = _KERB_TICKET_CACHE_INFO;
  884.   {$EXTERNALSYM KERB_TICKET_CACHE_INFO}
  885.   TKerbTicketCacheInfo = KERB_TICKET_CACHE_INFO;
  886.   PKerbTicketCacheInfo = PKERB_TICKET_CACHE_INFO;
  887.   _KERB_TICKET_CACHE_INFO_EX = record
  888.     ClientName: UNICODE_STRING;
  889.     ClientRealm: UNICODE_STRING;
  890.     ServerName: UNICODE_STRING;
  891.     ServerRealm: UNICODE_STRING;
  892.     StartTime: LARGE_INTEGER;
  893.     EndTime: LARGE_INTEGER;
  894.     RenewTime: LARGE_INTEGER;
  895.     EncryptionType: LONG;
  896.     TicketFlags: ULONG;
  897.   end;
  898.   {$EXTERNALSYM _KERB_TICKET_CACHE_INFO_EX}
  899.   KERB_TICKET_CACHE_INFO_EX = _KERB_TICKET_CACHE_INFO_EX;
  900.   {$EXTERNALSYM KERB_TICKET_CACHE_INFO_EX}
  901.   PKERB_TICKET_CACHE_INFO_EX = ^KERB_TICKET_CACHE_INFO_EX;
  902.   {$EXTERNALSYM PKERB_TICKET_CACHE_INFO_EX}
  903.   TKerbTicketCacheInfoEx = KERB_TICKET_CACHE_INFO_EX;
  904.   PKerbTicketCacheInfoEx = PKERB_TICKET_CACHE_INFO_EX;  
  905.   PKERB_QUERY_TKT_CACHE_RESPONSE = ^KERB_QUERY_TKT_CACHE_RESPONSE;
  906.   {$EXTERNALSYM PKERB_QUERY_TKT_CACHE_RESPONSE}
  907.   _KERB_QUERY_TKT_CACHE_RESPONSE = record
  908.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  909.     CountOfTickets: ULONG;
  910.     Tickets: array [0..ANYSIZE_ARRAY - 1] of KERB_TICKET_CACHE_INFO;
  911.   end;
  912.   {$EXTERNALSYM _KERB_QUERY_TKT_CACHE_RESPONSE}
  913.   KERB_QUERY_TKT_CACHE_RESPONSE = _KERB_QUERY_TKT_CACHE_RESPONSE;
  914.   {$EXTERNALSYM KERB_QUERY_TKT_CACHE_RESPONSE}
  915.   TKerbQueryTktCacheResponse = KERB_QUERY_TKT_CACHE_RESPONSE;
  916.   PKerbQueryTktCacheResponse = PKERB_QUERY_TKT_CACHE_RESPONSE;
  917.   _KERB_QUERY_TKT_CACHE_EX_RESPONSE = record
  918.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  919.     CountOfTickets: ULONG;
  920.     Tickets: array [0..ANYSIZE_ARRAY - 1] of KERB_TICKET_CACHE_INFO_EX;
  921.   end;
  922.   {$EXTERNALSYM _KERB_QUERY_TKT_CACHE_EX_RESPONSE}
  923.   KERB_QUERY_TKT_CACHE_EX_RESPONSE = _KERB_QUERY_TKT_CACHE_EX_RESPONSE;
  924.   {$EXTERNALSYM KERB_QUERY_TKT_CACHE_EX_RESPONSE}
  925.   PKERB_QUERY_TKT_CACHE_EX_RESPONSE = ^KERB_QUERY_TKT_CACHE_EX_RESPONSE;
  926.   {$EXTERNALSYM PKERB_QUERY_TKT_CACHE_EX_RESPONSE}
  927.   TKerbQueryTktCacheExResponse = KERB_QUERY_TKT_CACHE_EX_RESPONSE;
  928.   PKerbQueryTktCacheExResponse = PKERB_QUERY_TKT_CACHE_EX_RESPONSE;  
  929. //
  930. // Types for retrieving encoded ticket from the cache
  931. //
  932.   _SecHandle = record
  933.     dwLower: ULONG_PTR;
  934.     dwUpper: ULONG_PTR;
  935.   end;
  936.   {$EXTERNALSYM _SecHandle}
  937.   SecHandle = _SecHandle;
  938.   {$EXTERNALSYM SecHandle}
  939.   PSecHandle = ^SecHandle;
  940.   {$EXTERNALSYM PSecHandle}
  941. // Ticket Flags
  942. const
  943.   KERB_USE_DEFAULT_TICKET_FLAGS = $0;
  944.   {$EXTERNALSYM KERB_USE_DEFAULT_TICKET_FLAGS}
  945. // CacheOptions
  946.   KERB_RETRIEVE_TICKET_DEFAULT  = $0;
  947.   {$EXTERNALSYM KERB_RETRIEVE_TICKET_DEFAULT}
  948.   KERB_RETRIEVE_TICKET_DONT_USE_CACHE = $1;
  949.   {$EXTERNALSYM KERB_RETRIEVE_TICKET_DONT_USE_CACHE}
  950.   KERB_RETRIEVE_TICKET_USE_CACHE_ONLY = $2;
  951.   {$EXTERNALSYM KERB_RETRIEVE_TICKET_USE_CACHE_ONLY}
  952.   KERB_RETRIEVE_TICKET_USE_CREDHANDLE = $4;
  953.   {$EXTERNALSYM KERB_RETRIEVE_TICKET_USE_CREDHANDLE}
  954.   KERB_RETRIEVE_TICKET_AS_KERB_CRED   = $8;
  955.   {$EXTERNALSYM KERB_RETRIEVE_TICKET_AS_KERB_CRED}
  956.   KERB_RETRIEVE_TICKET_WITH_SEC_CRED  = $10;
  957.   {$EXTERNALSYM KERB_RETRIEVE_TICKET_WITH_SEC_CRED}
  958. // Encryption Type options
  959.   KERB_ETYPE_DEFAULT = $0; // don't specify etype in tkt req.
  960.   {$EXTERNALSYM KERB_ETYPE_DEFAULT}
  961. type
  962.   _KERB_AUTH_DATA = record
  963.     Type_: ULONG;
  964.     Length: ULONG;
  965.     Data: PUCHAR;
  966.   end;
  967.   {$EXTERNALSYM _KERB_AUTH_DATA}
  968.   KERB_AUTH_DATA = _KERB_AUTH_DATA;
  969.   {$EXTERNALSYM KERB_AUTH_DATA}
  970.   PKERB_AUTH_DATA = ^KERB_AUTH_DATA;
  971.   {$EXTERNALSYM PKERB_AUTH_DATA}
  972.   TKerbAuthData = KERB_AUTH_DATA;
  973.   PKerbAuthData = PKERB_AUTH_DATA;
  974.   _KERB_NET_ADDRESS = record
  975.     Family: ULONG;
  976.     Length: ULONG;
  977.     Address: PCHAR;
  978.   end;
  979.   {$EXTERNALSYM _KERB_NET_ADDRESS}
  980.   KERB_NET_ADDRESS = _KERB_NET_ADDRESS;
  981.   {$EXTERNALSYM KERB_NET_ADDRESS}
  982.   PKERB_NET_ADDRESS = ^KERB_NET_ADDRESS;
  983.   {$EXTERNALSYM PKERB_NET_ADDRESS}
  984.   TKerbNetAddress = KERB_NET_ADDRESS;
  985.   PKerbNetAddress = PKERB_NET_ADDRESS;
  986.   _KERB_NET_ADDRESSES = record
  987.     Number: ULONG;
  988.     Addresses: array [0..ANYSIZE_ARRAY - 1] of KERB_NET_ADDRESS;
  989.   end;
  990.   {$EXTERNALSYM _KERB_NET_ADDRESSES}
  991.   KERB_NET_ADDRESSES = _KERB_NET_ADDRESSES;
  992.   {$EXTERNALSYM KERB_NET_ADDRESSES}
  993.   PKERB_NET_ADDRESSES = ^KERB_NET_ADDRESSES;
  994.   {$EXTERNALSYM PKERB_NET_ADDRESSES}
  995.   TKerbNetAddresses = KERB_NET_ADDRESSES;
  996.   PKerbNetAddresses = PKERB_NET_ADDRESSES;  
  997. //
  998. // Types for the information about a ticket
  999. //
  1000. type
  1001.   PKERB_EXTERNAL_NAME = ^KERB_EXTERNAL_NAME;
  1002.   {$EXTERNALSYM PKERB_EXTERNAL_NAME}
  1003.   _KERB_EXTERNAL_NAME = record
  1004.     NameType: SHORT;
  1005.     NameCount: USHORT;
  1006.     Names: array [0..ANYSIZE_ARRAY - 1] of UNICODE_STRING;
  1007.   end;
  1008.   {$EXTERNALSYM _KERB_EXTERNAL_NAME}
  1009.   KERB_EXTERNAL_NAME = _KERB_EXTERNAL_NAME;
  1010.   {$EXTERNALSYM KERB_EXTERNAL_NAME}
  1011.   TKerbExternalName = KERB_EXTERNAL_NAME;
  1012.   PKerbExternalName = PKERB_EXTERNAL_NAME;
  1013.   PKERB_EXTERNAL_TICKET = ^KERB_EXTERNAL_TICKET;
  1014.   {$EXTERNALSYM PKERB_EXTERNAL_TICKET}
  1015.   _KERB_EXTERNAL_TICKET = record
  1016.     ServiceName: PKERB_EXTERNAL_NAME;
  1017.     TargetName: PKERB_EXTERNAL_NAME;
  1018.     ClientName: PKERB_EXTERNAL_NAME;
  1019.     DomainName: UNICODE_STRING;
  1020.     TargetDomainName: UNICODE_STRING;  // contains ClientDomainName
  1021.     AltTargetDomainName: UNICODE_STRING;
  1022.     SessionKey: KERB_CRYPTO_KEY;
  1023.     TicketFlags: ULONG;
  1024.     Flags: ULONG;
  1025.     KeyExpirationTime: LARGE_INTEGER;
  1026.     StartTime: LARGE_INTEGER;
  1027.     EndTime: LARGE_INTEGER;
  1028.     RenewUntil: LARGE_INTEGER;
  1029.     TimeSkew: LARGE_INTEGER;
  1030.     EncodedTicketSize: ULONG;
  1031.     EncodedTicket: PUCHAR;
  1032.   end;
  1033.   {$EXTERNALSYM _KERB_EXTERNAL_TICKET}
  1034.   KERB_EXTERNAL_TICKET = _KERB_EXTERNAL_TICKET;
  1035.   {$EXTERNALSYM KERB_EXTERNAL_TICKET}
  1036.   TKerbExternalTicket = KERB_EXTERNAL_TICKET;
  1037.   PKerbExternalTicket = PKERB_EXTERNAL_TICKET;
  1038.   _KERB_RETRIEVE_TKT_REQUEST = record
  1039.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1040.     LogonId: LUID;
  1041.     TargetName: UNICODE_STRING;
  1042.     TicketFlags: ULONG;
  1043.     CacheOptions: ULONG;
  1044.     EncryptionType: LONG;
  1045.     CredentialsHandle: SecHandle;
  1046.   end;
  1047.   {$EXTERNALSYM _KERB_RETRIEVE_TKT_REQUEST}
  1048.   KERB_RETRIEVE_TKT_REQUEST = _KERB_RETRIEVE_TKT_REQUEST;
  1049.   {$EXTERNALSYM KERB_RETRIEVE_TKT_REQUEST}
  1050.   PKERB_RETRIEVE_TKT_REQUEST = ^KERB_RETRIEVE_TKT_REQUEST;
  1051.   {$EXTERNALSYM PKERB_RETRIEVE_TKT_REQUEST}
  1052.   TKerbRetrieveTktRequest = KERB_RETRIEVE_TKT_REQUEST;
  1053.   PKerbRetrieveTktRequest = PKERB_RETRIEVE_TKT_REQUEST;
  1054.   PKERB_RETRIEVE_TKT_RESPONSE = ^KERB_RETRIEVE_TKT_RESPONSE;
  1055.   {$EXTERNALSYM PKERB_RETRIEVE_TKT_RESPONSE}
  1056.   _KERB_RETRIEVE_TKT_RESPONSE = record
  1057.     Ticket: KERB_EXTERNAL_TICKET;
  1058.   end;
  1059.   {$EXTERNALSYM _KERB_RETRIEVE_TKT_RESPONSE}
  1060.   KERB_RETRIEVE_TKT_RESPONSE = _KERB_RETRIEVE_TKT_RESPONSE;
  1061.   {$EXTERNALSYM KERB_RETRIEVE_TKT_RESPONSE}
  1062.   TKerbRetrieveTktResponse = KERB_RETRIEVE_TKT_RESPONSE;
  1063.   PKerbRetrieveTktResponse = PKERB_RETRIEVE_TKT_RESPONSE;
  1064. //
  1065. // Used to purge entries from the ticket cache
  1066. //
  1067.   PKERB_PURGE_TKT_CACHE_REQUEST = ^KERB_PURGE_TKT_CACHE_REQUEST;
  1068.   {$EXTERNALSYM PKERB_PURGE_TKT_CACHE_REQUEST}
  1069.   _KERB_PURGE_TKT_CACHE_REQUEST = record
  1070.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1071.     LogonId: LUID;
  1072.     ServerName: UNICODE_STRING;
  1073.     RealmName: UNICODE_STRING;
  1074.   end;
  1075.   {$EXTERNALSYM _KERB_PURGE_TKT_CACHE_REQUEST}
  1076.   KERB_PURGE_TKT_CACHE_REQUEST = _KERB_PURGE_TKT_CACHE_REQUEST;
  1077.   {$EXTERNALSYM KERB_PURGE_TKT_CACHE_REQUEST}
  1078.   TKerbPurgeTktCacheRequest = KERB_PURGE_TKT_CACHE_REQUEST;
  1079.   PKerbPurgeTktCacheRequest = PKERB_PURGE_TKT_CACHE_REQUEST;
  1080. //
  1081. // Flags for purge requests
  1082. //
  1083. const
  1084.   KERB_PURGE_ALL_TICKETS = 1;
  1085.   {$EXTERNALSYM KERB_PURGE_ALL_TICKETS}
  1086. type
  1087.   _KERB_PURGE_TKT_CACHE_EX_REQUEST = record
  1088.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1089.     LogonId: LUID;
  1090.     Flags: ULONG;
  1091.     TicketTemplate: KERB_TICKET_CACHE_INFO_EX;
  1092.   end;
  1093.   {$EXTERNALSYM _KERB_PURGE_TKT_CACHE_EX_REQUEST}
  1094.   KERB_PURGE_TKT_CACHE_EX_REQUEST = _KERB_PURGE_TKT_CACHE_EX_REQUEST;
  1095.   {$EXTERNALSYM KERB_PURGE_TKT_CACHE_EX_REQUEST}
  1096.   PKERB_PURGE_TKT_CACHE_EX_REQUEST = ^KERB_PURGE_TKT_CACHE_EX_REQUEST;
  1097.   {$EXTERNALSYM PKERB_PURGE_TKT_CACHE_EX_REQUEST}
  1098.   TKerbPurgeTktCacheExRequest = KERB_PURGE_TKT_CACHE_EX_REQUEST;
  1099.   PKerbPurgeTktCacheExRequest = PKERB_PURGE_TKT_CACHE_EX_REQUEST;
  1100. //
  1101. // KerbChangePassword
  1102. //
  1103. // KerbChangePassword changes the password on the KDC account plus
  1104. //  the password cache and logon credentials if applicable.
  1105. //
  1106. //
  1107.   PKERB_CHANGEPASSWORD_REQUEST = ^KERB_CHANGEPASSWORD_REQUEST;
  1108.   {$EXTERNALSYM PKERB_CHANGEPASSWORD_REQUEST}
  1109.   _KERB_CHANGEPASSWORD_REQUEST = record
  1110.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1111.     DomainName: UNICODE_STRING;
  1112.     AccountName: UNICODE_STRING;
  1113.     OldPassword: UNICODE_STRING;
  1114.     NewPassword: UNICODE_STRING;
  1115.     Impersonating: ByteBool;
  1116.   end;
  1117.   {$EXTERNALSYM _KERB_CHANGEPASSWORD_REQUEST}
  1118.   KERB_CHANGEPASSWORD_REQUEST = _KERB_CHANGEPASSWORD_REQUEST;
  1119.   {$EXTERNALSYM KERB_CHANGEPASSWORD_REQUEST}
  1120.   TKerbChangepasswordRequest = KERB_CHANGEPASSWORD_REQUEST;
  1121.   PKerbChangepasswordRequest = PKERB_CHANGEPASSWORD_REQUEST;
  1122. //
  1123. // KerbSetPassword
  1124. //
  1125. // KerbSetPassword changes the password on the KDC account plus
  1126. //  the password cache and logon credentials if applicable.
  1127. //
  1128. //
  1129.   PKERB_SETPASSWORD_REQUEST = ^KERB_SETPASSWORD_REQUEST;
  1130.   {$EXTERNALSYM PKERB_SETPASSWORD_REQUEST}
  1131.   _KERB_SETPASSWORD_REQUEST = record
  1132.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1133.     LogonId: LUID;
  1134.     CredentialsHandle: SecHandle;
  1135.     Flags: ULONG;
  1136.     DomainName: UNICODE_STRING;
  1137.     AccountName: UNICODE_STRING;
  1138.     Password: UNICODE_STRING;
  1139.   end;
  1140.   {$EXTERNALSYM _KERB_SETPASSWORD_REQUEST}
  1141.   KERB_SETPASSWORD_REQUEST = _KERB_SETPASSWORD_REQUEST;
  1142.   {$EXTERNALSYM KERB_SETPASSWORD_REQUEST}
  1143.   TKerbSetpasswordRequest = KERB_SETPASSWORD_REQUEST;
  1144.   PKerbSetpasswordRequest = PKERB_SETPASSWORD_REQUEST;
  1145.   _KERB_SETPASSWORD_EX_REQUEST = record
  1146.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1147.     LogonId: LUID;
  1148.     CredentialsHandle: SecHandle;
  1149.     Flags: ULONG;
  1150.     AccountRealm: UNICODE_STRING;
  1151.     AccountName: UNICODE_STRING;
  1152.     Password: UNICODE_STRING;
  1153.     ClientRealm: UNICODE_STRING;
  1154.     ClientName: UNICODE_STRING;
  1155.     Impersonating: BOOLEAN;
  1156.     KdcAddress: UNICODE_STRING;
  1157.     KdcAddressType: ULONG;
  1158.   end;
  1159.   {$EXTERNALSYM _KERB_SETPASSWORD_EX_REQUEST}
  1160.   KERB_SETPASSWORD_EX_REQUEST = _KERB_SETPASSWORD_EX_REQUEST;
  1161.   {$EXTERNALSYM KERB_SETPASSWORD_EX_REQUEST}
  1162.   PKERB_SETPASSWORD_EX_REQUEST = ^KERB_SETPASSWORD_EX_REQUEST;
  1163.   {$EXTERNALSYM PKERB_SETPASSWORD_EX_REQUEST}
  1164.   TKerbSetPasswordExRequest = KERB_SETPASSWORD_EX_REQUEST;
  1165.   PKerbSetPasswordExRequest = PKERB_SETPASSWORD_EX_REQUEST;  
  1166. const
  1167.   DS_UNKNOWN_ADDRESS_TYPE     = 0; // anything *but* IP
  1168.   {$EXTERNALSYM DS_UNKNOWN_ADDRESS_TYPE}
  1169.   KERB_SETPASS_USE_LOGONID    = 1;
  1170.   {$EXTERNALSYM KERB_SETPASS_USE_LOGONID}
  1171.   KERB_SETPASS_USE_CREDHANDLE = 2;
  1172.   {$EXTERNALSYM KERB_SETPASS_USE_CREDHANDLE}
  1173. type
  1174.   PKERB_DECRYPT_REQUEST = ^KERB_DECRYPT_REQUEST;
  1175.   {$EXTERNALSYM PKERB_DECRYPT_REQUEST}
  1176.   _KERB_DECRYPT_REQUEST = record
  1177.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1178.     LogonId: LUID;
  1179.     Flags: ULONG;
  1180.     CryptoType: LONG;
  1181.     KeyUsage: LONG;
  1182.     Key: KERB_CRYPTO_KEY; // optional
  1183.     EncryptedDataSize: ULONG;
  1184.     InitialVectorSize: ULONG;
  1185.     InitialVector: PUCHAR;
  1186.     EncryptedData: PUCHAR;
  1187.   end;
  1188.   {$EXTERNALSYM _KERB_DECRYPT_REQUEST}
  1189.   KERB_DECRYPT_REQUEST = _KERB_DECRYPT_REQUEST;
  1190.   {$EXTERNALSYM KERB_DECRYPT_REQUEST}
  1191.   TKerbDecryptRequest = KERB_DECRYPT_REQUEST;
  1192.   PKerbDecryptRequest = PKERB_DECRYPT_REQUEST;
  1193. //
  1194. // If set, use the primary key from the current logon session of the one provided in the LogonId field.
  1195. // Otherwise, use the Key in the KERB_DECRYPT_MESSAGE.
  1196. const
  1197.   KERB_DECRYPT_FLAG_DEFAULT_KEY = $00000001;
  1198.   {$EXTERNALSYM KERB_DECRYPT_FLAG_DEFAULT_KEY}
  1199. type
  1200.   PKERB_DECRYPT_RESPONSE = ^KERB_DECRYPT_RESPONSE;
  1201.   {$EXTERNALSYM PKERB_DECRYPT_RESPONSE}
  1202.   _KERB_DECRYPT_RESPONSE = record
  1203.     DecryptedData: array [0..ANYSIZE_ARRAY - 1] of UCHAR;
  1204.   end;
  1205.   {$EXTERNALSYM _KERB_DECRYPT_RESPONSE}
  1206.   KERB_DECRYPT_RESPONSE = _KERB_DECRYPT_RESPONSE;
  1207.   {$EXTERNALSYM KERB_DECRYPT_RESPONSE}
  1208.   TKerbDecryptResponse = KERB_DECRYPT_RESPONSE;
  1209.   PKerbDecryptResponse = PKERB_DECRYPT_RESPONSE;
  1210. //
  1211. // Request structure for adding a binding cache entry. TCB privilege
  1212. // is required for this operation.
  1213. //
  1214.   PKERB_ADD_BINDING_CACHE_ENTRY_REQUEST = ^KERB_ADD_BINDING_CACHE_ENTRY_REQUEST;
  1215.   {$EXTERNALSYM PKERB_ADD_BINDING_CACHE_ENTRY_REQUEST}
  1216.   _KERB_ADD_BINDING_CACHE_ENTRY_REQUEST = record
  1217.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1218.     RealmName: UNICODE_STRING;
  1219.     KdcAddress: UNICODE_STRING;
  1220.     AddressType: ULONG; //dsgetdc.h DS_NETBIOS_ADDRESS||DS_INET_ADDRESS
  1221.   end;
  1222.   {$EXTERNALSYM _KERB_ADD_BINDING_CACHE_ENTRY_REQUEST}
  1223.   KERB_ADD_BINDING_CACHE_ENTRY_REQUEST = _KERB_ADD_BINDING_CACHE_ENTRY_REQUEST;
  1224.   {$EXTERNALSYM KERB_ADD_BINDING_CACHE_ENTRY_REQUEST}
  1225.   TKerbAddBindingCacheEntryRequest = KERB_ADD_BINDING_CACHE_ENTRY_REQUEST;
  1226.   PKerbAddBindingCacheEntryRequest = PKERB_ADD_BINDING_CACHE_ENTRY_REQUEST;
  1227. //
  1228. // Request structure for reacquiring smartcard credentials for a 
  1229. // given LUID.
  1230. // Requires TCB.
  1231. //
  1232.   _KERB_REFRESH_SCCRED_REQUEST = record
  1233.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1234.     CredentialBlob: UNICODE_STRING;  // optional
  1235.     LogonId: LUID;
  1236.     Flags: ULONG;
  1237.   end;
  1238.   {$EXTERNALSYM _KERB_REFRESH_SCCRED_REQUEST}
  1239.   KERB_REFRESH_SCCRED_REQUEST = _KERB_REFRESH_SCCRED_REQUEST;
  1240.   {$EXTERNALSYM KERB_REFRESH_SCCRED_REQUEST}
  1241.   PKERB_REFRESH_SCCRED_REQUEST = ^KERB_REFRESH_SCCRED_REQUEST;
  1242.   {$EXTERNALSYM PKERB_REFRESH_SCCRED_REQUEST}
  1243.   TKerbRefreshScCredRequest = KERB_REFRESH_SCCRED_REQUEST;
  1244.   PKerbRefreshScCredRequest = PKERB_REFRESH_SCCRED_REQUEST;  
  1245. //
  1246. // Flags for KERB_REFRESH_SCCRED_REQUEST
  1247. //
  1248. // KERB_REFRESH_SCCRED_RELEASE
  1249. //  Release the smartcard handle for LUID
  1250. //
  1251. //      KERB_REFRESH_SCCRED_GETTGT
  1252. // Use the certificate hash in the blob to get a TGT for the logon 
  1253. // session.
  1254. //
  1255. const
  1256.   KERB_REFRESH_SCCRED_RELEASE = $0;
  1257.   {$EXTERNALSYM KERB_REFRESH_SCCRED_RELEASE}
  1258.   KERB_REFRESH_SCCRED_GETTGT  = $1;
  1259.   {$EXTERNALSYM KERB_REFRESH_SCCRED_GETTGT}
  1260. //
  1261. // Request structure for adding extra Server credentials to a given
  1262. // logon session.  Only applicable during AcceptSecurityContext, and
  1263. // requires TCB to alter "other" creds
  1264. //
  1265. type
  1266.   _KERB_ADD_CREDENTIALS_REQUEST = record
  1267.     MessageType: KERB_PROTOCOL_MESSAGE_TYPE;
  1268.     UserName: UNICODE_STRING;
  1269.     DomainName: UNICODE_STRING;
  1270.     Password: UNICODE_STRING;
  1271.     LogonId: LUID; // optional
  1272.     Flags: ULONG;
  1273.   end;
  1274.   {$EXTERNALSYM _KERB_ADD_CREDENTIALS_REQUEST}
  1275.   KERB_ADD_CREDENTIALS_REQUEST = _KERB_ADD_CREDENTIALS_REQUEST;
  1276.   {$EXTERNALSYM KERB_ADD_CREDENTIALS_REQUEST}
  1277.   PKERB_ADD_CREDENTIALS_REQUEST = ^KERB_ADD_CREDENTIALS_REQUEST;
  1278.   {$EXTERNALSYM PKERB_ADD_CREDENTIALS_REQUEST}
  1279.   TKerbAddCredentialsRequest = KERB_ADD_CREDENTIALS_REQUEST;
  1280.   PKerbAddCredentialsRequest = PKERB_ADD_CREDENTIALS_REQUEST;
  1281. const
  1282.   KERB_REQUEST_ADD_CREDENTIAL     = 1;
  1283.   {$EXTERNALSYM KERB_REQUEST_ADD_CREDENTIAL}
  1284.   KERB_REQUEST_REPLACE_CREDENTIAL = 2;
  1285.   {$EXTERNALSYM KERB_REQUEST_REPLACE_CREDENTIAL}
  1286.   KERB_REQUEST_REMOVE_CREDENTIAL  = 4;
  1287.   {$EXTERNALSYM KERB_REQUEST_REMOVE_CREDENTIAL}
  1288. implementation
  1289. function LSA_SUCCESS(Error: NTSTATUS): BOOL;
  1290. begin
  1291.  Result := LONG(Error) > 0;
  1292. end;
  1293. const
  1294.   secur32 = 'secur32.dll';
  1295.   advapi32 = 'advapi32.dll';
  1296. {$IFDEF DYNAMIC_LINK}
  1297. var
  1298.   _LsaRegisterLogonProcess: Pointer;
  1299. function LsaRegisterLogonProcess;
  1300. begin
  1301.   GetProcedureAddress(_LsaRegisterLogonProcess, secur32, 'LsaRegisterLogonProcess');
  1302.   asm
  1303.     mov esp, ebp
  1304.     pop ebp
  1305.     jmp [_LsaRegisterLogonProcess]
  1306.   end;
  1307. end;
  1308. {$ELSE}
  1309. function LsaRegisterLogonProcess; external secur32 name 'LsaRegisterLogonProcess';
  1310. {$ENDIF DYNAMIC_LINK}
  1311. {$IFDEF DYNAMIC_LINK}
  1312. var
  1313.   _LsaLogonUser: Pointer;
  1314. function LsaLogonUser;
  1315. begin
  1316.   GetProcedureAddress(_LsaLogonUser, secur32, 'LsaLogonUser');
  1317.   asm
  1318.     mov esp, ebp
  1319.     pop ebp
  1320.     jmp [_LsaLogonUser]
  1321.   end;
  1322. end;
  1323. {$ELSE}
  1324. function LsaLogonUser; external secur32 name 'LsaLogonUser';
  1325. {$ENDIF DYNAMIC_LINK}
  1326. {$IFDEF DYNAMIC_LINK}
  1327. var
  1328.   _LsaLookupAuthenticationPackage: Pointer;
  1329. function LsaLookupAuthenticationPackage;
  1330. begin
  1331.   GetProcedureAddress(_LsaLookupAuthenticationPackage, secur32, 'LsaLookupAuthenticationPackage');
  1332.   asm
  1333.     mov esp, ebp
  1334.     pop ebp
  1335.     jmp [_LsaLookupAuthenticationPackage]
  1336.   end;
  1337. end;
  1338. {$ELSE}
  1339. function LsaLookupAuthenticationPackage; external secur32 name 'LsaLookupAuthenticationPackage';
  1340. {$ENDIF DYNAMIC_LINK}
  1341. {$IFDEF DYNAMIC_LINK}
  1342. var
  1343.   _LsaFreeReturnBuffer: Pointer;
  1344. function LsaFreeReturnBuffer;
  1345. begin
  1346.   GetProcedureAddress(_LsaFreeReturnBuffer, secur32, 'LsaFreeReturnBuffer');
  1347.   asm
  1348.     mov esp, ebp
  1349.     pop ebp
  1350.     jmp [_LsaFreeReturnBuffer]
  1351.   end;
  1352. end;
  1353. {$ELSE}
  1354. function LsaFreeReturnBuffer; external secur32 name 'LsaFreeReturnBuffer';
  1355. {$ENDIF DYNAMIC_LINK}
  1356. {$IFDEF DYNAMIC_LINK}
  1357. var
  1358.   _LsaCallAuthenticationPackage: Pointer;
  1359. function LsaCallAuthenticationPackage;
  1360. begin
  1361.   GetProcedureAddress(_LsaCallAuthenticationPackage, secur32, 'LsaCallAuthenticationPackage');
  1362.   asm
  1363.     mov esp, ebp
  1364.     pop ebp
  1365.     jmp [_LsaCallAuthenticationPackage]
  1366.   end;
  1367. end;
  1368. {$ELSE}
  1369. function LsaCallAuthenticationPackage; external secur32 name 'LsaCallAuthenticationPackage';
  1370. {$ENDIF DYNAMIC_LINK}
  1371. {$IFDEF DYNAMIC_LINK}
  1372. var
  1373.   _LsaDeregisterLogonProcess: Pointer;
  1374. function LsaDeregisterLogonProcess;
  1375. begin
  1376.   GetProcedureAddress(_LsaDeregisterLogonProcess, secur32, 'LsaDeregisterLogonProcess');
  1377.   asm
  1378.     mov esp, ebp
  1379.     pop ebp
  1380.     jmp [_LsaDeregisterLogonProcess]
  1381.   end;
  1382. end;
  1383. {$ELSE}
  1384. function LsaDeregisterLogonProcess; external secur32 name 'LsaDeregisterLogonProcess';
  1385. {$ENDIF DYNAMIC_LINK}
  1386. {$IFDEF DYNAMIC_LINK}
  1387. var
  1388.   _LsaConnectUntrusted: Pointer;
  1389. function LsaConnectUntrusted;
  1390. begin
  1391.   GetProcedureAddress(_LsaConnectUntrusted, secur32, 'LsaConnectUntrusted');
  1392.   asm
  1393.     mov esp, ebp
  1394.     pop ebp
  1395.     jmp [_LsaConnectUntrusted]
  1396.   end;
  1397. end;
  1398. {$ELSE}
  1399. function LsaConnectUntrusted; external secur32 name 'LsaConnectUntrusted';
  1400. {$ENDIF DYNAMIC_LINK}
  1401. {$IFDEF DYNAMIC_LINK}
  1402. var
  1403.   _LsaFreeMemory: Pointer;
  1404. function LsaFreeMemory;
  1405. begin
  1406.   GetProcedureAddress(_LsaFreeMemory, advapi32, 'LsaFreeMemory');
  1407.   asm
  1408.     mov esp, ebp
  1409.     pop ebp
  1410.     jmp [_LsaFreeMemory]
  1411.   end;
  1412. end;
  1413. {$ELSE}
  1414. function LsaFreeMemory; external advapi32 name 'LsaFreeMemory';
  1415. {$ENDIF DYNAMIC_LINK}
  1416. {$IFDEF DYNAMIC_LINK}
  1417. var
  1418.   _LsaClose: Pointer;
  1419. function LsaClose;
  1420. begin
  1421.   GetProcedureAddress(_LsaClose, advapi32, 'LsaClose');
  1422.   asm
  1423.     mov esp, ebp
  1424.     pop ebp
  1425.     jmp [_LsaClose]
  1426.   end;
  1427. end;
  1428. {$ELSE}
  1429. function LsaClose; external advapi32 name 'LsaClose';
  1430. {$ENDIF DYNAMIC_LINK}
  1431. {$IFDEF DYNAMIC_LINK}
  1432. var
  1433.   _LsaOpenPolicy: Pointer;
  1434. function LsaOpenPolicy;
  1435. begin
  1436.   GetProcedureAddress(_LsaOpenPolicy, advapi32, 'LsaOpenPolicy');
  1437.   asm
  1438.     mov esp, ebp
  1439.     pop ebp
  1440.     jmp [_LsaOpenPolicy]
  1441.   end;
  1442. end;
  1443. {$ELSE}
  1444. function LsaOpenPolicy; external advapi32 name 'LsaOpenPolicy';
  1445. {$ENDIF DYNAMIC_LINK}
  1446. {$IFDEF DYNAMIC_LINK}
  1447. var
  1448.   _LsaEnumerateLogonSessions: Pointer;
  1449. function LsaEnumerateLogonSessions;
  1450. begin
  1451.   GetProcedureAddress(_LsaEnumerateLogonSessions, secur32, 'LsaEnumerateLogonSessions');
  1452.   asm
  1453.     mov esp, ebp
  1454.     pop ebp
  1455.     jmp [_LsaEnumerateLogonSessions]
  1456.   end;
  1457. end;
  1458. {$ELSE}
  1459. function LsaEnumerateLogonSessions; external secur32 name 'LsaEnumerateLogonSessions';
  1460. {$ENDIF DYNAMIC_LINK}
  1461. {$IFDEF DYNAMIC_LINK}
  1462. var
  1463.   _LsaGetLogonSessionData: Pointer;
  1464. function LsaGetLogonSessionData;
  1465. begin
  1466.   GetProcedureAddress(_LsaGetLogonSessionData, secur32, 'LsaGetLogonSessionData');
  1467.   asm
  1468.     mov esp, ebp
  1469.     pop ebp
  1470.     jmp [_LsaGetLogonSessionData]
  1471.   end;
  1472. end;
  1473. {$ELSE}
  1474. function LsaGetLogonSessionData; external secur32 name 'LsaGetLogonSessionData';
  1475. {$ENDIF DYNAMIC_LINK}
  1476. {$IFDEF DYNAMIC_LINK}
  1477. var
  1478.   _LsaQueryInformationPolicy: Pointer;
  1479. function LsaQueryInformationPolicy;
  1480. begin
  1481.   GetProcedureAddress(_LsaQueryInformationPolicy, advapi32, 'LsaQueryInformationPolicy');
  1482.   asm
  1483.     mov esp, ebp
  1484.     pop ebp
  1485.     jmp [_LsaQueryInformationPolicy]
  1486.   end;
  1487. end;
  1488. {$ELSE}
  1489. function LsaQueryInformationPolicy; external advapi32 name 'LsaQueryInformationPolicy';
  1490. {$ENDIF DYNAMIC_LINK}
  1491. {$IFDEF DYNAMIC_LINK}
  1492. var
  1493.   _LsaSetInformationPolicy: Pointer;
  1494. function LsaSetInformationPolicy;
  1495. begin
  1496.   GetProcedureAddress(_LsaSetInformationPolicy, advapi32, 'LsaSetInformationPolicy');
  1497.   asm
  1498.     mov esp, ebp
  1499.     pop ebp
  1500.     jmp [_LsaSetInformationPolicy]
  1501.   end;
  1502. end;
  1503. {$ELSE}
  1504. function LsaSetInformationPolicy; external advapi32 name 'LsaSetInformationPolicy';
  1505. {$ENDIF DYNAMIC_LINK}
  1506. {$IFDEF DYNAMIC_LINK}
  1507. var
  1508.   _LsaQueryDomainInformationPolicy: Pointer;
  1509. function LsaQueryDomainInformationPolicy;
  1510. begin
  1511.   GetProcedureAddress(_LsaQueryDomainInformationPolicy, advapi32, 'LsaQueryDomainInformationPolicy');
  1512.   asm
  1513.     mov esp, ebp
  1514.     pop ebp
  1515.     jmp [_LsaQueryDomainInformationPolicy]
  1516.   end;
  1517. end;
  1518. {$ELSE}
  1519. function LsaQueryDomainInformationPolicy; external advapi32 name 'LsaQueryDomainInformationPolicy';
  1520. {$ENDIF DYNAMIC_LINK}
  1521. {$IFDEF DYNAMIC_LINK}
  1522. var
  1523.   _LsaSetDomainInformationPolicy: Pointer;
  1524. function LsaSetDomainInformationPolicy;
  1525. begin
  1526.   GetProcedureAddress(_LsaSetDomainInformationPolicy, advapi32, 'LsaSetDomainInformationPolicy');
  1527.   asm
  1528.     mov esp, ebp
  1529.     pop ebp
  1530.     jmp [_LsaSetDomainInformationPolicy]
  1531.   end;
  1532. end;
  1533. {$ELSE}
  1534. function LsaSetDomainInformationPolicy; external advapi32 name 'LsaSetDomainInformationPolicy';
  1535. {$ENDIF DYNAMIC_LINK}
  1536. {$IFDEF DYNAMIC_LINK}
  1537. var
  1538.   _LsaRegisterPolicyChangeNot: Pointer;
  1539. function LsaRegisterPolicyChangeNotification;
  1540. begin
  1541.   GetProcedureAddress(_LsaRegisterPolicyChangeNot, secur32, 'LsaRegisterPolicyChangeNotification');
  1542.   asm
  1543.     mov esp, ebp
  1544.     pop ebp
  1545.     jmp [_LsaRegisterPolicyChangeNot]
  1546.   end;
  1547. end;
  1548. {$ELSE}
  1549. function LsaRegisterPolicyChangeNotification; external secur32 name 'LsaRegisterPolicyChangeNotification';
  1550. {$ENDIF DYNAMIC_LINK}
  1551. {$IFDEF DYNAMIC_LINK}
  1552. var
  1553.   _LsaUnregisterPolicyChangeNot: Pointer;
  1554. function LsaUnregisterPolicyChangeNotification;
  1555. begin
  1556.   GetProcedureAddress(_LsaUnregisterPolicyChangeNot, secur32, 'LsaUnregisterPolicyChangeNotification');
  1557.   asm
  1558.     mov esp, ebp
  1559.     pop ebp
  1560.     jmp [_LsaUnregisterPolicyChangeNot]
  1561.   end;
  1562. end;
  1563. {$ELSE}
  1564. function LsaUnregisterPolicyChangeNotification; external secur32 name 'LsaUnregisterPolicyChangeNotification';
  1565. {$ENDIF DYNAMIC_LINK}
  1566. {$IFDEF DYNAMIC_LINK}
  1567. var
  1568.   _LsaEnumerateTrustedDomains: Pointer;
  1569. function LsaEnumerateTrustedDomains;
  1570. begin
  1571.   GetProcedureAddress(_LsaEnumerateTrustedDomains, advapi32, 'LsaEnumerateTrustedDomains');
  1572.   asm
  1573.     mov esp, ebp
  1574.     pop ebp
  1575.     jmp [_LsaEnumerateTrustedDomains]
  1576.   end;
  1577. end;
  1578. {$ELSE}
  1579. function LsaEnumerateTrustedDomains; external advapi32 name 'LsaEnumerateTrustedDomains';
  1580. {$ENDIF DYNAMIC_LINK}
  1581. {$IFDEF DYNAMIC_LINK}
  1582. var
  1583.   _LsaLookupNames: Pointer;
  1584. function LsaLookupNames;
  1585. begin
  1586.   GetProcedureAddress(_LsaLookupNames, advapi32, 'LsaLookupNames');
  1587.   asm
  1588.     mov esp, ebp
  1589.     pop ebp
  1590.     jmp [_LsaLookupNames]
  1591.   end;
  1592. end;
  1593. {$ELSE}
  1594. function LsaLookupNames; external advapi32 name 'LsaLookupNames';
  1595. {$ENDIF DYNAMIC_LINK}
  1596. {$IFDEF DYNAMIC_LINK}
  1597. var
  1598.   _LsaLookupNames2: Pointer;
  1599. function LsaLookupNames2;
  1600. begin
  1601.   GetProcedureAddress(_LsaLookupNames2, advapi32, 'LsaLookupNames2');
  1602.   asm
  1603.     mov esp, ebp
  1604.     pop ebp
  1605.     jmp [_LsaLookupNames2]
  1606.   end;
  1607. end;
  1608. {$ELSE}
  1609. function LsaLookupNames2; external advapi32 name 'LsaLookupNames2';
  1610. {$ENDIF DYNAMIC_LINK}
  1611. {$IFDEF DYNAMIC_LINK}
  1612. var
  1613.   _LsaLookupSids: Pointer;
  1614. function LsaLookupSids;
  1615. begin
  1616.   GetProcedureAddress(_LsaLookupSids, advapi32, 'LsaLookupSids');
  1617.   asm
  1618.     mov esp, ebp
  1619.     pop ebp
  1620.     jmp [_LsaLookupSids]
  1621.   end;
  1622. end;
  1623. {$ELSE}
  1624. function LsaLookupSids; external advapi32 name 'LsaLookupSids';
  1625. {$ENDIF DYNAMIC_LINK}
  1626. {$IFDEF DYNAMIC_LINK}
  1627. var
  1628.   _LsaEnumAccountsWithUserRight: Pointer;
  1629. function LsaEnumerateAccountsWithUserRight;
  1630. begin
  1631.   GetProcedureAddress(_LsaEnumAccountsWithUserRight, advapi32, 'LsaEnumerateAccountsWithUserRight');
  1632.   asm
  1633.     mov esp, ebp
  1634.     pop ebp
  1635.     jmp [_LsaEnumAccountsWithUserRight]
  1636.   end;
  1637. end;
  1638. {$ELSE}
  1639. function LsaEnumerateAccountsWithUserRight; external advapi32 name 'LsaEnumerateAccountsWithUserRight';
  1640. {$ENDIF DYNAMIC_LINK}
  1641. {$IFDEF DYNAMIC_LINK}
  1642. var
  1643.   _LsaEnumerateAccountRights: Pointer;
  1644. function LsaEnumerateAccountRights;
  1645. begin
  1646.   GetProcedureAddress(_LsaEnumerateAccountRights, advapi32, 'LsaEnumerateAccountRights');
  1647.   asm
  1648.     mov esp, ebp
  1649.     pop ebp
  1650.     jmp [_LsaEnumerateAccountRights]
  1651.   end;
  1652. end;
  1653. {$ELSE}
  1654. function LsaEnumerateAccountRights; external advapi32 name 'LsaEnumerateAccountRights';
  1655. {$ENDIF DYNAMIC_LINK}
  1656. {$IFDEF DYNAMIC_LINK}
  1657. var
  1658.   _LsaAddAccountRights: Pointer;
  1659. function LsaAddAccountRights;
  1660. begin
  1661.   GetProcedureAddress(_LsaAddAccountRights, advapi32, 'LsaAddAccountRights');
  1662.   asm
  1663.     mov esp, ebp
  1664.     pop ebp
  1665.     jmp [_LsaAddAccountRights]
  1666.   end;
  1667. end;
  1668. {$ELSE}
  1669. function LsaAddAccountRights; external advapi32 name 'LsaAddAccountRights';
  1670. {$ENDIF DYNAMIC_LINK}
  1671. {$IFDEF DYNAMIC_LINK}
  1672. var
  1673.   _LsaRemoveAccountRights: Pointer;
  1674. function LsaRemoveAccountRights;
  1675. begin
  1676.   GetProcedureAddress(_LsaRemoveAccountRights, advapi32, 'LsaRemoveAccountRights');
  1677.   asm
  1678.     mov esp, ebp
  1679.     pop ebp
  1680.     jmp [_LsaRemoveAccountRights]
  1681.   end;
  1682. end;
  1683. {$ELSE}
  1684. function LsaRemoveAccountRights; external advapi32 name 'LsaRemoveAccountRights';
  1685. {$ENDIF DYNAMIC_LINK}
  1686. {$IFDEF DYNAMIC_LINK}
  1687. var
  1688.   _LsaOpenTrustedDomainByName: Pointer;
  1689. function LsaOpenTrustedDomainByName;
  1690. begin
  1691.   GetProcedureAddress(_LsaOpenTrustedDomainByName, advapi32, 'LsaOpenTrustedDomainByName');
  1692.   asm
  1693.     mov esp, ebp
  1694.     pop ebp
  1695.     jmp [_LsaOpenTrustedDomainByName]
  1696.   end;
  1697. end;
  1698. {$ELSE}
  1699. function LsaOpenTrustedDomainByName; external advapi32 name 'LsaOpenTrustedDomainByName';
  1700. {$ENDIF DYNAMIC_LINK}
  1701. {$IFDEF DYNAMIC_LINK}
  1702. var
  1703.   _LsaQueryTrustedDomainInfo: Pointer;
  1704. function LsaQueryTrustedDomainInfo;
  1705. begin
  1706.   GetProcedureAddress(_LsaQueryTrustedDomainInfo, advapi32, 'LsaQueryTrustedDomainInfo');
  1707.   asm
  1708.     mov esp, ebp
  1709.     pop ebp
  1710.     jmp [_LsaQueryTrustedDomainInfo]
  1711.   end;
  1712. end;
  1713. {$ELSE}
  1714. function LsaQueryTrustedDomainInfo; external advapi32 name 'LsaQueryTrustedDomainInfo';
  1715. {$ENDIF DYNAMIC_LINK}
  1716. {$IFDEF DYNAMIC_LINK}
  1717. var
  1718.   _LsaSetTrustedDomainInformation: Pointer;
  1719. function LsaSetTrustedDomainInformation;
  1720. begin
  1721.   GetProcedureAddress(_LsaSetTrustedDomainInformation, advapi32, 'LsaSetTrustedDomainInformation');
  1722.   asm
  1723.     mov esp, ebp
  1724.     pop ebp
  1725.     jmp [_LsaSetTrustedDomainInformation]
  1726.   end;
  1727. end;
  1728. {$ELSE}
  1729. function LsaSetTrustedDomainInformation; external advapi32 name 'LsaSetTrustedDomainInformation';
  1730. {$ENDIF DYNAMIC_LINK}
  1731. {$IFDEF DYNAMIC_LINK}
  1732. var
  1733.   _LsaDeleteTrustedDomain: Pointer;
  1734. function LsaDeleteTrustedDomain;
  1735. begin
  1736.   GetProcedureAddress(_LsaDeleteTrustedDomain, advapi32, 'LsaDeleteTrustedDomain');
  1737.   asm
  1738.     mov esp, ebp
  1739.     pop ebp
  1740.     jmp [_LsaDeleteTrustedDomain]
  1741.   end;
  1742. end;
  1743. {$ELSE}
  1744. function LsaDeleteTrustedDomain; external advapi32 name 'LsaDeleteTrustedDomain';
  1745. {$ENDIF DYNAMIC_LINK}
  1746. {$IFDEF DYNAMIC_LINK}
  1747. var
  1748.   _LsaQueryTrustedDomainInfoByName: Pointer;
  1749. function LsaQueryTrustedDomainInfoByName;
  1750. begin
  1751.   GetProcedureAddress(_LsaQueryTrustedDomainInfoByName, advapi32, 'LsaQueryTrustedDomainInfoByName');
  1752.   asm
  1753.     mov esp, ebp
  1754.     pop ebp
  1755.     jmp [_LsaQueryTrustedDomainInfoByName]
  1756.   end;
  1757. end;
  1758. {$ELSE}
  1759. function LsaQueryTrustedDomainInfoByName; external advapi32 name 'LsaQueryTrustedDomainInfoByName';
  1760. {$ENDIF DYNAMIC_LINK}
  1761. {$IFDEF DYNAMIC_LINK}
  1762. var
  1763.   _LsaSetTrustedDomainInfoByName: Pointer;
  1764. function LsaSetTrustedDomainInfoByName;
  1765. begin
  1766.   GetProcedureAddress(_LsaSetTrustedDomainInfoByName, advapi32, 'LsaSetTrustedDomainInfoByName');
  1767.   asm
  1768.     mov esp, ebp
  1769.     pop ebp
  1770.     jmp [_LsaSetTrustedDomainInfoByName]
  1771.   end;
  1772. end;
  1773. {$ELSE}
  1774. function LsaSetTrustedDomainInfoByName; external advapi32 name 'LsaSetTrustedDomainInfoByName';
  1775. {$ENDIF DYNAMIC_LINK}
  1776. {$IFDEF DYNAMIC_LINK}
  1777. var
  1778.   _LsaEnumerateTrustedDomainsEx: Pointer;
  1779. function LsaEnumerateTrustedDomainsEx;
  1780. begin
  1781.   GetProcedureAddress(_LsaEnumerateTrustedDomainsEx, advapi32, 'LsaEnumerateTrustedDomainsEx');
  1782.   asm
  1783.     mov esp, ebp
  1784.     pop ebp
  1785.     jmp [_LsaEnumerateTrustedDomainsEx]
  1786.   end;
  1787. end;
  1788. {$ELSE}
  1789. function LsaEnumerateTrustedDomainsEx; external advapi32 name 'LsaEnumerateTrustedDomainsEx';
  1790. {$ENDIF DYNAMIC_LINK}
  1791. {$IFDEF DYNAMIC_LINK}
  1792. var
  1793.   _LsaCreateTrustedDomainEx: Pointer;
  1794. function LsaCreateTrustedDomainEx;
  1795. begin
  1796.   GetProcedureAddress(_LsaCreateTrustedDomainEx, advapi32, 'LsaCreateTrustedDomainEx');
  1797.   asm
  1798.     mov esp, ebp
  1799.     pop ebp
  1800.     jmp [_LsaCreateTrustedDomainEx]
  1801.   end;
  1802. end;
  1803. {$ELSE}
  1804. function LsaCreateTrustedDomainEx; external advapi32 name 'LsaCreateTrustedDomainEx';
  1805. {$ENDIF DYNAMIC_LINK}
  1806. {$IFDEF DYNAMIC_LINK}
  1807. var
  1808.   _LsaQueryForestTrustInformation: Pointer;
  1809. function LsaQueryForestTrustInformation;
  1810. begin
  1811.   GetProcedureAddress(_LsaQueryForestTrustInformation, advapi32, 'LsaQueryForestTrustInformation');
  1812.   asm
  1813.     mov esp, ebp
  1814.     pop ebp
  1815.     jmp [_LsaQueryForestTrustInformation]
  1816.   end;
  1817. end;
  1818. {$ELSE}
  1819. function LsaQueryForestTrustInformation; external advapi32 name 'LsaQueryForestTrustInformation';
  1820. {$ENDIF DYNAMIC_LINK}
  1821. {$IFDEF DYNAMIC_LINK}
  1822. var
  1823.   _LsaSetForestTrustInformation: Pointer;
  1824. function LsaSetForestTrustInformation;
  1825. begin
  1826.   GetProcedureAddress(_LsaSetForestTrustInformation, advapi32, 'LsaSetForestTrustInformation');
  1827.   asm
  1828.     mov esp, ebp
  1829.     pop ebp
  1830.     jmp [_LsaSetForestTrustInformation]
  1831.   end;
  1832. end;
  1833. {$ELSE}
  1834. function LsaSetForestTrustInformation; external advapi32 name 'LsaSetForestTrustInformation';
  1835. {$ENDIF DYNAMIC_LINK}
  1836. {$IFDEF DYNAMIC_LINK}
  1837. var
  1838.   _LsaStorePrivateData: Pointer;
  1839. function LsaStorePrivateData;
  1840. begin
  1841.   GetProcedureAddress(_LsaStorePrivateData, advapi32, 'LsaStorePrivateData');
  1842.   asm
  1843.     mov esp, ebp
  1844.     pop ebp
  1845.     jmp [_LsaStorePrivateData]
  1846.   end;
  1847. end;
  1848. {$ELSE}
  1849. function LsaStorePrivateData; external advapi32 name 'LsaStorePrivateData';
  1850. {$ENDIF DYNAMIC_LINK}
  1851. {$IFDEF DYNAMIC_LINK}
  1852. var
  1853.   _LsaRetrievePrivateData: Pointer;
  1854. function LsaRetrievePrivateData;
  1855. begin
  1856.   GetProcedureAddress(_LsaRetrievePrivateData, advapi32, 'LsaRetrievePrivateData');
  1857.   asm
  1858.     mov esp, ebp
  1859.     pop ebp
  1860.     jmp [_LsaRetrievePrivateData]
  1861.   end;
  1862. end;
  1863. {$ELSE}
  1864. function LsaRetrievePrivateData; external advapi32 name 'LsaRetrievePrivateData';
  1865. {$ENDIF DYNAMIC_LINK}
  1866. {$IFDEF DYNAMIC_LINK}
  1867. var
  1868.   _LsaNtStatusToWinError: Pointer;
  1869. function LsaNtStatusToWinError;
  1870. begin
  1871.   GetProcedureAddress(_LsaNtStatusToWinError, advapi32, 'LsaNtStatusToWinError');
  1872.   asm
  1873.     mov esp, ebp
  1874.     pop ebp
  1875.     jmp [_LsaNtStatusToWinError]
  1876.   end;
  1877. end;
  1878. {$ELSE}
  1879. function LsaNtStatusToWinError; external advapi32 name 'LsaNtStatusToWinError';
  1880. {$ENDIF DYNAMIC_LINK}
  1881. end.