home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / C_C++ / BorlandCompiler / freecommandLinetools.exe / Include / ntsecapi.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-27  |  73.2 KB  |  2,451 lines

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