Leaked source code of windows server 2003
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.

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