Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2853 lines
82 KiB

  1. /*++ BUILD Version: 0000 Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntsecapi.h
  5. Abstract:
  6. This module defines the Local Security Authority APIs.
  7. Revision History:
  8. --*/
  9. #ifndef _NTSECAPI_
  10. #define _NTSECAPI_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #ifndef _NTDEF_
  15. typedef LONG NTSTATUS, *PNTSTATUS;
  16. #endif
  17. #ifndef _NTLSA_IFS_
  18. // begin_ntifs
  19. //
  20. // Security operation mode of the system is held in a control
  21. // longword.
  22. //
  23. typedef ULONG LSA_OPERATIONAL_MODE, *PLSA_OPERATIONAL_MODE;
  24. // end_ntifs
  25. #endif // _NTLSA_IFS_
  26. //
  27. // The flags in the security operational mode are defined
  28. // as:
  29. //
  30. // PasswordProtected - Some level of authentication (such as
  31. // a password) must be provided by users before they are
  32. // allowed to use the system. Once set, this value will
  33. // not be cleared without re-booting the system.
  34. //
  35. // IndividualAccounts - Each user must identify an account to
  36. // logon to. This flag is only meaningful if the
  37. // PasswordProtected flag is also set. If this flag is
  38. // not set and the PasswordProtected flag is set, then all
  39. // users may logon to the same account. Once set, this value
  40. // will not be cleared without re-booting the system.
  41. //
  42. // MandatoryAccess - Indicates the system is running in a mandatory
  43. // access control mode (e.g., B-level as defined by the U.S.A's
  44. // Department of Defense's "Orange Book"). This is not utilized
  45. // in the current release of NT. This flag is only meaningful
  46. // if both the PasswordProtected and IndividualAccounts flags are
  47. // set. Once set, this value will not be cleared without
  48. // re-booting the system.
  49. //
  50. // LogFull - Indicates the system has been brought up in a mode in
  51. // which if must perform security auditing, but its audit log
  52. // is full. This may (should) restrict the operations that
  53. // can occur until the audit log is made not-full again. THIS
  54. // VALUE MAY BE CLEARED WHILE THE SYSTEM IS RUNNING (I.E., WITHOUT
  55. // REBOOTING).
  56. //
  57. // If the PasswordProtected flag is not set, then the system is running
  58. // without security, and user interface should be adjusted appropriately.
  59. //
  60. #define LSA_MODE_PASSWORD_PROTECTED (0x00000001L)
  61. #define LSA_MODE_INDIVIDUAL_ACCOUNTS (0x00000002L)
  62. #define LSA_MODE_MANDATORY_ACCESS (0x00000004L)
  63. #define LSA_MODE_LOG_FULL (0x00000008L)
  64. #ifndef _NTLSA_IFS_
  65. // begin_ntifs
  66. //
  67. // Used by a logon process to indicate what type of logon is being
  68. // requested.
  69. //
  70. typedef enum _SECURITY_LOGON_TYPE {
  71. Interactive = 2, // Interactively logged on (locally or remotely)
  72. Network, // Accessing system via network
  73. Batch, // Started via a batch queue
  74. Service, // Service started by service controller
  75. Proxy, // Proxy logon
  76. Unlock, // Unlock workstation
  77. NetworkCleartext, // Network logon with cleartext credentials
  78. NewCredentials, // Clone caller, new default credentials
  79. RemoteInteractive, // Remote, yet interactive. Terminal server
  80. CachedInteractive // Try cached credentials without hitting the net.
  81. } SECURITY_LOGON_TYPE, *PSECURITY_LOGON_TYPE;
  82. // end_ntifs
  83. #endif // _NTLSA_IFS_
  84. //
  85. // Audit Event Categories
  86. //
  87. // The following are the built-in types or Categories of audit event.
  88. // WARNING! This structure is subject to expansion. The user should not
  89. // compute the number of elements of this type directly, but instead
  90. // should obtain the count of elements by calling LsaQueryInformationPolicy()
  91. // for the PolicyAuditEventsInformation class and extracting the count from
  92. // the MaximumAuditEventCount field of the returned structure.
  93. //
  94. typedef enum _POLICY_AUDIT_EVENT_TYPE {
  95. AuditCategorySystem,
  96. AuditCategoryLogon,
  97. AuditCategoryObjectAccess,
  98. AuditCategoryPrivilegeUse,
  99. AuditCategoryDetailedTracking,
  100. AuditCategoryPolicyChange,
  101. AuditCategoryAccountManagement,
  102. AuditCategoryDirectoryServiceAccess,
  103. AuditCategoryAccountLogon
  104. } POLICY_AUDIT_EVENT_TYPE, *PPOLICY_AUDIT_EVENT_TYPE;
  105. //
  106. // The following defines describe the auditing options for each
  107. // event type
  108. //
  109. // Leave options specified for this event unchanged
  110. #define POLICY_AUDIT_EVENT_UNCHANGED (0x00000000L)
  111. // Audit successful occurrences of events of this type
  112. #define POLICY_AUDIT_EVENT_SUCCESS (0x00000001L)
  113. // Audit failed attempts to cause an event of this type to occur
  114. #define POLICY_AUDIT_EVENT_FAILURE (0x00000002L)
  115. #define POLICY_AUDIT_EVENT_NONE (0x00000004L)
  116. // Mask of valid event auditing options
  117. #define POLICY_AUDIT_EVENT_MASK \
  118. (POLICY_AUDIT_EVENT_SUCCESS | \
  119. POLICY_AUDIT_EVENT_FAILURE | \
  120. POLICY_AUDIT_EVENT_UNCHANGED | \
  121. POLICY_AUDIT_EVENT_NONE)
  122. #ifdef _NTDEF_
  123. // begin_ntifs
  124. typedef UNICODE_STRING LSA_UNICODE_STRING, *PLSA_UNICODE_STRING;
  125. typedef STRING LSA_STRING, *PLSA_STRING;
  126. typedef OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES;
  127. // end_ntifs
  128. #else // _NTDEF_
  129. #ifndef IN
  130. #define IN
  131. #endif
  132. #ifndef OUT
  133. #define OUT
  134. #endif
  135. #ifndef OPTIONAL
  136. #define OPTIONAL
  137. #endif
  138. typedef struct _LSA_UNICODE_STRING {
  139. USHORT Length;
  140. USHORT MaximumLength;
  141. #ifdef MIDL_PASS
  142. [size_is(MaximumLength/2), length_is(Length/2)]
  143. #endif // MIDL_PASS
  144. PWSTR Buffer;
  145. } LSA_UNICODE_STRING, *PLSA_UNICODE_STRING;
  146. typedef struct _LSA_STRING {
  147. USHORT Length;
  148. USHORT MaximumLength;
  149. PCHAR Buffer;
  150. } LSA_STRING, *PLSA_STRING;
  151. typedef struct _LSA_OBJECT_ATTRIBUTES {
  152. ULONG Length;
  153. HANDLE RootDirectory;
  154. PLSA_UNICODE_STRING ObjectName;
  155. ULONG Attributes;
  156. PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
  157. PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
  158. } LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES;
  159. #endif // _NTDEF_
  160. //
  161. // Macro for determining whether an API succeeded.
  162. //
  163. #define LSA_SUCCESS(Error) ((LONG)(Error) >= 0)
  164. #ifndef _NTLSA_IFS_
  165. // begin_ntifs
  166. NTSTATUS
  167. NTAPI
  168. LsaRegisterLogonProcess (
  169. IN PLSA_STRING LogonProcessName,
  170. OUT PHANDLE LsaHandle,
  171. OUT PLSA_OPERATIONAL_MODE SecurityMode
  172. );
  173. NTSTATUS
  174. NTAPI
  175. LsaLogonUser (
  176. IN HANDLE LsaHandle,
  177. IN PLSA_STRING OriginName,
  178. IN SECURITY_LOGON_TYPE LogonType,
  179. IN ULONG AuthenticationPackage,
  180. IN PVOID AuthenticationInformation,
  181. IN ULONG AuthenticationInformationLength,
  182. IN PTOKEN_GROUPS LocalGroups OPTIONAL,
  183. IN PTOKEN_SOURCE SourceContext,
  184. OUT PVOID *ProfileBuffer,
  185. OUT PULONG ProfileBufferLength,
  186. OUT PLUID LogonId,
  187. OUT PHANDLE Token,
  188. OUT PQUOTA_LIMITS Quotas,
  189. OUT PNTSTATUS SubStatus
  190. );
  191. // end_ntifs
  192. NTSTATUS
  193. NTAPI
  194. LsaLookupAuthenticationPackage (
  195. IN HANDLE LsaHandle,
  196. IN PLSA_STRING PackageName,
  197. OUT PULONG AuthenticationPackage
  198. );
  199. // begin_ntifs
  200. NTSTATUS
  201. NTAPI
  202. LsaFreeReturnBuffer (
  203. IN PVOID Buffer
  204. );
  205. // end_ntifs
  206. NTSTATUS
  207. NTAPI
  208. LsaCallAuthenticationPackage (
  209. IN HANDLE LsaHandle,
  210. IN ULONG AuthenticationPackage,
  211. IN PVOID ProtocolSubmitBuffer,
  212. IN ULONG SubmitBufferLength,
  213. OUT PVOID *ProtocolReturnBuffer,
  214. OUT PULONG ReturnBufferLength,
  215. OUT PNTSTATUS ProtocolStatus
  216. );
  217. NTSTATUS
  218. NTAPI
  219. LsaDeregisterLogonProcess (
  220. IN HANDLE LsaHandle
  221. );
  222. NTSTATUS
  223. NTAPI
  224. LsaConnectUntrusted (
  225. OUT PHANDLE LsaHandle
  226. );
  227. #endif // _NTLSA_IFS_
  228. ////////////////////////////////////////////////////////////////////////////
  229. // //
  230. // Local Security Policy Administration API datatypes and defines //
  231. // //
  232. ////////////////////////////////////////////////////////////////////////////
  233. //
  234. // Access types for the Policy object
  235. //
  236. #define POLICY_VIEW_LOCAL_INFORMATION 0x00000001L
  237. #define POLICY_VIEW_AUDIT_INFORMATION 0x00000002L
  238. #define POLICY_GET_PRIVATE_INFORMATION 0x00000004L
  239. #define POLICY_TRUST_ADMIN 0x00000008L
  240. #define POLICY_CREATE_ACCOUNT 0x00000010L
  241. #define POLICY_CREATE_SECRET 0x00000020L
  242. #define POLICY_CREATE_PRIVILEGE 0x00000040L
  243. #define POLICY_SET_DEFAULT_QUOTA_LIMITS 0x00000080L
  244. #define POLICY_SET_AUDIT_REQUIREMENTS 0x00000100L
  245. #define POLICY_AUDIT_LOG_ADMIN 0x00000200L
  246. #define POLICY_SERVER_ADMIN 0x00000400L
  247. #define POLICY_LOOKUP_NAMES 0x00000800L
  248. #define POLICY_NOTIFICATION 0x00001000L
  249. #define POLICY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  250. POLICY_VIEW_LOCAL_INFORMATION |\
  251. POLICY_VIEW_AUDIT_INFORMATION |\
  252. POLICY_GET_PRIVATE_INFORMATION |\
  253. POLICY_TRUST_ADMIN |\
  254. POLICY_CREATE_ACCOUNT |\
  255. POLICY_CREATE_SECRET |\
  256. POLICY_CREATE_PRIVILEGE |\
  257. POLICY_SET_DEFAULT_QUOTA_LIMITS |\
  258. POLICY_SET_AUDIT_REQUIREMENTS |\
  259. POLICY_AUDIT_LOG_ADMIN |\
  260. POLICY_SERVER_ADMIN |\
  261. POLICY_LOOKUP_NAMES)
  262. #define POLICY_READ (STANDARD_RIGHTS_READ |\
  263. POLICY_VIEW_AUDIT_INFORMATION |\
  264. POLICY_GET_PRIVATE_INFORMATION)
  265. #define POLICY_WRITE (STANDARD_RIGHTS_WRITE |\
  266. POLICY_TRUST_ADMIN |\
  267. POLICY_CREATE_ACCOUNT |\
  268. POLICY_CREATE_SECRET |\
  269. POLICY_CREATE_PRIVILEGE |\
  270. POLICY_SET_DEFAULT_QUOTA_LIMITS |\
  271. POLICY_SET_AUDIT_REQUIREMENTS |\
  272. POLICY_AUDIT_LOG_ADMIN |\
  273. POLICY_SERVER_ADMIN)
  274. #define POLICY_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  275. POLICY_VIEW_LOCAL_INFORMATION |\
  276. POLICY_LOOKUP_NAMES)
  277. //
  278. // Policy object specific data types.
  279. //
  280. //
  281. // The following data type is used to identify a domain
  282. //
  283. typedef struct _LSA_TRUST_INFORMATION {
  284. LSA_UNICODE_STRING Name;
  285. PSID Sid;
  286. } LSA_TRUST_INFORMATION, *PLSA_TRUST_INFORMATION;
  287. // where members have the following usage:
  288. //
  289. // Name - The name of the domain.
  290. //
  291. // Sid - A pointer to the Sid of the Domain
  292. //
  293. //
  294. // The following data type is used in name and SID lookup services to
  295. // describe the domains referenced in the lookup operation.
  296. //
  297. typedef struct _LSA_REFERENCED_DOMAIN_LIST {
  298. ULONG Entries;
  299. PLSA_TRUST_INFORMATION Domains;
  300. } LSA_REFERENCED_DOMAIN_LIST, *PLSA_REFERENCED_DOMAIN_LIST;
  301. // where members have the following usage:
  302. //
  303. // Entries - Is a count of the number of domains described in the
  304. // Domains array.
  305. //
  306. // Domains - Is a pointer to an array of Entries LSA_TRUST_INFORMATION data
  307. // structures.
  308. //
  309. //
  310. // The following data type is used in name to SID lookup services to describe
  311. // the domains referenced in the lookup operation.
  312. //
  313. typedef struct _LSA_TRANSLATED_SID {
  314. SID_NAME_USE Use;
  315. ULONG RelativeId;
  316. LONG DomainIndex;
  317. } LSA_TRANSLATED_SID, *PLSA_TRANSLATED_SID;
  318. // where members have the following usage:
  319. //
  320. // Use - identifies the use of the SID. If this value is SidUnknown or
  321. // SidInvalid, then the remainder of the record is not set and
  322. // should be ignored.
  323. //
  324. // RelativeId - Contains the relative ID of the translated SID. The
  325. // remainder of the SID (the prefix) is obtained using the
  326. // DomainIndex field.
  327. //
  328. // DomainIndex - Is the index of an entry in a related
  329. // LSA_REFERENCED_DOMAIN_LIST data structure describing the
  330. // domain in which the account was found.
  331. //
  332. // If there is no corresponding reference domain for an entry, then
  333. // this field will contain a negative value.
  334. //
  335. typedef struct _LSA_TRANSLATED_SID2 {
  336. SID_NAME_USE Use;
  337. PSID Sid;
  338. LONG DomainIndex;
  339. ULONG Flags;
  340. } LSA_TRANSLATED_SID2, *PLSA_TRANSLATED_SID2;
  341. // where members have the following usage:
  342. //
  343. // Use - identifies the use of the SID. If this value is SidUnknown or
  344. // SidInvalid, then the remainder of the record is not set and
  345. // should be ignored.
  346. //
  347. // Sid - Contains the complete Sid of the tranlated SID
  348. //
  349. // DomainIndex - Is the index of an entry in a related
  350. // LSA_REFERENCED_DOMAIN_LIST data structure describing the
  351. // domain in which the account was found.
  352. //
  353. // If there is no corresponding reference domain for an entry, then
  354. // this field will contain a negative value.
  355. //
  356. //
  357. // The following data type is used in SID to name lookup services to
  358. // describe the domains referenced in the lookup operation.
  359. //
  360. typedef struct _LSA_TRANSLATED_NAME {
  361. SID_NAME_USE Use;
  362. LSA_UNICODE_STRING Name;
  363. LONG DomainIndex;
  364. } LSA_TRANSLATED_NAME, *PLSA_TRANSLATED_NAME;
  365. // where the members have the following usage:
  366. //
  367. // Use - Identifies the use of the name. If this value is SidUnknown
  368. // or SidInvalid, then the remainder of the record is not set and
  369. // should be ignored. If this value is SidWellKnownGroup then the
  370. // Name field is invalid, but the DomainIndex field is not.
  371. //
  372. // Name - Contains the isolated name of the translated SID.
  373. //
  374. // DomainIndex - Is the index of an entry in a related
  375. // LSA_REFERENCED_DOMAIN_LIST data structure describing the domain
  376. // in which the account was found.
  377. //
  378. // If there is no corresponding reference domain for an entry, then
  379. // this field will contain a negative value.
  380. //
  381. //
  382. // The following data type is used to represent the role of the LSA
  383. // server (primary or backup).
  384. //
  385. typedef enum _POLICY_LSA_SERVER_ROLE {
  386. PolicyServerRoleBackup = 2,
  387. PolicyServerRolePrimary
  388. } POLICY_LSA_SERVER_ROLE, *PPOLICY_LSA_SERVER_ROLE;
  389. //
  390. // The following data type is used to represent the state of the LSA
  391. // server (enabled or disabled). Some operations may only be performed on
  392. // an enabled LSA server.
  393. //
  394. typedef enum _POLICY_SERVER_ENABLE_STATE {
  395. PolicyServerEnabled = 2,
  396. PolicyServerDisabled
  397. } POLICY_SERVER_ENABLE_STATE, *PPOLICY_SERVER_ENABLE_STATE;
  398. //
  399. // The following data type is used to specify the auditing options for
  400. // an Audit Event Type.
  401. //
  402. typedef ULONG POLICY_AUDIT_EVENT_OPTIONS, *PPOLICY_AUDIT_EVENT_OPTIONS;
  403. // where the following flags can be set:
  404. //
  405. // POLICY_AUDIT_EVENT_UNCHANGED - Leave existing auditing options
  406. // unchanged for events of this type. This flag is only used for
  407. // set operations. If this flag is set, then all other flags
  408. // are ignored.
  409. //
  410. // POLICY_AUDIT_EVENT_NONE - Cancel all auditing options for events
  411. // of this type. If this flag is set, the success/failure flags
  412. // are ignored.
  413. //
  414. // POLICY_AUDIT_EVENT_SUCCESS - When auditing is enabled, audit all
  415. // successful occurrences of events of the given type.
  416. //
  417. // POLICY_AUDIT_EVENT_FAILURE - When auditing is enabled, audit all
  418. // unsuccessful occurrences of events of the given type.
  419. //
  420. //
  421. // The following data type defines the classes of Policy Information
  422. // that may be queried/set.
  423. //
  424. typedef enum _POLICY_INFORMATION_CLASS {
  425. PolicyAuditLogInformation = 1,
  426. PolicyAuditEventsInformation,
  427. PolicyPrimaryDomainInformation,
  428. PolicyPdAccountInformation,
  429. PolicyAccountDomainInformation,
  430. PolicyLsaServerRoleInformation,
  431. PolicyReplicaSourceInformation,
  432. PolicyDefaultQuotaInformation,
  433. PolicyModificationInformation,
  434. PolicyAuditFullSetInformation,
  435. PolicyAuditFullQueryInformation,
  436. PolicyDnsDomainInformation,
  437. PolicyDnsDomainInformationInt
  438. } POLICY_INFORMATION_CLASS, *PPOLICY_INFORMATION_CLASS;
  439. //
  440. // The following data type corresponds to the PolicyAuditLogInformation
  441. // information class. It is used to represent information relating to
  442. // the Audit Log.
  443. //
  444. // This structure may be used in both query and set operations. However,
  445. // when used in set operations, some fields are ignored.
  446. //
  447. typedef struct _POLICY_AUDIT_LOG_INFO {
  448. ULONG AuditLogPercentFull;
  449. ULONG MaximumLogSize;
  450. LARGE_INTEGER AuditRetentionPeriod;
  451. BOOLEAN AuditLogFullShutdownInProgress;
  452. LARGE_INTEGER TimeToShutdown;
  453. ULONG NextAuditRecordId;
  454. } POLICY_AUDIT_LOG_INFO, *PPOLICY_AUDIT_LOG_INFO;
  455. // where the members have the following usage:
  456. //
  457. // AuditLogPercentFull - Indicates the percentage of the Audit Log
  458. // currently being used.
  459. //
  460. // MaximumLogSize - Specifies the maximum size of the Audit Log in
  461. // kilobytes.
  462. //
  463. // AuditRetentionPeriod - Indicates the length of time that Audit
  464. // Records are to be retained. Audit Records are discardable
  465. // if their timestamp predates the current time minus the
  466. // retention period.
  467. //
  468. // AuditLogFullShutdownInProgress - Indicates whether or not a system
  469. // shutdown is being initiated due to the security Audit Log becoming
  470. // full. This condition will only occur if the system is configured
  471. // to shutdown when the log becomes full.
  472. //
  473. // TRUE indicates that a shutdown is in progress
  474. // FALSE indicates that a shutdown is not in progress.
  475. //
  476. // Once a shutdown has been initiated, this flag will be set to
  477. // TRUE. If an administrator is able to currect the situation
  478. // before the shutdown becomes irreversible, then this flag will
  479. // be reset to false.
  480. //
  481. // This field is ignored for set operations.
  482. //
  483. // TimeToShutdown - If the AuditLogFullShutdownInProgress flag is set,
  484. // then this field contains the time left before the shutdown
  485. // becomes irreversible.
  486. //
  487. // This field is ignored for set operations.
  488. //
  489. //
  490. // The following data type corresponds to the PolicyAuditEventsInformation
  491. // information class. It is used to represent information relating to
  492. // the audit requirements.
  493. //
  494. typedef struct _POLICY_AUDIT_EVENTS_INFO {
  495. BOOLEAN AuditingMode;
  496. PPOLICY_AUDIT_EVENT_OPTIONS EventAuditingOptions;
  497. ULONG MaximumAuditEventCount;
  498. } POLICY_AUDIT_EVENTS_INFO, *PPOLICY_AUDIT_EVENTS_INFO;
  499. // where the members have the following usage:
  500. //
  501. // AuditingMode - A Boolean variable specifying the Auditing Mode value.
  502. // This value is interpreted as follows:
  503. //
  504. // TRUE - Auditing is to be enabled (set operations) or is enabled
  505. // (query operations). Audit Records will be generated according
  506. // to the Event Auditing Options in effect (see the
  507. // EventAuditingOptions field.
  508. //
  509. // FALSE - Auditing is to be disabled (set operations) or is
  510. // disabled (query operations). No Audit Records will be
  511. // generated. Note that for set operations the Event Auditing
  512. // Options in effect will still be updated as specified by the
  513. // EventAuditingOptions field whether Auditing is enabled or
  514. // disabled.
  515. //
  516. // EventAuditingOptions - Pointer to an array of Auditing Options
  517. // indexed by Audit Event Type.
  518. //
  519. // MaximumAuditEventCount - Specifiesa count of the number of Audit
  520. // Event Types specified by the EventAuditingOptions parameter. If
  521. // this count is less than the number of Audit Event Types supported
  522. // by the system, the Auditing Options for Event Types with IDs
  523. // higher than (MaximumAuditEventCount + 1) are left unchanged.
  524. //
  525. //
  526. // The following structure corresponds to the PolicyAccountDomainInformation
  527. // information class.
  528. //
  529. typedef struct _POLICY_ACCOUNT_DOMAIN_INFO {
  530. LSA_UNICODE_STRING DomainName;
  531. PSID DomainSid;
  532. } POLICY_ACCOUNT_DOMAIN_INFO, *PPOLICY_ACCOUNT_DOMAIN_INFO;
  533. // where the members have the following usage:
  534. //
  535. // DomainName - Is the name of the domain
  536. //
  537. // DomainSid - Is the Sid of the domain
  538. //
  539. //
  540. // The following structure corresponds to the PolicyPrimaryDomainInformation
  541. // information class.
  542. //
  543. typedef struct _POLICY_PRIMARY_DOMAIN_INFO {
  544. LSA_UNICODE_STRING Name;
  545. PSID Sid;
  546. } POLICY_PRIMARY_DOMAIN_INFO, *PPOLICY_PRIMARY_DOMAIN_INFO;
  547. // where the members have the following usage:
  548. //
  549. // Name - Is the name of the domain
  550. //
  551. // Sid - Is the Sid of the domain
  552. //
  553. //
  554. // The following structure corresponds to the PolicyDnsDomainInformation
  555. // information class
  556. //
  557. typedef struct _POLICY_DNS_DOMAIN_INFO
  558. {
  559. LSA_UNICODE_STRING Name;
  560. LSA_UNICODE_STRING DnsDomainName;
  561. LSA_UNICODE_STRING DnsForestName;
  562. GUID DomainGuid;
  563. PSID Sid;
  564. } POLICY_DNS_DOMAIN_INFO, *PPOLICY_DNS_DOMAIN_INFO;
  565. // where the members have the following usage:
  566. //
  567. // Name - Is the name of the Domain
  568. //
  569. // DnsDomainName - Is the DNS name of the domain
  570. //
  571. // DnsForestName - Is the DNS forest name of the domain
  572. //
  573. // DomainGuid - Is the GUID of the domain
  574. //
  575. // Sid - Is the Sid of the domain
  576. //
  577. // The following structure corresponds to the PolicyPdAccountInformation
  578. // information class. This structure may be used in Query operations
  579. // only.
  580. //
  581. typedef struct _POLICY_PD_ACCOUNT_INFO {
  582. LSA_UNICODE_STRING Name;
  583. } POLICY_PD_ACCOUNT_INFO, *PPOLICY_PD_ACCOUNT_INFO;
  584. // where the members have the following usage:
  585. //
  586. // Name - Is the name of an account in the domain that should be used
  587. // for authentication and name/ID lookup requests.
  588. //
  589. //
  590. // The following structure corresponds to the PolicyLsaServerRoleInformation
  591. // information class.
  592. //
  593. typedef struct _POLICY_LSA_SERVER_ROLE_INFO {
  594. POLICY_LSA_SERVER_ROLE LsaServerRole;
  595. } POLICY_LSA_SERVER_ROLE_INFO, *PPOLICY_LSA_SERVER_ROLE_INFO;
  596. // where the fields have the following usage:
  597. //
  598. // TBS
  599. //
  600. //
  601. // The following structure corresponds to the PolicyReplicaSourceInformation
  602. // information class.
  603. //
  604. typedef struct _POLICY_REPLICA_SOURCE_INFO {
  605. LSA_UNICODE_STRING ReplicaSource;
  606. LSA_UNICODE_STRING ReplicaAccountName;
  607. } POLICY_REPLICA_SOURCE_INFO, *PPOLICY_REPLICA_SOURCE_INFO;
  608. //
  609. // The following structure corresponds to the PolicyDefaultQuotaInformation
  610. // information class.
  611. //
  612. typedef struct _POLICY_DEFAULT_QUOTA_INFO {
  613. QUOTA_LIMITS QuotaLimits;
  614. } POLICY_DEFAULT_QUOTA_INFO, *PPOLICY_DEFAULT_QUOTA_INFO;
  615. //
  616. // The following structure corresponds to the PolicyModificationInformation
  617. // information class.
  618. //
  619. typedef struct _POLICY_MODIFICATION_INFO {
  620. LARGE_INTEGER ModifiedId;
  621. LARGE_INTEGER DatabaseCreationTime;
  622. } POLICY_MODIFICATION_INFO, *PPOLICY_MODIFICATION_INFO;
  623. // where the members have the following usage:
  624. //
  625. // ModifiedId - Is a 64-bit unsigned integer that is incremented each
  626. // time anything in the LSA database is modified. This value is
  627. // only modified on Primary Domain Controllers.
  628. //
  629. // DatabaseCreationTime - Is the date/time that the LSA Database was
  630. // created. On Backup Domain Controllers, this value is replicated
  631. // from the Primary Domain Controller.
  632. //
  633. //
  634. // The following structure type corresponds to the PolicyAuditFullSetInformation
  635. // Information Class.
  636. //
  637. typedef struct _POLICY_AUDIT_FULL_SET_INFO {
  638. BOOLEAN ShutDownOnFull;
  639. } POLICY_AUDIT_FULL_SET_INFO, *PPOLICY_AUDIT_FULL_SET_INFO;
  640. //
  641. // The following structure type corresponds to the PolicyAuditFullQueryInformation
  642. // Information Class.
  643. //
  644. typedef struct _POLICY_AUDIT_FULL_QUERY_INFO {
  645. BOOLEAN ShutDownOnFull;
  646. BOOLEAN LogIsFull;
  647. } POLICY_AUDIT_FULL_QUERY_INFO, *PPOLICY_AUDIT_FULL_QUERY_INFO;
  648. //
  649. // The following data type defines the classes of Policy Information
  650. // that may be queried/set that has domain wide effect.
  651. //
  652. typedef enum _POLICY_DOMAIN_INFORMATION_CLASS {
  653. // PolicyDomainQualityOfServiceInformation, // value was used in W2K; no longer supported
  654. PolicyDomainEfsInformation = 2,
  655. PolicyDomainKerberosTicketInformation
  656. } POLICY_DOMAIN_INFORMATION_CLASS, *PPOLICY_DOMAIN_INFORMATION_CLASS;
  657. //
  658. // QualityOfService information. Corresponds to PolicyDomainQualityOfServiceInformation
  659. //
  660. #define POLICY_QOS_SCHANNEL_REQUIRED 0x00000001
  661. #define POLICY_QOS_OUTBOUND_INTEGRITY 0x00000002
  662. #define POLICY_QOS_OUTBOUND_CONFIDENTIALITY 0x00000004
  663. #define POLICY_QOS_INBOUND_INTEGRITY 0x00000008
  664. #define POLICY_QOS_INBOUND_CONFIDENTIALITY 0x00000010
  665. #define POLICY_QOS_ALLOW_LOCAL_ROOT_CERT_STORE 0x00000020
  666. #define POLICY_QOS_RAS_SERVER_ALLOWED 0x00000040
  667. #define POLICY_QOS_DHCP_SERVER_ALLOWED 0x00000080
  668. //
  669. // Bits 0x00000100 through 0xFFFFFFFF are reserved for future use.
  670. //
  671. //
  672. // The following structure corresponds to the PolicyEfsInformation
  673. // information class
  674. //
  675. typedef struct _POLICY_DOMAIN_EFS_INFO {
  676. ULONG InfoLength;
  677. PUCHAR EfsBlob;
  678. } POLICY_DOMAIN_EFS_INFO, *PPOLICY_DOMAIN_EFS_INFO;
  679. // where the members have the following usage:
  680. //
  681. // InfoLength - Length of the EFS Information blob
  682. //
  683. // EfsBlob - Efs blob data
  684. //
  685. //
  686. // The following structure corresponds to the PolicyDomainKerberosTicketInformation
  687. // information class
  688. #define POLICY_KERBEROS_VALIDATE_CLIENT 0x00000080
  689. typedef struct _POLICY_DOMAIN_KERBEROS_TICKET_INFO {
  690. ULONG AuthenticationOptions;
  691. LARGE_INTEGER MaxServiceTicketAge;
  692. LARGE_INTEGER MaxTicketAge;
  693. LARGE_INTEGER MaxRenewAge;
  694. LARGE_INTEGER MaxClockSkew;
  695. LARGE_INTEGER Reserved;
  696. } POLICY_DOMAIN_KERBEROS_TICKET_INFO, *PPOLICY_DOMAIN_KERBEROS_TICKET_INFO;
  697. //
  698. // where the members have the following usage
  699. //
  700. // AuthenticationOptions -- allowed ticket options (POLICY_KERBEROS_* flags )
  701. //
  702. // MaxServiceTicketAge -- Maximum lifetime for a service ticket
  703. //
  704. // MaxTicketAge -- Maximum lifetime for the initial ticket
  705. //
  706. // MaxRenewAge -- Maximum cumulative age a renewable ticket can be with
  707. // requring authentication
  708. //
  709. // MaxClockSkew -- Maximum tolerance for synchronization of computer clocks
  710. //
  711. // Reserved -- Reserved
  712. //
  713. // The following data type defines the classes of Policy Information / Policy Domain Information
  714. // that may be used to request notification
  715. //
  716. typedef enum _POLICY_NOTIFICATION_INFORMATION_CLASS {
  717. PolicyNotifyAuditEventsInformation = 1,
  718. PolicyNotifyAccountDomainInformation,
  719. PolicyNotifyServerRoleInformation,
  720. PolicyNotifyDnsDomainInformation,
  721. PolicyNotifyDomainEfsInformation,
  722. PolicyNotifyDomainKerberosTicketInformation,
  723. PolicyNotifyMachineAccountPasswordInformation
  724. } POLICY_NOTIFICATION_INFORMATION_CLASS, *PPOLICY_NOTIFICATION_INFORMATION_CLASS;
  725. //
  726. // LSA RPC Context Handle (Opaque form). Note that a Context Handle is
  727. // always a pointer type unlike regular handles.
  728. //
  729. typedef PVOID LSA_HANDLE, *PLSA_HANDLE;
  730. //
  731. // Trusted Domain Object specific data types
  732. //
  733. //
  734. // This data type defines the following information classes that may be
  735. // queried or set.
  736. //
  737. typedef enum _TRUSTED_INFORMATION_CLASS {
  738. TrustedDomainNameInformation = 1,
  739. TrustedControllersInformation,
  740. TrustedPosixOffsetInformation,
  741. TrustedPasswordInformation,
  742. TrustedDomainInformationBasic,
  743. TrustedDomainInformationEx,
  744. TrustedDomainAuthInformation,
  745. TrustedDomainFullInformation,
  746. TrustedDomainAuthInformationInternal,
  747. TrustedDomainFullInformationInternal,
  748. TrustedDomainInformationEx2Internal,
  749. TrustedDomainFullInformation2Internal,
  750. } TRUSTED_INFORMATION_CLASS, *PTRUSTED_INFORMATION_CLASS;
  751. //
  752. // The following data type corresponds to the TrustedDomainNameInformation
  753. // information class.
  754. //
  755. typedef struct _TRUSTED_DOMAIN_NAME_INFO {
  756. LSA_UNICODE_STRING Name;
  757. } TRUSTED_DOMAIN_NAME_INFO, *PTRUSTED_DOMAIN_NAME_INFO;
  758. // where members have the following meaning:
  759. //
  760. // Name - The name of the Trusted Domain.
  761. //
  762. //
  763. // The following data type corresponds to the TrustedControllersInformation
  764. // information class.
  765. //
  766. typedef struct _TRUSTED_CONTROLLERS_INFO {
  767. ULONG Entries;
  768. PLSA_UNICODE_STRING Names;
  769. } TRUSTED_CONTROLLERS_INFO, *PTRUSTED_CONTROLLERS_INFO;
  770. // where members have the following meaning:
  771. //
  772. // Entries - Indicate how mamy entries there are in the Names array.
  773. //
  774. // Names - Pointer to an array of LSA_UNICODE_STRING structures containing the
  775. // names of domain controllers of the domain. This information may not
  776. // be accurate and should be used only as a hint. The order of this
  777. // list is considered significant and will be maintained.
  778. //
  779. // By convention, the first name in this list is assumed to be the
  780. // Primary Domain Controller of the domain. If the Primary Domain
  781. // Controller is not known, the first name should be set to the NULL
  782. // string.
  783. //
  784. //
  785. // The following data type corresponds to the TrustedPosixOffsetInformation
  786. // information class.
  787. //
  788. typedef struct _TRUSTED_POSIX_OFFSET_INFO {
  789. ULONG Offset;
  790. } TRUSTED_POSIX_OFFSET_INFO, *PTRUSTED_POSIX_OFFSET_INFO;
  791. // where members have the following meaning:
  792. //
  793. // Offset - Is an offset to use for the generation of Posix user and group
  794. // IDs from SIDs. The Posix ID corresponding to any particular SID is
  795. // generated by adding the RID of that SID to the Offset of the SID's
  796. // corresponding TrustedDomain object.
  797. //
  798. //
  799. // The following data type corresponds to the TrustedPasswordInformation
  800. // information class.
  801. //
  802. typedef struct _TRUSTED_PASSWORD_INFO {
  803. LSA_UNICODE_STRING Password;
  804. LSA_UNICODE_STRING OldPassword;
  805. } TRUSTED_PASSWORD_INFO, *PTRUSTED_PASSWORD_INFO;
  806. typedef LSA_TRUST_INFORMATION TRUSTED_DOMAIN_INFORMATION_BASIC;
  807. typedef PLSA_TRUST_INFORMATION PTRUSTED_DOMAIN_INFORMATION_BASIC;
  808. //
  809. // Direction of the trust
  810. //
  811. #define TRUST_DIRECTION_DISABLED 0x00000000
  812. #define TRUST_DIRECTION_INBOUND 0x00000001
  813. #define TRUST_DIRECTION_OUTBOUND 0x00000002
  814. #define TRUST_DIRECTION_BIDIRECTIONAL (TRUST_DIRECTION_INBOUND | TRUST_DIRECTION_OUTBOUND)
  815. #define TRUST_TYPE_DOWNLEVEL 0x00000001 // NT4 and before
  816. #define TRUST_TYPE_UPLEVEL 0x00000002 // NT5
  817. #define TRUST_TYPE_MIT 0x00000003 // Trust with a MIT Kerberos realm
  818. #define TRUST_TYPE_DCE 0x00000004 // Trust with a DCE realm
  819. // Levels 0x5 - 0x000FFFFF reserved for future use
  820. // Provider specific trust levels are from 0x00100000 to 0xFFF00000
  821. #define TRUST_ATTRIBUTE_NON_TRANSITIVE 0x00000001 // Disallow transitivity
  822. #define TRUST_ATTRIBUTE_UPLEVEL_ONLY 0x00000002 // Trust link only valid for uplevel client
  823. #define TRUST_ATTRIBUTE_FILTER_SIDS 0x00000004 // Used to quarantine domains
  824. #define TRUST_ATTRIBUTE_FOREST_TRANSITIVE 0x00000008 // This link may contain forest trust information
  825. // Trust attributes 0x00000010 through 0x00200000 are reserved for future use
  826. // Trust attributes 0x00400000 through 0x00800000 were used previously (up to W2K) and should not be re-used
  827. // Trust attributes 0x01000000 through 0x80000000 are reserved for user
  828. #define TRUST_ATTRIBUTES_VALID 0xFF03FFFF
  829. #define TRUST_ATTRIBUTES_USER 0xFF000000
  830. typedef struct _TRUSTED_DOMAIN_INFORMATION_EX {
  831. LSA_UNICODE_STRING Name;
  832. LSA_UNICODE_STRING FlatName;
  833. PSID Sid;
  834. ULONG TrustDirection;
  835. ULONG TrustType;
  836. ULONG TrustAttributes;
  837. } TRUSTED_DOMAIN_INFORMATION_EX, *PTRUSTED_DOMAIN_INFORMATION_EX;
  838. typedef struct _TRUSTED_DOMAIN_INFORMATION_EX2 {
  839. LSA_UNICODE_STRING Name;
  840. LSA_UNICODE_STRING FlatName;
  841. PSID Sid;
  842. ULONG TrustDirection;
  843. ULONG TrustType;
  844. ULONG TrustAttributes;
  845. ULONG ForestTrustLength;
  846. #ifdef MIDL_PASS
  847. [size_is( ForestTrustLength )]
  848. #endif
  849. PUCHAR ForestTrustInfo;
  850. } TRUSTED_DOMAIN_INFORMATION_EX2, *PTRUSTED_DOMAIN_INFORMATION_EX2;
  851. //
  852. // Type of authentication information
  853. //
  854. #define TRUST_AUTH_TYPE_NONE 0 // Ignore this entry
  855. #define TRUST_AUTH_TYPE_NT4OWF 1 // NT4 OWF password
  856. #define TRUST_AUTH_TYPE_CLEAR 2 // Cleartext password
  857. #define TRUST_AUTH_TYPE_VERSION 3 // Cleartext password version number
  858. typedef struct _LSA_AUTH_INFORMATION {
  859. LARGE_INTEGER LastUpdateTime;
  860. ULONG AuthType;
  861. ULONG AuthInfoLength;
  862. PUCHAR AuthInfo;
  863. } LSA_AUTH_INFORMATION, *PLSA_AUTH_INFORMATION;
  864. typedef struct _TRUSTED_DOMAIN_AUTH_INFORMATION {
  865. ULONG IncomingAuthInfos;
  866. PLSA_AUTH_INFORMATION IncomingAuthenticationInformation;
  867. PLSA_AUTH_INFORMATION IncomingPreviousAuthenticationInformation;
  868. ULONG OutgoingAuthInfos;
  869. PLSA_AUTH_INFORMATION OutgoingAuthenticationInformation;
  870. PLSA_AUTH_INFORMATION OutgoingPreviousAuthenticationInformation;
  871. } TRUSTED_DOMAIN_AUTH_INFORMATION, *PTRUSTED_DOMAIN_AUTH_INFORMATION;
  872. typedef struct _TRUSTED_DOMAIN_FULL_INFORMATION {
  873. TRUSTED_DOMAIN_INFORMATION_EX Information;
  874. TRUSTED_POSIX_OFFSET_INFO PosixOffset;
  875. TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
  876. } TRUSTED_DOMAIN_FULL_INFORMATION, *PTRUSTED_DOMAIN_FULL_INFORMATION;
  877. typedef struct _TRUSTED_DOMAIN_FULL_INFORMATION2 {
  878. TRUSTED_DOMAIN_INFORMATION_EX2 Information;
  879. TRUSTED_POSIX_OFFSET_INFO PosixOffset;
  880. TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
  881. } TRUSTED_DOMAIN_FULL_INFORMATION2, *PTRUSTED_DOMAIN_FULL_INFORMATION2;
  882. typedef enum {
  883. ForestTrustTopLevelName,
  884. ForestTrustTopLevelNameEx,
  885. ForestTrustDomainInfo,
  886. ForestTrustRecordTypeLast = ForestTrustDomainInfo
  887. } LSA_FOREST_TRUST_RECORD_TYPE;
  888. #define LSA_FOREST_TRUST_RECORD_TYPE_UNRECOGNIZED 0x80000000
  889. //
  890. // Bottom 16 bits of the flags are reserved for disablement reasons
  891. //
  892. #define LSA_FTRECORD_DISABLED_REASONS ( 0x0000FFFFL )
  893. //
  894. // Reasons for a top-level name forest trust record to be disabled
  895. //
  896. #define LSA_TLN_DISABLED_NEW ( 0x00000001L )
  897. #define LSA_TLN_DISABLED_ADMIN ( 0x00000002L )
  898. #define LSA_TLN_DISABLED_CONFLICT ( 0x00000004L )
  899. //
  900. // Reasons for a domain information forest trust record to be disabled
  901. //
  902. #define LSA_SID_DISABLED_ADMIN ( 0x00000001L )
  903. #define LSA_SID_DISABLED_CONFLICT ( 0x00000002L )
  904. #define LSA_NB_DISABLED_ADMIN ( 0x00000004L )
  905. #define LSA_NB_DISABLED_CONFLICT ( 0x00000008L )
  906. typedef struct _LSA_FOREST_TRUST_DOMAIN_INFO {
  907. #ifdef MIDL_PASS
  908. PISID Sid;
  909. #else
  910. PSID Sid;
  911. #endif
  912. LSA_UNICODE_STRING DnsName;
  913. LSA_UNICODE_STRING NetbiosName;
  914. } LSA_FOREST_TRUST_DOMAIN_INFO, *PLSA_FOREST_TRUST_DOMAIN_INFO;
  915. typedef struct _LSA_FOREST_TRUST_BINARY_DATA {
  916. ULONG Length;
  917. #ifdef MIDL_PASS
  918. [size_is( Length )]
  919. #endif
  920. PUCHAR Buffer;
  921. } LSA_FOREST_TRUST_BINARY_DATA, *PLSA_FOREST_TRUST_BINARY_DATA;
  922. typedef struct _LSA_FOREST_TRUST_RECORD {
  923. ULONG Flags;
  924. LSA_FOREST_TRUST_RECORD_TYPE ForestTrustType; // type of record
  925. LARGE_INTEGER Time;
  926. #ifdef MIDL_PASS
  927. [switch_type( LSA_FOREST_TRUST_RECORD_TYPE ), switch_is( ForestTrustType )]
  928. #endif
  929. union { // actual data
  930. #ifdef MIDL_PASS
  931. [case( ForestTrustTopLevelName,
  932. ForestTrustTopLevelNameEx )] LSA_UNICODE_STRING TopLevelName;
  933. [case( ForestTrustDomainInfo )] LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
  934. [default] LSA_FOREST_TRUST_BINARY_DATA Data;
  935. #else
  936. LSA_UNICODE_STRING TopLevelName;
  937. LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
  938. LSA_FOREST_TRUST_BINARY_DATA Data; // used for unrecognized types
  939. #endif
  940. } ForestTrustData;
  941. } LSA_FOREST_TRUST_RECORD, *PLSA_FOREST_TRUST_RECORD;
  942. typedef struct _LSA_FOREST_TRUST_INFORMATION {
  943. ULONG RecordCount;
  944. #ifdef MIDL_PASS
  945. [size_is( RecordCount )]
  946. #endif
  947. PLSA_FOREST_TRUST_RECORD * Entries;
  948. } LSA_FOREST_TRUST_INFORMATION, *PLSA_FOREST_TRUST_INFORMATION;
  949. typedef enum {
  950. CollisionTdo,
  951. CollisionXref,
  952. CollisionOther
  953. } LSA_FOREST_TRUST_COLLISION_RECORD_TYPE;
  954. typedef struct _LSA_FOREST_TRUST_COLLISION_RECORD {
  955. ULONG Index;
  956. LSA_FOREST_TRUST_COLLISION_RECORD_TYPE Type;
  957. ULONG Flags;
  958. LSA_UNICODE_STRING Name;
  959. } LSA_FOREST_TRUST_COLLISION_RECORD, *PLSA_FOREST_TRUST_COLLISION_RECORD;
  960. typedef struct _LSA_FOREST_TRUST_COLLISION_INFORMATION {
  961. ULONG RecordCount;
  962. #ifdef MIDL_PASS
  963. [size_is( RecordCount )]
  964. #endif
  965. PLSA_FOREST_TRUST_COLLISION_RECORD * Entries;
  966. } LSA_FOREST_TRUST_COLLISION_INFORMATION, *PLSA_FOREST_TRUST_COLLISION_INFORMATION;
  967. //
  968. // LSA Enumeration Context
  969. //
  970. typedef ULONG LSA_ENUMERATION_HANDLE, *PLSA_ENUMERATION_HANDLE;
  971. //
  972. // LSA Enumeration Information
  973. //
  974. typedef struct _LSA_ENUMERATION_INFORMATION {
  975. PSID Sid;
  976. } LSA_ENUMERATION_INFORMATION, *PLSA_ENUMERATION_INFORMATION;
  977. ////////////////////////////////////////////////////////////////////////////
  978. // //
  979. // Local Security Policy - Miscellaneous API function prototypes //
  980. // //
  981. ////////////////////////////////////////////////////////////////////////////
  982. NTSTATUS
  983. NTAPI
  984. LsaFreeMemory(
  985. IN PVOID Buffer
  986. );
  987. NTSTATUS
  988. NTAPI
  989. LsaClose(
  990. IN LSA_HANDLE ObjectHandle
  991. );
  992. typedef struct _SECURITY_LOGON_SESSION_DATA {
  993. ULONG Size ;
  994. LUID LogonId ;
  995. LSA_UNICODE_STRING UserName ;
  996. LSA_UNICODE_STRING LogonDomain ;
  997. LSA_UNICODE_STRING AuthenticationPackage ;
  998. ULONG LogonType ;
  999. ULONG Session ;
  1000. PSID Sid ;
  1001. LARGE_INTEGER LogonTime ;
  1002. //
  1003. // new for whistler:
  1004. //
  1005. LSA_UNICODE_STRING LogonServer ;
  1006. LSA_UNICODE_STRING DnsDomainName ;
  1007. LSA_UNICODE_STRING Upn ;
  1008. } SECURITY_LOGON_SESSION_DATA, * PSECURITY_LOGON_SESSION_DATA ;
  1009. NTSTATUS
  1010. NTAPI
  1011. LsaEnumerateLogonSessions(
  1012. OUT PULONG LogonSessionCount,
  1013. OUT PLUID * LogonSessionList
  1014. );
  1015. NTSTATUS
  1016. NTAPI
  1017. LsaGetLogonSessionData(
  1018. IN PLUID LogonId,
  1019. OUT PSECURITY_LOGON_SESSION_DATA * ppLogonSessionData
  1020. );
  1021. NTSTATUS
  1022. NTAPI
  1023. LsaOpenPolicy(
  1024. IN PLSA_UNICODE_STRING SystemName OPTIONAL,
  1025. IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
  1026. IN ACCESS_MASK DesiredAccess,
  1027. IN OUT PLSA_HANDLE PolicyHandle
  1028. );
  1029. NTSTATUS
  1030. NTAPI
  1031. LsaQueryInformationPolicy(
  1032. IN LSA_HANDLE PolicyHandle,
  1033. IN POLICY_INFORMATION_CLASS InformationClass,
  1034. OUT PVOID *Buffer
  1035. );
  1036. NTSTATUS
  1037. NTAPI
  1038. LsaSetInformationPolicy(
  1039. IN LSA_HANDLE PolicyHandle,
  1040. IN POLICY_INFORMATION_CLASS InformationClass,
  1041. IN PVOID Buffer
  1042. );
  1043. NTSTATUS
  1044. NTAPI
  1045. LsaQueryDomainInformationPolicy(
  1046. IN LSA_HANDLE PolicyHandle,
  1047. IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
  1048. OUT PVOID *Buffer
  1049. );
  1050. NTSTATUS
  1051. NTAPI
  1052. LsaSetDomainInformationPolicy(
  1053. IN LSA_HANDLE PolicyHandle,
  1054. IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
  1055. IN PVOID Buffer
  1056. );
  1057. NTSTATUS
  1058. NTAPI
  1059. LsaRegisterPolicyChangeNotification(
  1060. IN POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
  1061. IN HANDLE NotificationEventHandle
  1062. );
  1063. NTSTATUS
  1064. NTAPI
  1065. LsaUnregisterPolicyChangeNotification(
  1066. IN POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
  1067. IN HANDLE NotificationEventHandle
  1068. );
  1069. NTSTATUS
  1070. NTAPI
  1071. LsaEnumerateTrustedDomains(
  1072. IN LSA_HANDLE PolicyHandle,
  1073. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  1074. OUT PVOID *Buffer,
  1075. IN ULONG PreferedMaximumLength,
  1076. OUT PULONG CountReturned
  1077. );
  1078. NTSTATUS
  1079. NTAPI
  1080. LsaLookupNames(
  1081. IN LSA_HANDLE PolicyHandle,
  1082. IN ULONG Count,
  1083. IN PLSA_UNICODE_STRING Names,
  1084. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  1085. OUT PLSA_TRANSLATED_SID *Sids
  1086. );
  1087. NTSTATUS
  1088. NTAPI
  1089. LsaLookupNames2(
  1090. IN LSA_HANDLE PolicyHandle,
  1091. IN ULONG Flags, // Reserved
  1092. IN ULONG Count,
  1093. IN PLSA_UNICODE_STRING Names,
  1094. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  1095. OUT PLSA_TRANSLATED_SID2 *Sids
  1096. );
  1097. NTSTATUS
  1098. NTAPI
  1099. LsaLookupSids(
  1100. IN LSA_HANDLE PolicyHandle,
  1101. IN ULONG Count,
  1102. IN PSID *Sids,
  1103. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  1104. OUT PLSA_TRANSLATED_NAME *Names
  1105. );
  1106. #define SE_INTERACTIVE_LOGON_NAME TEXT("SeInteractiveLogonRight")
  1107. #define SE_NETWORK_LOGON_NAME TEXT("SeNetworkLogonRight")
  1108. #define SE_BATCH_LOGON_NAME TEXT("SeBatchLogonRight")
  1109. #define SE_SERVICE_LOGON_NAME TEXT("SeServiceLogonRight")
  1110. #define SE_DENY_INTERACTIVE_LOGON_NAME TEXT("SeDenyInteractiveLogonRight")
  1111. #define SE_DENY_NETWORK_LOGON_NAME TEXT("SeDenyNetworkLogonRight")
  1112. #define SE_DENY_BATCH_LOGON_NAME TEXT("SeDenyBatchLogonRight")
  1113. #define SE_DENY_SERVICE_LOGON_NAME TEXT("SeDenyServiceLogonRight")
  1114. #define SE_REMOTE_INTERACTIVE_LOGON_NAME TEXT("SeRemoteInteractiveLogonRight")
  1115. #define SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME TEXT("SeDenyRemoteInteractiveLogonRight")
  1116. //
  1117. // This new API returns all the accounts with a certain privilege
  1118. //
  1119. NTSTATUS
  1120. NTAPI
  1121. LsaEnumerateAccountsWithUserRight(
  1122. IN LSA_HANDLE PolicyHandle,
  1123. IN OPTIONAL PLSA_UNICODE_STRING UserRights,
  1124. OUT PVOID *EnumerationBuffer,
  1125. OUT PULONG CountReturned
  1126. );
  1127. //
  1128. // These new APIs differ by taking a SID instead of requiring the caller
  1129. // to open the account first and passing in an account handle
  1130. //
  1131. NTSTATUS
  1132. NTAPI
  1133. LsaEnumerateAccountRights(
  1134. IN LSA_HANDLE PolicyHandle,
  1135. IN PSID AccountSid,
  1136. OUT PLSA_UNICODE_STRING *UserRights,
  1137. OUT PULONG CountOfRights
  1138. );
  1139. NTSTATUS
  1140. NTAPI
  1141. LsaAddAccountRights(
  1142. IN LSA_HANDLE PolicyHandle,
  1143. IN PSID AccountSid,
  1144. IN PLSA_UNICODE_STRING UserRights,
  1145. IN ULONG CountOfRights
  1146. );
  1147. NTSTATUS
  1148. NTAPI
  1149. LsaRemoveAccountRights(
  1150. IN LSA_HANDLE PolicyHandle,
  1151. IN PSID AccountSid,
  1152. IN BOOLEAN AllRights,
  1153. IN PLSA_UNICODE_STRING UserRights,
  1154. IN ULONG CountOfRights
  1155. );
  1156. ///////////////////////////////////////////////////////////////////////////////
  1157. // //
  1158. // Local Security Policy - Trusted Domain Object API function prototypes //
  1159. // //
  1160. ///////////////////////////////////////////////////////////////////////////////
  1161. NTSTATUS
  1162. NTAPI
  1163. LsaOpenTrustedDomainByName(
  1164. IN LSA_HANDLE PolicyHandle,
  1165. IN PLSA_UNICODE_STRING TrustedDomainName,
  1166. IN ACCESS_MASK DesiredAccess,
  1167. OUT PLSA_HANDLE TrustedDomainHandle
  1168. );
  1169. NTSTATUS
  1170. NTAPI
  1171. LsaQueryTrustedDomainInfo(
  1172. IN LSA_HANDLE PolicyHandle,
  1173. IN PSID TrustedDomainSid,
  1174. IN TRUSTED_INFORMATION_CLASS InformationClass,
  1175. OUT PVOID *Buffer
  1176. );
  1177. NTSTATUS
  1178. NTAPI
  1179. LsaSetTrustedDomainInformation(
  1180. IN LSA_HANDLE PolicyHandle,
  1181. IN PSID TrustedDomainSid,
  1182. IN TRUSTED_INFORMATION_CLASS InformationClass,
  1183. IN PVOID Buffer
  1184. );
  1185. NTSTATUS
  1186. NTAPI
  1187. LsaDeleteTrustedDomain(
  1188. IN LSA_HANDLE PolicyHandle,
  1189. IN PSID TrustedDomainSid
  1190. );
  1191. NTSTATUS
  1192. NTAPI
  1193. LsaQueryTrustedDomainInfoByName(
  1194. IN LSA_HANDLE PolicyHandle,
  1195. IN PLSA_UNICODE_STRING TrustedDomainName,
  1196. IN TRUSTED_INFORMATION_CLASS InformationClass,
  1197. OUT PVOID *Buffer
  1198. );
  1199. NTSTATUS
  1200. NTAPI
  1201. LsaSetTrustedDomainInfoByName(
  1202. IN LSA_HANDLE PolicyHandle,
  1203. IN PLSA_UNICODE_STRING TrustedDomainName,
  1204. IN TRUSTED_INFORMATION_CLASS InformationClass,
  1205. IN PVOID Buffer
  1206. );
  1207. NTSTATUS
  1208. NTAPI
  1209. LsaEnumerateTrustedDomainsEx(
  1210. IN LSA_HANDLE PolicyHandle,
  1211. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  1212. OUT PVOID *Buffer,
  1213. IN ULONG PreferedMaximumLength,
  1214. OUT PULONG CountReturned
  1215. );
  1216. NTSTATUS
  1217. NTAPI
  1218. LsaCreateTrustedDomainEx(
  1219. IN LSA_HANDLE PolicyHandle,
  1220. IN PTRUSTED_DOMAIN_INFORMATION_EX TrustedDomainInformation,
  1221. IN PTRUSTED_DOMAIN_AUTH_INFORMATION AuthenticationInformation,
  1222. IN ACCESS_MASK DesiredAccess,
  1223. OUT PLSA_HANDLE TrustedDomainHandle
  1224. );
  1225. NTSTATUS
  1226. NTAPI
  1227. LsaQueryForestTrustInformation(
  1228. IN LSA_HANDLE PolicyHandle,
  1229. IN PLSA_UNICODE_STRING TrustedDomainName,
  1230. OUT PLSA_FOREST_TRUST_INFORMATION * ForestTrustInfo
  1231. );
  1232. NTSTATUS
  1233. NTAPI
  1234. LsaSetForestTrustInformation(
  1235. IN LSA_HANDLE PolicyHandle,
  1236. IN PLSA_UNICODE_STRING TrustedDomainName,
  1237. IN PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
  1238. IN BOOLEAN CheckOnly,
  1239. OUT PLSA_FOREST_TRUST_COLLISION_INFORMATION * CollisionInfo
  1240. );
  1241. // #define TESTING_MATCHING_ROUTINE
  1242. #ifdef TESTING_MATCHING_ROUTINE
  1243. NTSTATUS
  1244. NTAPI
  1245. LsaForestTrustFindMatch(
  1246. IN LSA_HANDLE PolicyHandle,
  1247. IN ULONG Type,
  1248. IN PLSA_UNICODE_STRING Name,
  1249. OUT PLSA_UNICODE_STRING * Match
  1250. );
  1251. #endif
  1252. //
  1253. // This API sets the workstation password (equivalent of setting/getting
  1254. // the SSI_SECRET_NAME secret)
  1255. //
  1256. NTSTATUS
  1257. NTAPI
  1258. LsaStorePrivateData(
  1259. IN LSA_HANDLE PolicyHandle,
  1260. IN PLSA_UNICODE_STRING KeyName,
  1261. IN PLSA_UNICODE_STRING PrivateData
  1262. );
  1263. NTSTATUS
  1264. NTAPI
  1265. LsaRetrievePrivateData(
  1266. IN LSA_HANDLE PolicyHandle,
  1267. IN PLSA_UNICODE_STRING KeyName,
  1268. OUT PLSA_UNICODE_STRING * PrivateData
  1269. );
  1270. ULONG
  1271. NTAPI
  1272. LsaNtStatusToWinError(
  1273. NTSTATUS Status
  1274. );
  1275. //
  1276. // Define a symbol so we can tell if ntifs.h has been included.
  1277. //
  1278. // begin_ntifs
  1279. #ifndef _NTLSA_IFS_
  1280. #define _NTLSA_IFS_
  1281. #endif
  1282. // end_ntifs
  1283. //
  1284. // SPNEGO package stuff
  1285. //
  1286. enum NEGOTIATE_MESSAGES {
  1287. NegEnumPackagePrefixes = 0,
  1288. NegGetCallerName = 1,
  1289. NegCallPackageMax
  1290. } ;
  1291. #define NEGOTIATE_MAX_PREFIX 32
  1292. typedef struct _NEGOTIATE_PACKAGE_PREFIX {
  1293. ULONG_PTR PackageId ;
  1294. PVOID PackageDataA ;
  1295. PVOID PackageDataW ;
  1296. ULONG_PTR PrefixLen ;
  1297. UCHAR Prefix[ NEGOTIATE_MAX_PREFIX ];
  1298. } NEGOTIATE_PACKAGE_PREFIX, * PNEGOTIATE_PACKAGE_PREFIX ;
  1299. typedef struct _NEGOTIATE_PACKAGE_PREFIXES {
  1300. ULONG MessageType ;
  1301. ULONG PrefixCount ;
  1302. ULONG Offset ; // Offset to array of _PREFIX above
  1303. } NEGOTIATE_PACKAGE_PREFIXES, *PNEGOTIATE_PACKAGE_PREFIXES ;
  1304. typedef struct _NEGOTIATE_CALLER_NAME_REQUEST {
  1305. ULONG MessageType ;
  1306. LUID LogonId ;
  1307. } NEGOTIATE_CALLER_NAME_REQUEST, *PNEGOTIATE_CALLER_NAME_REQUEST ;
  1308. typedef struct _NEGOTIATE_CALLER_NAME_RESPONSE {
  1309. ULONG MessageType ;
  1310. PWSTR CallerName ;
  1311. } NEGOTIATE_CALLER_NAME_RESPONSE, * PNEGOTIATE_CALLER_NAME_RESPONSE ;
  1312. #define NEGOTIATE_ALLOW_NTLM 0x10000000
  1313. #define NEGOTIATE_NEG_NTLM 0x20000000
  1314. #ifndef _NTDEF_
  1315. typedef LSA_UNICODE_STRING UNICODE_STRING, *PUNICODE_STRING;
  1316. typedef LSA_STRING STRING, *PSTRING ;
  1317. #endif
  1318. #ifndef _DOMAIN_PASSWORD_INFORMATION_DEFINED
  1319. #define _DOMAIN_PASSWORD_INFORMATION_DEFINED
  1320. typedef struct _DOMAIN_PASSWORD_INFORMATION {
  1321. USHORT MinPasswordLength;
  1322. USHORT PasswordHistoryLength;
  1323. ULONG PasswordProperties;
  1324. #if defined(MIDL_PASS)
  1325. OLD_LARGE_INTEGER MaxPasswordAge;
  1326. OLD_LARGE_INTEGER MinPasswordAge;
  1327. #else
  1328. LARGE_INTEGER MaxPasswordAge;
  1329. LARGE_INTEGER MinPasswordAge;
  1330. #endif
  1331. } DOMAIN_PASSWORD_INFORMATION, *PDOMAIN_PASSWORD_INFORMATION;
  1332. #endif
  1333. //
  1334. // PasswordProperties flags
  1335. //
  1336. #define DOMAIN_PASSWORD_COMPLEX 0x00000001L
  1337. #define DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002L
  1338. #define DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004L
  1339. #define DOMAIN_LOCKOUT_ADMINS 0x00000008L
  1340. #define DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010L
  1341. #define DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020L
  1342. #define DOMAIN_NO_LM_OWF_CHANGE 0x00000040L
  1343. #ifndef _PASSWORD_NOTIFICATION_DEFINED
  1344. #define _PASSWORD_NOTIFICATION_DEFINED
  1345. typedef NTSTATUS (*PSAM_PASSWORD_NOTIFICATION_ROUTINE) (
  1346. PUNICODE_STRING UserName,
  1347. ULONG RelativeId,
  1348. PUNICODE_STRING NewPassword
  1349. );
  1350. #define SAM_PASSWORD_CHANGE_NOTIFY_ROUTINE "PasswordChangeNotify"
  1351. typedef BOOLEAN (*PSAM_INIT_NOTIFICATION_ROUTINE) (
  1352. );
  1353. #define SAM_INIT_NOTIFICATION_ROUTINE "InitializeChangeNotify"
  1354. #define SAM_PASSWORD_FILTER_ROUTINE "PasswordFilter"
  1355. typedef BOOLEAN (*PSAM_PASSWORD_FILTER_ROUTINE) (
  1356. IN PUNICODE_STRING AccountName,
  1357. IN PUNICODE_STRING FullName,
  1358. IN PUNICODE_STRING Password,
  1359. IN BOOLEAN SetOperation
  1360. );
  1361. #endif // _PASSWORD_NOTIFICATION_DEFINED
  1362. /////////////////////////////////////////////////////////////////////////
  1363. // //
  1364. // Name of the MSV1_0 authentication package //
  1365. // //
  1366. /////////////////////////////////////////////////////////////////////////
  1367. #define MSV1_0_PACKAGE_NAME "MICROSOFT_AUTHENTICATION_PACKAGE_V1_0"
  1368. #define MSV1_0_PACKAGE_NAMEW L"MICROSOFT_AUTHENTICATION_PACKAGE_V1_0"
  1369. #define MSV1_0_PACKAGE_NAMEW_LENGTH sizeof(MSV1_0_PACKAGE_NAMEW) - sizeof(WCHAR)
  1370. //
  1371. // Location of MSV authentication package data
  1372. //
  1373. #define MSV1_0_SUBAUTHENTICATION_KEY "SYSTEM\\CurrentControlSet\\Control\\Lsa\\MSV1_0"
  1374. #define MSV1_0_SUBAUTHENTICATION_VALUE "Auth"
  1375. /////////////////////////////////////////////////////////////////////////
  1376. // //
  1377. // Widely used MSV1_0 data types //
  1378. // //
  1379. /////////////////////////////////////////////////////////////////////////
  1380. ///////////////////////////////////////////////////////////////////////////////
  1381. // //
  1382. // LOGON Related Data Structures
  1383. //
  1384. // //
  1385. ///////////////////////////////////////////////////////////////////////////////
  1386. //
  1387. // When a LsaLogonUser() call is dispatched to the MsV1_0 authentication
  1388. // package, the beginning of the AuthenticationInformation buffer is
  1389. // cast to a MSV1_0_LOGON_SUBMIT_TYPE to determine the type of logon
  1390. // being requested. Similarly, upon return, the type of profile buffer
  1391. // can be determined by typecasting it to a MSV_1_0_PROFILE_BUFFER_TYPE.
  1392. //
  1393. //
  1394. // MSV1.0 LsaLogonUser() submission message types.
  1395. //
  1396. typedef enum _MSV1_0_LOGON_SUBMIT_TYPE {
  1397. MsV1_0InteractiveLogon = 2,
  1398. MsV1_0Lm20Logon,
  1399. MsV1_0NetworkLogon,
  1400. MsV1_0SubAuthLogon,
  1401. MsV1_0WorkstationUnlockLogon = 7
  1402. } MSV1_0_LOGON_SUBMIT_TYPE, *PMSV1_0_LOGON_SUBMIT_TYPE;
  1403. //
  1404. // MSV1.0 LsaLogonUser() profile buffer types.
  1405. //
  1406. typedef enum _MSV1_0_PROFILE_BUFFER_TYPE {
  1407. MsV1_0InteractiveProfile = 2,
  1408. MsV1_0Lm20LogonProfile,
  1409. MsV1_0SmartCardProfile
  1410. } MSV1_0_PROFILE_BUFFER_TYPE, *PMSV1_0_PROFILE_BUFFER_TYPE;
  1411. //
  1412. // MsV1_0InteractiveLogon
  1413. //
  1414. // The AuthenticationInformation buffer of an LsaLogonUser() call to
  1415. // perform an interactive logon contains the following data structure:
  1416. //
  1417. typedef struct _MSV1_0_INTERACTIVE_LOGON {
  1418. MSV1_0_LOGON_SUBMIT_TYPE MessageType;
  1419. UNICODE_STRING LogonDomainName;
  1420. UNICODE_STRING UserName;
  1421. UNICODE_STRING Password;
  1422. } MSV1_0_INTERACTIVE_LOGON, *PMSV1_0_INTERACTIVE_LOGON;
  1423. //
  1424. // Where:
  1425. //
  1426. // MessageType - Contains the type of logon being requested. This
  1427. // field must be set to MsV1_0InteractiveLogon.
  1428. //
  1429. // UserName - Is a string representing the user's account name. The
  1430. // name may be up to 255 characters long. The name is treated case
  1431. // insensitive.
  1432. //
  1433. // Password - Is a string containing the user's cleartext password.
  1434. // The password may be up to 255 characters long and contain any
  1435. // UNICODE value.
  1436. //
  1437. //
  1438. //
  1439. // The ProfileBuffer returned upon a successful logon of this type
  1440. // contains the following data structure:
  1441. //
  1442. typedef struct _MSV1_0_INTERACTIVE_PROFILE {
  1443. MSV1_0_PROFILE_BUFFER_TYPE MessageType;
  1444. USHORT LogonCount;
  1445. USHORT BadPasswordCount;
  1446. LARGE_INTEGER LogonTime;
  1447. LARGE_INTEGER LogoffTime;
  1448. LARGE_INTEGER KickOffTime;
  1449. LARGE_INTEGER PasswordLastSet;
  1450. LARGE_INTEGER PasswordCanChange;
  1451. LARGE_INTEGER PasswordMustChange;
  1452. UNICODE_STRING LogonScript;
  1453. UNICODE_STRING HomeDirectory;
  1454. UNICODE_STRING FullName;
  1455. UNICODE_STRING ProfilePath;
  1456. UNICODE_STRING HomeDirectoryDrive;
  1457. UNICODE_STRING LogonServer;
  1458. ULONG UserFlags;
  1459. } MSV1_0_INTERACTIVE_PROFILE, *PMSV1_0_INTERACTIVE_PROFILE;
  1460. //
  1461. // where:
  1462. //
  1463. // MessageType - Identifies the type of profile data being returned.
  1464. // Contains the type of logon being requested. This field must
  1465. // be set to MsV1_0InteractiveProfile.
  1466. //
  1467. // LogonCount - Number of times the user is currently logged on.
  1468. //
  1469. // BadPasswordCount - Number of times a bad password was applied to
  1470. // the account since last successful logon.
  1471. //
  1472. // LogonTime - Time when user last logged on. This is an absolute
  1473. // format NT standard time value.
  1474. //
  1475. // LogoffTime - Time when user should log off. This is an absolute
  1476. // format NT standard time value.
  1477. //
  1478. // KickOffTime - Time when system should force user logoff. This is
  1479. // an absolute format NT standard time value.
  1480. //
  1481. // PasswordLastChanged - Time and date the password was last
  1482. // changed. This is an absolute format NT standard time
  1483. // value.
  1484. //
  1485. // PasswordCanChange - Time and date when the user can change the
  1486. // password. This is an absolute format NT time value. To
  1487. // prevent a password from ever changing, set this field to a
  1488. // date very far into the future.
  1489. //
  1490. // PasswordMustChange - Time and date when the user must change the
  1491. // password. If the user can never change the password, this
  1492. // field is undefined. This is an absolute format NT time
  1493. // value.
  1494. //
  1495. // LogonScript - The (relative) path to the account's logon
  1496. // script.
  1497. //
  1498. // HomeDirectory - The home directory for the user.
  1499. //
  1500. //
  1501. // MsV1_0Lm20Logon and MsV1_0NetworkLogon
  1502. //
  1503. // The AuthenticationInformation buffer of an LsaLogonUser() call to
  1504. // perform an network logon contains the following data structure:
  1505. //
  1506. // MsV1_0NetworkLogon logon differs from MsV1_0Lm20Logon in that the
  1507. // ParameterControl field exists.
  1508. //
  1509. #define MSV1_0_CHALLENGE_LENGTH 8
  1510. #define MSV1_0_USER_SESSION_KEY_LENGTH 16
  1511. #define MSV1_0_LANMAN_SESSION_KEY_LENGTH 8
  1512. //
  1513. // Values for ParameterControl.
  1514. //
  1515. #define MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x02
  1516. #define MSV1_0_UPDATE_LOGON_STATISTICS 0x04
  1517. #define MSV1_0_RETURN_USER_PARAMETERS 0x08
  1518. #define MSV1_0_DONT_TRY_GUEST_ACCOUNT 0x10
  1519. #define MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x20
  1520. #define MSV1_0_RETURN_PASSWORD_EXPIRY 0x40
  1521. // this next flag says that CaseInsensitiveChallengeResponse
  1522. // (aka LmResponse) contains a client challenge in the first 8 bytes
  1523. #define MSV1_0_USE_CLIENT_CHALLENGE 0x80
  1524. #define MSV1_0_TRY_GUEST_ACCOUNT_ONLY 0x100
  1525. #define MSV1_0_RETURN_PROFILE_PATH 0x200
  1526. #define MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY 0x400
  1527. #define MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x800
  1528. #define MSV1_0_DISABLE_PERSONAL_FALLBACK 0x00001000
  1529. #define MSV1_0_ALLOW_FORCE_GUEST 0x00002000
  1530. #define MSV1_0_SUBAUTHENTICATION_DLL_EX 0x00100000
  1531. //
  1532. // The high order byte is a value indicating the SubAuthentication DLL.
  1533. // Zero indicates no SubAuthentication DLL.
  1534. //
  1535. #define MSV1_0_SUBAUTHENTICATION_DLL 0xFF000000
  1536. #define MSV1_0_SUBAUTHENTICATION_DLL_SHIFT 24
  1537. #define MSV1_0_MNS_LOGON 0x01000000
  1538. //
  1539. // This is the list of subauthentication dlls used in MS
  1540. //
  1541. #define MSV1_0_SUBAUTHENTICATION_DLL_RAS 2
  1542. #define MSV1_0_SUBAUTHENTICATION_DLL_IIS 132
  1543. typedef struct _MSV1_0_LM20_LOGON {
  1544. MSV1_0_LOGON_SUBMIT_TYPE MessageType;
  1545. UNICODE_STRING LogonDomainName;
  1546. UNICODE_STRING UserName;
  1547. UNICODE_STRING Workstation;
  1548. UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
  1549. STRING CaseSensitiveChallengeResponse;
  1550. STRING CaseInsensitiveChallengeResponse;
  1551. ULONG ParameterControl;
  1552. } MSV1_0_LM20_LOGON, * PMSV1_0_LM20_LOGON;
  1553. //
  1554. // NT 5.0 SubAuth dlls can use this struct
  1555. //
  1556. typedef struct _MSV1_0_SUBAUTH_LOGON{
  1557. MSV1_0_LOGON_SUBMIT_TYPE MessageType;
  1558. UNICODE_STRING LogonDomainName;
  1559. UNICODE_STRING UserName;
  1560. UNICODE_STRING Workstation;
  1561. UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
  1562. STRING AuthenticationInfo1;
  1563. STRING AuthenticationInfo2;
  1564. ULONG ParameterControl;
  1565. ULONG SubAuthPackageId;
  1566. } MSV1_0_SUBAUTH_LOGON, * PMSV1_0_SUBAUTH_LOGON;
  1567. //
  1568. // Values for UserFlags.
  1569. //
  1570. #define LOGON_GUEST 0x01
  1571. #define LOGON_NOENCRYPTION 0x02
  1572. #define LOGON_CACHED_ACCOUNT 0x04
  1573. #define LOGON_USED_LM_PASSWORD 0x08
  1574. #define LOGON_EXTRA_SIDS 0x20
  1575. #define LOGON_SUBAUTH_SESSION_KEY 0x40
  1576. #define LOGON_SERVER_TRUST_ACCOUNT 0x80
  1577. #define LOGON_NTLMV2_ENABLED 0x100 // says DC understands NTLMv2
  1578. #define LOGON_RESOURCE_GROUPS 0x200
  1579. #define LOGON_PROFILE_PATH_RETURNED 0x400
  1580. //
  1581. // The high order byte is reserved for return by SubAuthentication DLLs.
  1582. //
  1583. #define MSV1_0_SUBAUTHENTICATION_FLAGS 0xFF000000
  1584. // Values returned by the MSV1_0_MNS_LOGON SubAuthentication DLL
  1585. #define LOGON_GRACE_LOGON 0x01000000
  1586. typedef struct _MSV1_0_LM20_LOGON_PROFILE {
  1587. MSV1_0_PROFILE_BUFFER_TYPE MessageType;
  1588. LARGE_INTEGER KickOffTime;
  1589. LARGE_INTEGER LogoffTime;
  1590. ULONG UserFlags;
  1591. UCHAR UserSessionKey[MSV1_0_USER_SESSION_KEY_LENGTH];
  1592. UNICODE_STRING LogonDomainName;
  1593. UCHAR LanmanSessionKey[MSV1_0_LANMAN_SESSION_KEY_LENGTH];
  1594. UNICODE_STRING LogonServer;
  1595. UNICODE_STRING UserParameters;
  1596. } MSV1_0_LM20_LOGON_PROFILE, * PMSV1_0_LM20_LOGON_PROFILE;
  1597. //
  1598. // Supplemental credentials structure used for passing credentials into
  1599. // MSV1_0 from other packages
  1600. //
  1601. #define MSV1_0_OWF_PASSWORD_LENGTH 16
  1602. #define MSV1_0_CRED_LM_PRESENT 0x1
  1603. #define MSV1_0_CRED_NT_PRESENT 0x2
  1604. #define MSV1_0_CRED_VERSION 0
  1605. typedef struct _MSV1_0_SUPPLEMENTAL_CREDENTIAL {
  1606. ULONG Version;
  1607. ULONG Flags;
  1608. UCHAR LmPassword[MSV1_0_OWF_PASSWORD_LENGTH];
  1609. UCHAR NtPassword[MSV1_0_OWF_PASSWORD_LENGTH];
  1610. } MSV1_0_SUPPLEMENTAL_CREDENTIAL, *PMSV1_0_SUPPLEMENTAL_CREDENTIAL;
  1611. //
  1612. // NTLM3 definitions.
  1613. //
  1614. #define MSV1_0_NTLM3_RESPONSE_LENGTH 16
  1615. #define MSV1_0_NTLM3_OWF_LENGTH 16
  1616. //
  1617. // this is the longest amount of time we'll allow challenge response
  1618. // pairs to be used. Note that this also has to allow for worst case clock skew
  1619. //
  1620. #define MSV1_0_MAX_NTLM3_LIFE 129600 // 36 hours (in seconds)
  1621. #define MSV1_0_MAX_AVL_SIZE 64000
  1622. //
  1623. // MsvAvFlags bit values
  1624. //
  1625. #define MSV1_0_AV_FLAG_FORCE_GUEST 0x00000001
  1626. // this is an MSV1_0 private data structure, defining the layout of an NTLM3 response, as sent by a
  1627. // client in the NtChallengeResponse field of the NETLOGON_NETWORK_INFO structure. If can be differentiated
  1628. // from an old style NT response by its length. This is crude, but it needs to pass through servers and
  1629. // the servers' DCs that do not understand NTLM3 but that are willing to pass longer responses.
  1630. typedef struct _MSV1_0_NTLM3_RESPONSE {
  1631. UCHAR Response[MSV1_0_NTLM3_RESPONSE_LENGTH]; // hash of OWF of password with all the following fields
  1632. UCHAR RespType; // id number of response; current is 1
  1633. UCHAR HiRespType; // highest id number understood by client
  1634. USHORT Flags; // reserved; must be sent as zero at this version
  1635. ULONG MsgWord; // 32 bit message from client to server (for use by auth protocol)
  1636. ULONGLONG TimeStamp; // time stamp when client generated response -- NT system time, quad part
  1637. UCHAR ChallengeFromClient[MSV1_0_CHALLENGE_LENGTH];
  1638. ULONG AvPairsOff; // offset to start of AvPairs (to allow future expansion)
  1639. UCHAR Buffer[1]; // start of buffer with AV pairs (or future stuff -- so use the offset)
  1640. } MSV1_0_NTLM3_RESPONSE, *PMSV1_0_NTLM3_RESPONSE;
  1641. #define MSV1_0_NTLM3_INPUT_LENGTH (sizeof(MSV1_0_NTLM3_RESPONSE) - MSV1_0_NTLM3_RESPONSE_LENGTH)
  1642. typedef enum {
  1643. MsvAvEOL, // end of list
  1644. MsvAvNbComputerName, // server's computer name -- NetBIOS
  1645. MsvAvNbDomainName, // server's domain name -- NetBIOS
  1646. MsvAvDnsComputerName, // server's computer name -- DNS
  1647. MsvAvDnsDomainName, // server's domain name -- DNS
  1648. MsvAvDnsTreeName, // server's tree name -- DNS
  1649. MsvAvFlags // server's extended flags -- DWORD mask
  1650. } MSV1_0_AVID;
  1651. typedef struct _MSV1_0_AV_PAIR {
  1652. USHORT AvId;
  1653. USHORT AvLen;
  1654. // Data is treated as byte array following structure
  1655. } MSV1_0_AV_PAIR, *PMSV1_0_AV_PAIR;
  1656. ///////////////////////////////////////////////////////////////////////////////
  1657. // //
  1658. // CALL PACKAGE Related Data Structures //
  1659. // //
  1660. ///////////////////////////////////////////////////////////////////////////////
  1661. //
  1662. // MSV1.0 LsaCallAuthenticationPackage() submission and response
  1663. // message types.
  1664. //
  1665. typedef enum _MSV1_0_PROTOCOL_MESSAGE_TYPE {
  1666. MsV1_0Lm20ChallengeRequest = 0, // Both submission and response
  1667. MsV1_0Lm20GetChallengeResponse, // Both submission and response
  1668. MsV1_0EnumerateUsers, // Both submission and response
  1669. MsV1_0GetUserInfo, // Both submission and response
  1670. MsV1_0ReLogonUsers, // Submission only
  1671. MsV1_0ChangePassword, // Both submission and response
  1672. MsV1_0ChangeCachedPassword, // Both submission and response
  1673. MsV1_0GenericPassthrough, // Both submission and response
  1674. MsV1_0CacheLogon, // Submission only, no response
  1675. MsV1_0SubAuth, // Both submission and response
  1676. MsV1_0DeriveCredential, // Both submission and response
  1677. MsV1_0CacheLookup, // Both submission and response
  1678. MsV1_0SetProcessOption, // Submission only, no response
  1679. } MSV1_0_PROTOCOL_MESSAGE_TYPE, *PMSV1_0_PROTOCOL_MESSAGE_TYPE;
  1680. typedef struct _MSV1_0_CHANGEPASSWORD_REQUEST {
  1681. MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
  1682. UNICODE_STRING DomainName;
  1683. UNICODE_STRING AccountName;
  1684. UNICODE_STRING OldPassword;
  1685. UNICODE_STRING NewPassword;
  1686. BOOLEAN Impersonating;
  1687. } MSV1_0_CHANGEPASSWORD_REQUEST, *PMSV1_0_CHANGEPASSWORD_REQUEST;
  1688. typedef struct _MSV1_0_CHANGEPASSWORD_RESPONSE {
  1689. MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
  1690. BOOLEAN PasswordInfoValid;
  1691. DOMAIN_PASSWORD_INFORMATION DomainPasswordInfo;
  1692. } MSV1_0_CHANGEPASSWORD_RESPONSE, *PMSV1_0_CHANGEPASSWORD_RESPONSE;
  1693. //
  1694. // MsV1_0SubAuthInfo submit buffer and response - for submitting a buffer to a
  1695. // specified Subauthentication Package during an LsaCallAuthenticationPackage().
  1696. // If this Subauthentication is to be done locally, then package this message
  1697. // in LsaCallAuthenticationPackage(). If this SubAuthentication needs to be done
  1698. // on the domain controller, then call LsaCallauthenticationPackage with the
  1699. // message type being MsV1_0GenericPassThrough and the LogonData in this struct
  1700. // should be a PMSV1_0_SUBAUTH_REQUEST
  1701. //
  1702. typedef struct _MSV1_0_SUBAUTH_REQUEST{
  1703. MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
  1704. ULONG SubAuthPackageId;
  1705. ULONG SubAuthInfoLength;
  1706. PUCHAR SubAuthSubmitBuffer;
  1707. } MSV1_0_SUBAUTH_REQUEST, *PMSV1_0_SUBAUTH_REQUEST;
  1708. typedef struct _MSV1_0_SUBAUTH_RESPONSE{
  1709. MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
  1710. ULONG SubAuthInfoLength;
  1711. PUCHAR SubAuthReturnBuffer;
  1712. } MSV1_0_SUBAUTH_RESPONSE, *PMSV1_0_SUBAUTH_RESPONSE;
  1713. // Revision of the Kerberos Protocol. MS uses Version 5, Revision 6
  1714. #define KERBEROS_VERSION 5
  1715. #define KERBEROS_REVISION 6
  1716. // Encryption Types:
  1717. // These encryption types are supported by the default MS KERBSUPP DLL
  1718. // as crypto systems. Values over 127 are local values, and may be changed
  1719. // without notice.
  1720. #define KERB_ETYPE_NULL 0
  1721. #define KERB_ETYPE_DES_CBC_CRC 1
  1722. #define KERB_ETYPE_DES_CBC_MD4 2
  1723. #define KERB_ETYPE_DES_CBC_MD5 3
  1724. #define KERB_ETYPE_RC4_MD4 -128 // FFFFFF80
  1725. #define KERB_ETYPE_RC4_PLAIN2 -129
  1726. #define KERB_ETYPE_RC4_LM -130
  1727. #define KERB_ETYPE_RC4_SHA -131
  1728. #define KERB_ETYPE_DES_PLAIN -132
  1729. #define KERB_ETYPE_RC4_HMAC_OLD -133 // FFFFFF7B
  1730. #define KERB_ETYPE_RC4_PLAIN_OLD -134
  1731. #define KERB_ETYPE_RC4_HMAC_OLD_EXP -135
  1732. #define KERB_ETYPE_RC4_PLAIN_OLD_EXP -136
  1733. #define KERB_ETYPE_RC4_PLAIN -140
  1734. #define KERB_ETYPE_RC4_PLAIN_EXP -141
  1735. //
  1736. // Pkinit encryption types
  1737. //
  1738. #define KERB_ETYPE_DSA_SHA1_CMS 9
  1739. #define KERB_ETYPE_RSA_MD5_CMS 10
  1740. #define KERB_ETYPE_RSA_SHA1_CMS 11
  1741. #define KERB_ETYPE_RC2_CBC_ENV 12
  1742. #define KERB_ETYPE_RSA_ENV 13
  1743. #define KERB_ETYPE_RSA_ES_OEAP_ENV 14
  1744. #define KERB_ETYPE_DES_EDE3_CBC_ENV 15
  1745. //
  1746. // Deprecated
  1747. //
  1748. #define KERB_ETYPE_DSA_SIGN 8
  1749. #define KERB_ETYPE_RSA_PRIV 9
  1750. #define KERB_ETYPE_RSA_PUB 10
  1751. #define KERB_ETYPE_RSA_PUB_MD5 11
  1752. #define KERB_ETYPE_RSA_PUB_SHA1 12
  1753. #define KERB_ETYPE_PKCS7_PUB 13
  1754. //
  1755. // In use types
  1756. //
  1757. #define KERB_ETYPE_DES_CBC_MD5_NT 20
  1758. #define KERB_ETYPE_RC4_HMAC_NT 23
  1759. #define KERB_ETYPE_RC4_HMAC_NT_EXP 24
  1760. // Checksum algorithms.
  1761. // These algorithms are keyed internally for our use.
  1762. #define KERB_CHECKSUM_NONE 0
  1763. #define KERB_CHECKSUM_CRC32 1
  1764. #define KERB_CHECKSUM_MD4 2
  1765. #define KERB_CHECKSUM_KRB_DES_MAC 4
  1766. #define KERB_CHECKSUM_KRB_DES_MAC_K 5
  1767. #define KERB_CHECKSUM_MD5 7
  1768. #define KERB_CHECKSUM_MD5_DES 8
  1769. #define KERB_CHECKSUM_LM -130
  1770. #define KERB_CHECKSUM_SHA1 -131
  1771. #define KERB_CHECKSUM_REAL_CRC32 -132
  1772. #define KERB_CHECKSUM_DES_MAC -133
  1773. #define KERB_CHECKSUM_DES_MAC_MD5 -134
  1774. #define KERB_CHECKSUM_MD25 -135
  1775. #define KERB_CHECKSUM_RC4_MD5 -136
  1776. #define KERB_CHECKSUM_MD5_HMAC -137 // used by netlogon
  1777. #define KERB_CHECKSUM_HMAC_MD5 -138 // used by Kerberos
  1778. #define AUTH_REQ_ALLOW_FORWARDABLE 0x00000001
  1779. #define AUTH_REQ_ALLOW_PROXIABLE 0x00000002
  1780. #define AUTH_REQ_ALLOW_POSTDATE 0x00000004
  1781. #define AUTH_REQ_ALLOW_RENEWABLE 0x00000008
  1782. #define AUTH_REQ_ALLOW_NOADDRESS 0x00000010
  1783. #define AUTH_REQ_ALLOW_ENC_TKT_IN_SKEY 0x00000020
  1784. #define AUTH_REQ_ALLOW_VALIDATE 0x00000040
  1785. #define AUTH_REQ_VALIDATE_CLIENT 0x00000080
  1786. #define AUTH_REQ_OK_AS_DELEGATE 0x00000100
  1787. #define AUTH_REQ_PREAUTH_REQUIRED 0x00000200
  1788. #define AUTH_REQ_TRANSITIVE_TRUST 0x00000400
  1789. #define AUTH_REQ_PER_USER_FLAGS (AUTH_REQ_ALLOW_FORWARDABLE | \
  1790. AUTH_REQ_ALLOW_PROXIABLE | \
  1791. AUTH_REQ_ALLOW_POSTDATE | \
  1792. AUTH_REQ_ALLOW_RENEWABLE | \
  1793. AUTH_REQ_ALLOW_VALIDATE )
  1794. //
  1795. // Ticket Flags:
  1796. //
  1797. #define KERB_TICKET_FLAGS_reserved 0x80000000
  1798. #define KERB_TICKET_FLAGS_forwardable 0x40000000
  1799. #define KERB_TICKET_FLAGS_forwarded 0x20000000
  1800. #define KERB_TICKET_FLAGS_proxiable 0x10000000
  1801. #define KERB_TICKET_FLAGS_proxy 0x08000000
  1802. #define KERB_TICKET_FLAGS_may_postdate 0x04000000
  1803. #define KERB_TICKET_FLAGS_postdated 0x02000000
  1804. #define KERB_TICKET_FLAGS_invalid 0x01000000
  1805. #define KERB_TICKET_FLAGS_renewable 0x00800000
  1806. #define KERB_TICKET_FLAGS_initial 0x00400000
  1807. #define KERB_TICKET_FLAGS_pre_authent 0x00200000
  1808. #define KERB_TICKET_FLAGS_hw_authent 0x00100000
  1809. #define KERB_TICKET_FLAGS_ok_as_delegate 0x00040000
  1810. #define KERB_TICKET_FLAGS_name_canonicalize 0x00010000
  1811. #define KERB_TICKET_FLAGS_cname_in_pa_data 0x00040000
  1812. #define KERB_TICKET_FLAGS_reserved1 0x00000001
  1813. //
  1814. // Name types
  1815. //
  1816. #define KRB_NT_UNKNOWN 0 // Name type not known
  1817. #define KRB_NT_PRINCIPAL 1 // Just the name of the principal as in DCE, or for users
  1818. #define KRB_NT_PRINCIPAL_AND_ID -131 // Name of the principal and its SID.
  1819. #define KRB_NT_SRV_INST 2 // Service and other unique instance (krbtgt)
  1820. #define KRB_NT_SRV_INST_AND_ID -132 // SPN and SID
  1821. #define KRB_NT_SRV_HST 3 // Service with host name as instance (telnet, rcommands)
  1822. #define KRB_NT_SRV_XHST 4 // Service with host as remaining components
  1823. #define KRB_NT_UID 5 // Unique ID
  1824. #define KRB_NT_ENTERPRISE_PRINCIPAL 10 // UPN or SPN
  1825. #define KRB_NT_ENT_PRINCIPAL_AND_ID -130 // UPN and SID
  1826. //
  1827. // MS extensions, negative according to the RFC
  1828. //
  1829. #define KRB_NT_MS_PRINCIPAL -128 // NT4 style name
  1830. #define KRB_NT_MS_PRINCIPAL_AND_ID -129 // nt4 style name with sid
  1831. #define KERB_IS_MS_PRINCIPAL(_x_) (((_x_) <= KRB_NT_MS_PRINCIPAL) || ((_x_) >= KRB_NT_ENTERPRISE_PRINCIPAL))
  1832. #ifndef MICROSOFT_KERBEROS_NAME_A
  1833. #define MICROSOFT_KERBEROS_NAME_A "Kerberos"
  1834. #define MICROSOFT_KERBEROS_NAME_W L"Kerberos"
  1835. #ifdef WIN32_CHICAGO
  1836. #define MICROSOFT_KERBEROS_NAME MICROSOFT_KERBEROS_NAME_A
  1837. #else
  1838. #define MICROSOFT_KERBEROS_NAME MICROSOFT_KERBEROS_NAME_W
  1839. #endif // WIN32_CHICAGO
  1840. #endif // MICROSOFT_KERBEROS_NAME_A
  1841. /////////////////////////////////////////////////////////////////////////
  1842. //
  1843. // Quality of protection parameters for MakeSignature / EncryptMessage
  1844. //
  1845. /////////////////////////////////////////////////////////////////////////
  1846. //
  1847. // This flag indicates to EncryptMessage that the message is not to actually
  1848. // be encrypted, but a header/trailer are to be produced.
  1849. //
  1850. #define KERB_WRAP_NO_ENCRYPT 0x80000001
  1851. /////////////////////////////////////////////////////////////////////////
  1852. //
  1853. // LsaLogonUser parameters
  1854. //
  1855. /////////////////////////////////////////////////////////////////////////
  1856. typedef enum _KERB_LOGON_SUBMIT_TYPE {
  1857. KerbInteractiveLogon = 2,
  1858. KerbSmartCardLogon = 6,
  1859. KerbWorkstationUnlockLogon = 7,
  1860. KerbSmartCardUnlockLogon = 8,
  1861. KerbProxyLogon = 9,
  1862. KerbTicketLogon = 10,
  1863. KerbTicketUnlockLogon = 11,
  1864. KerbS4ULogon = 12
  1865. } KERB_LOGON_SUBMIT_TYPE, *PKERB_LOGON_SUBMIT_TYPE;
  1866. typedef struct _KERB_INTERACTIVE_LOGON {
  1867. KERB_LOGON_SUBMIT_TYPE MessageType;
  1868. UNICODE_STRING LogonDomainName;
  1869. UNICODE_STRING UserName;
  1870. UNICODE_STRING Password;
  1871. } KERB_INTERACTIVE_LOGON, *PKERB_INTERACTIVE_LOGON;
  1872. typedef struct _KERB_INTERACTIVE_UNLOCK_LOGON {
  1873. KERB_INTERACTIVE_LOGON Logon;
  1874. LUID LogonId;
  1875. } KERB_INTERACTIVE_UNLOCK_LOGON, *PKERB_INTERACTIVE_UNLOCK_LOGON;
  1876. typedef struct _KERB_SMART_CARD_LOGON {
  1877. KERB_LOGON_SUBMIT_TYPE MessageType;
  1878. UNICODE_STRING Pin;
  1879. ULONG CspDataLength;
  1880. PUCHAR CspData;
  1881. } KERB_SMART_CARD_LOGON, *PKERB_SMART_CARD_LOGON;
  1882. typedef struct _KERB_SMART_CARD_UNLOCK_LOGON {
  1883. KERB_SMART_CARD_LOGON Logon;
  1884. LUID LogonId;
  1885. } KERB_SMART_CARD_UNLOCK_LOGON, *PKERB_SMART_CARD_UNLOCK_LOGON;
  1886. //
  1887. // Structure used for a ticket-only logon
  1888. //
  1889. typedef struct _KERB_TICKET_LOGON {
  1890. KERB_LOGON_SUBMIT_TYPE MessageType;
  1891. ULONG Flags;
  1892. ULONG ServiceTicketLength;
  1893. ULONG TicketGrantingTicketLength;
  1894. PUCHAR ServiceTicket; // REQUIRED: Service ticket "host"
  1895. PUCHAR TicketGrantingTicket; // OPTIONAL: User's encdoded in a KERB_CRED message, encrypted with session key from service ticket
  1896. } KERB_TICKET_LOGON, *PKERB_TICKET_LOGON;
  1897. //
  1898. // Flags for the ticket logon flags field
  1899. //
  1900. #define KERB_LOGON_FLAG_ALLOW_EXPIRED_TICKET 0x1
  1901. typedef struct _KERB_TICKET_UNLOCK_LOGON {
  1902. KERB_TICKET_LOGON Logon;
  1903. LUID LogonId;
  1904. } KERB_TICKET_UNLOCK_LOGON, *PKERB_TICKET_UNLOCK_LOGON;
  1905. //
  1906. // Used for S4U Client requests
  1907. //
  1908. //
  1909. typedef struct _KERB_S4U_LOGON {
  1910. KERB_LOGON_SUBMIT_TYPE MessageType;
  1911. ULONG Flags;
  1912. UNICODE_STRING ClientUpn; // REQUIRED: UPN for client
  1913. UNICODE_STRING ClientRealm; // Optional: Client Realm, if known
  1914. } KERB_S4U_LOGON, *PKERB_S4U_LOGON;
  1915. //
  1916. // TBD: Flags for S4UToSelf() logon
  1917. //
  1918. //
  1919. // Use the same profile structure as MSV1_0
  1920. //
  1921. typedef enum _KERB_PROFILE_BUFFER_TYPE {
  1922. KerbInteractiveProfile = 2,
  1923. KerbSmartCardProfile = 4,
  1924. KerbTicketProfile = 6
  1925. } KERB_PROFILE_BUFFER_TYPE, *PKERB_PROFILE_BUFFER_TYPE;
  1926. typedef struct _KERB_INTERACTIVE_PROFILE {
  1927. KERB_PROFILE_BUFFER_TYPE MessageType;
  1928. USHORT LogonCount;
  1929. USHORT BadPasswordCount;
  1930. LARGE_INTEGER LogonTime;
  1931. LARGE_INTEGER LogoffTime;
  1932. LARGE_INTEGER KickOffTime;
  1933. LARGE_INTEGER PasswordLastSet;
  1934. LARGE_INTEGER PasswordCanChange;
  1935. LARGE_INTEGER PasswordMustChange;
  1936. UNICODE_STRING LogonScript;
  1937. UNICODE_STRING HomeDirectory;
  1938. UNICODE_STRING FullName;
  1939. UNICODE_STRING ProfilePath;
  1940. UNICODE_STRING HomeDirectoryDrive;
  1941. UNICODE_STRING LogonServer;
  1942. ULONG UserFlags;
  1943. } KERB_INTERACTIVE_PROFILE, *PKERB_INTERACTIVE_PROFILE;
  1944. //
  1945. // For smart card, we return a smart card profile, which is an interactive
  1946. // profile plus a certificate
  1947. //
  1948. typedef struct _KERB_SMART_CARD_PROFILE {
  1949. KERB_INTERACTIVE_PROFILE Profile;
  1950. ULONG CertificateSize;
  1951. PUCHAR CertificateData;
  1952. } KERB_SMART_CARD_PROFILE, *PKERB_SMART_CARD_PROFILE;
  1953. //
  1954. // For a ticket logon profile, we return the session key from the ticket
  1955. //
  1956. typedef struct KERB_CRYPTO_KEY {
  1957. LONG KeyType;
  1958. ULONG Length;
  1959. PUCHAR Value;
  1960. } KERB_CRYPTO_KEY, *PKERB_CRYPTO_KEY;
  1961. typedef struct _KERB_TICKET_PROFILE {
  1962. KERB_INTERACTIVE_PROFILE Profile;
  1963. KERB_CRYPTO_KEY SessionKey;
  1964. } KERB_TICKET_PROFILE, *PKERB_TICKET_PROFILE;
  1965. typedef enum _KERB_PROTOCOL_MESSAGE_TYPE {
  1966. KerbDebugRequestMessage = 0,
  1967. KerbQueryTicketCacheMessage,
  1968. KerbChangeMachinePasswordMessage,
  1969. KerbVerifyPacMessage,
  1970. KerbRetrieveTicketMessage,
  1971. KerbUpdateAddressesMessage,
  1972. KerbPurgeTicketCacheMessage,
  1973. KerbChangePasswordMessage,
  1974. KerbRetrieveEncodedTicketMessage,
  1975. KerbDecryptDataMessage,
  1976. KerbAddBindingCacheEntryMessage,
  1977. KerbSetPasswordMessage,
  1978. KerbSetPasswordExMessage,
  1979. KerbVerifyCredentialsMessage,
  1980. KerbQueryTicketCacheExMessage,
  1981. KerbPurgeTicketCacheExMessage,
  1982. // KerbRetrieveEncodedTicketExMessage,
  1983. } KERB_PROTOCOL_MESSAGE_TYPE, *PKERB_PROTOCOL_MESSAGE_TYPE;
  1984. //
  1985. // Used both for retrieving tickets and for querying ticket cache
  1986. //
  1987. typedef struct _KERB_QUERY_TKT_CACHE_REQUEST {
  1988. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  1989. LUID LogonId;
  1990. } KERB_QUERY_TKT_CACHE_REQUEST, *PKERB_QUERY_TKT_CACHE_REQUEST;
  1991. typedef struct _KERB_TICKET_CACHE_INFO {
  1992. UNICODE_STRING ServerName;
  1993. UNICODE_STRING RealmName;
  1994. LARGE_INTEGER StartTime;
  1995. LARGE_INTEGER EndTime;
  1996. LARGE_INTEGER RenewTime;
  1997. LONG EncryptionType;
  1998. ULONG TicketFlags;
  1999. } KERB_TICKET_CACHE_INFO, *PKERB_TICKET_CACHE_INFO;
  2000. typedef struct _KERB_TICKET_CACHE_INFO_EX {
  2001. UNICODE_STRING ClientName;
  2002. UNICODE_STRING ClientRealm;
  2003. UNICODE_STRING ServerName;
  2004. UNICODE_STRING ServerRealm;
  2005. LARGE_INTEGER StartTime;
  2006. LARGE_INTEGER EndTime;
  2007. LARGE_INTEGER RenewTime;
  2008. LONG EncryptionType;
  2009. ULONG TicketFlags;
  2010. } KERB_TICKET_CACHE_INFO_EX, *PKERB_TICKET_CACHE_INFO_EX;
  2011. typedef struct _KERB_QUERY_TKT_CACHE_RESPONSE {
  2012. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2013. ULONG CountOfTickets;
  2014. KERB_TICKET_CACHE_INFO Tickets[ANYSIZE_ARRAY];
  2015. } KERB_QUERY_TKT_CACHE_RESPONSE, *PKERB_QUERY_TKT_CACHE_RESPONSE;
  2016. typedef struct _KERB_QUERY_TKT_CACHE_EX_RESPONSE {
  2017. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2018. ULONG CountOfTickets;
  2019. KERB_TICKET_CACHE_INFO_EX Tickets[ANYSIZE_ARRAY];
  2020. } KERB_QUERY_TKT_CACHE_EX_RESPONSE, *PKERB_QUERY_TKT_CACHE_EX_RESPONSE;
  2021. //
  2022. // Types for retrieving encoded ticket from the cache
  2023. //
  2024. #ifndef __SECHANDLE_DEFINED__
  2025. typedef struct _SecHandle
  2026. {
  2027. ULONG_PTR dwLower ;
  2028. ULONG_PTR dwUpper ;
  2029. } SecHandle, * PSecHandle ;
  2030. #define __SECHANDLE_DEFINED__
  2031. #endif // __SECHANDLE_DEFINED__
  2032. // Ticket Flags
  2033. #define KERB_USE_DEFAULT_TICKET_FLAGS 0x0
  2034. // CacheOptions
  2035. #define KERB_RETRIEVE_TICKET_DEFAULT 0x0
  2036. #define KERB_RETRIEVE_TICKET_DONT_USE_CACHE 0x1
  2037. #define KERB_RETRIEVE_TICKET_USE_CACHE_ONLY 0x2
  2038. #define KERB_RETRIEVE_TICKET_USE_CREDHANDLE 0x4
  2039. #define KERB_RETRIEVE_TICKET_AS_KERB_CRED 0x8
  2040. #define KERB_RETRIEVE_TICKET_WITH_SEC_CRED 0x10
  2041. // Encryption Type options
  2042. #define KERB_ETYPE_DEFAULT 0x0 // don't specify etype in tkt req.
  2043. typedef struct _KERB_AUTH_DATA {
  2044. ULONG Type;
  2045. ULONG Length;
  2046. PUCHAR Data;
  2047. } KERB_AUTH_DATA, *PKERB_AUTH_DATA;
  2048. typedef struct _KERB_NET_ADDRESS {
  2049. ULONG Family;
  2050. ULONG Length;
  2051. PCHAR Address;
  2052. } KERB_NET_ADDRESS, *PKERB_NET_ADDRESS;
  2053. typedef struct _KERB_NET_ADDRESSES {
  2054. ULONG Number;
  2055. KERB_NET_ADDRESS Addresses[ANYSIZE_ARRAY];
  2056. } KERB_NET_ADDRESSES, *PKERB_NET_ADDRESSES;
  2057. //
  2058. // Types for the information about a ticket
  2059. //
  2060. typedef struct _KERB_EXTERNAL_NAME {
  2061. SHORT NameType;
  2062. USHORT NameCount;
  2063. UNICODE_STRING Names[ANYSIZE_ARRAY];
  2064. } KERB_EXTERNAL_NAME, *PKERB_EXTERNAL_NAME;
  2065. typedef struct _KERB_EXTERNAL_TICKET {
  2066. PKERB_EXTERNAL_NAME ServiceName;
  2067. PKERB_EXTERNAL_NAME TargetName;
  2068. PKERB_EXTERNAL_NAME ClientName;
  2069. UNICODE_STRING DomainName;
  2070. UNICODE_STRING TargetDomainName;
  2071. UNICODE_STRING AltTargetDomainName;
  2072. KERB_CRYPTO_KEY SessionKey;
  2073. ULONG TicketFlags;
  2074. ULONG Flags;
  2075. LARGE_INTEGER KeyExpirationTime;
  2076. LARGE_INTEGER StartTime;
  2077. LARGE_INTEGER EndTime;
  2078. LARGE_INTEGER RenewUntil;
  2079. LARGE_INTEGER TimeSkew;
  2080. ULONG EncodedTicketSize;
  2081. PUCHAR EncodedTicket;
  2082. } KERB_EXTERNAL_TICKET, *PKERB_EXTERNAL_TICKET;
  2083. #if 0
  2084. typedef struct _KERB_EXTERNAL_TICKET_EX {
  2085. PKERB_EXTERNAL_NAME ClientName;
  2086. PKERB_EXTERNAL_NAME ServiceName;
  2087. PKERB_EXTERNAL_NAME TargetName;
  2088. UNICODE_STRING ClientRealm;
  2089. UNICODE_STRING ServerRealm;
  2090. UNICODE_STRING TargetDomainName;
  2091. UNICODE_STRING AltTargetDomainName;
  2092. KERB_CRYPTO_KEY SessionKey;
  2093. ULONG TicketFlags;
  2094. ULONG Flags;
  2095. LARGE_INTEGER KeyExpirationTime;
  2096. LARGE_INTEGER StartTime;
  2097. LARGE_INTEGER EndTime;
  2098. LARGE_INTEGER RenewUntil;
  2099. LARGE_INTEGER TimeSkew;
  2100. PKERB_NET_ADDRESSES TicketAddresses;
  2101. PKERB_AUTH_DATA AuthorizationData;
  2102. _KERB_EXTERNAL_TICKET_EX * SecondTicket;
  2103. ULONG EncodedTicketSize;
  2104. PUCHAR EncodedTicket;
  2105. } KERB_EXTERNAL_TICKET_EX, *PKERB_EXTERNAL_TICKET_EX;
  2106. #endif // 0
  2107. typedef struct _KERB_RETRIEVE_TKT_REQUEST {
  2108. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2109. LUID LogonId;
  2110. UNICODE_STRING TargetName;
  2111. ULONG TicketFlags;
  2112. ULONG CacheOptions;
  2113. LONG EncryptionType;
  2114. SecHandle CredentialsHandle;
  2115. } KERB_RETRIEVE_TKT_REQUEST, *PKERB_RETRIEVE_TKT_REQUEST;
  2116. #if 0
  2117. typedef struct _KERB_RETRIEVE_TKT_EX_REQUEST {
  2118. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2119. LUID LogonId;
  2120. KERB_TICKET_CACHE_INFO_EX TicketTemplate;
  2121. ULONG CacheOptions;
  2122. SecHandle CredentialsHandle;
  2123. PKERB_EXTERNAL_TICKET_EX SecondTicket;
  2124. PKERB_AUTH_DATA UserAuthData;
  2125. PKERB_NET_ADDRESS Addresses;
  2126. } KERB_RETRIEVE_TKT_EX_REQUEST, *PKERB_RETRIEVE_TKT_EX_REQUEST;
  2127. #endif // 0
  2128. typedef struct _KERB_RETRIEVE_TKT_RESPONSE {
  2129. KERB_EXTERNAL_TICKET Ticket;
  2130. } KERB_RETRIEVE_TKT_RESPONSE, *PKERB_RETRIEVE_TKT_RESPONSE;
  2131. #if 0
  2132. typedef struct _KERB_RETRIEVE_TKT_EX_RESPONSE {
  2133. KERB_EXTERNAL_TICKET_EX Ticket;
  2134. } KERB_RETRIEVE_TKT_EX_RESPONSE, *PKERB_RETRIEVE_TKT_EX_RESPONSE;
  2135. #endif // 0
  2136. //
  2137. // Used to purge entries from the ticket cache
  2138. //
  2139. typedef struct _KERB_PURGE_TKT_CACHE_REQUEST {
  2140. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2141. LUID LogonId;
  2142. UNICODE_STRING ServerName;
  2143. UNICODE_STRING RealmName;
  2144. } KERB_PURGE_TKT_CACHE_REQUEST, *PKERB_PURGE_TKT_CACHE_REQUEST;
  2145. //
  2146. // Flags for purge requests
  2147. //
  2148. #define KERB_PURGE_ALL_TICKETS 1
  2149. typedef struct _KERB_PURGE_TKT_CACHE_EX_REQUEST {
  2150. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2151. LUID LogonId;
  2152. ULONG Flags;
  2153. KERB_TICKET_CACHE_INFO_EX TicketTemplate;
  2154. } KERB_PURGE_TKT_CACHE_EX_REQUEST, *PKERB_PURGE_TKT_CACHE_EX_REQUEST;
  2155. //
  2156. // KerbChangePassword
  2157. //
  2158. // KerbChangePassword changes the password on the KDC account plus
  2159. // the password cache and logon credentials if applicable.
  2160. //
  2161. //
  2162. typedef struct _KERB_CHANGEPASSWORD_REQUEST {
  2163. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2164. UNICODE_STRING DomainName;
  2165. UNICODE_STRING AccountName;
  2166. UNICODE_STRING OldPassword;
  2167. UNICODE_STRING NewPassword;
  2168. BOOLEAN Impersonating;
  2169. } KERB_CHANGEPASSWORD_REQUEST, *PKERB_CHANGEPASSWORD_REQUEST;
  2170. //
  2171. // KerbSetPassword
  2172. //
  2173. // KerbSetPassword changes the password on the KDC account plus
  2174. // the password cache and logon credentials if applicable.
  2175. //
  2176. //
  2177. typedef struct _KERB_SETPASSWORD_REQUEST {
  2178. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2179. LUID LogonId;
  2180. SecHandle CredentialsHandle;
  2181. ULONG Flags;
  2182. UNICODE_STRING DomainName;
  2183. UNICODE_STRING AccountName;
  2184. UNICODE_STRING Password;
  2185. } KERB_SETPASSWORD_REQUEST, *PKERB_SETPASSWORD_REQUEST;
  2186. typedef struct _KERB_SETPASSWORD_EX_REQUEST {
  2187. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2188. LUID LogonId;
  2189. SecHandle CredentialsHandle;
  2190. ULONG Flags;
  2191. UNICODE_STRING AccountRealm;
  2192. UNICODE_STRING AccountName;
  2193. UNICODE_STRING Password;
  2194. UNICODE_STRING ClientRealm;
  2195. UNICODE_STRING ClientName;
  2196. BOOLEAN Impersonating;
  2197. UNICODE_STRING KdcAddress;
  2198. ULONG KdcAddressType;
  2199. } KERB_SETPASSWORD_EX_REQUEST, *PKERB_SETPASSWORD_EX_REQUEST;
  2200. #define DS_UNKNOWN_ADDRESS_TYPE 0 // anything *but* IP
  2201. #define KERB_SETPASS_USE_LOGONID 1
  2202. #define KERB_SETPASS_USE_CREDHANDLE 2
  2203. typedef struct _KERB_DECRYPT_REQUEST {
  2204. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2205. LUID LogonId;
  2206. ULONG Flags;
  2207. LONG CryptoType;
  2208. LONG KeyUsage;
  2209. KERB_CRYPTO_KEY Key; // optional
  2210. ULONG EncryptedDataSize;
  2211. ULONG InitialVectorSize;
  2212. PUCHAR InitialVector;
  2213. PUCHAR EncryptedData;
  2214. } KERB_DECRYPT_REQUEST, *PKERB_DECRYPT_REQUEST;
  2215. //
  2216. // If set, use the primary key from the current logon session of the one provided in the LogonId field.
  2217. // Otherwise, use the Key in the KERB_DECRYPT_MESSAGE.
  2218. #define KERB_DECRYPT_FLAG_DEFAULT_KEY 0x00000001
  2219. typedef struct _KERB_DECRYPT_RESPONSE {
  2220. UCHAR DecryptedData[ANYSIZE_ARRAY];
  2221. } KERB_DECRYPT_RESPONSE, *PKERB_DECRYPT_RESPONSE;
  2222. //
  2223. // Request structure for adding a binding cache entry. TCB privilege
  2224. // is required for this operation.
  2225. //
  2226. typedef struct _KERB_ADD_BINDING_CACHE_ENTRY_REQUEST {
  2227. KERB_PROTOCOL_MESSAGE_TYPE MessageType;
  2228. UNICODE_STRING RealmName;
  2229. UNICODE_STRING KdcAddress;
  2230. ULONG AddressType; //dsgetdc.h DS_NETBIOS_ADDRESS||DS_INET_ADDRESS
  2231. } KERB_ADD_BINDING_CACHE_ENTRY_REQUEST, *PKERB_ADD_BINDING_CACHE_ENTRY_REQUEST;
  2232. #ifdef __cplusplus
  2233. }
  2234. #endif
  2235. #endif /* _NTSECAPI_ */