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.

3141 lines
98 KiB

  1. /*++ BUILD Version: 0011 // Increment this if a change has global effects
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. ntlsa.h
  5. Abstract:
  6. This module contains the public data structures and API definitions
  7. needed to utilize Local Security Authority (LSA) services.
  8. Author:
  9. Jim Kelly (JimK) 21-February-1991
  10. Revision History:
  11. --*/
  12. #ifndef _NTLSA_
  13. #define _NTLSA_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. //
  21. // Generic negative values for unknown IDs, inapplicable indices etc.
  22. //
  23. #define LSA_UNKNOWN_ID ((ULONG) 0xFFFFFFFFL)
  24. #define LSA_UNKNOWN_INDEX ((LONG) -1)
  25. // begin_ntsecapi
  26. #ifndef _NTLSA_IFS_
  27. // begin_ntifs
  28. //
  29. // Security operation mode of the system is held in a control
  30. // longword.
  31. //
  32. typedef ULONG LSA_OPERATIONAL_MODE, *PLSA_OPERATIONAL_MODE;
  33. // end_ntifs
  34. #endif // _NTLSA_IFS_
  35. //
  36. // The flags in the security operational mode are defined
  37. // as:
  38. //
  39. // PasswordProtected - Some level of authentication (such as
  40. // a password) must be provided by users before they are
  41. // allowed to use the system. Once set, this value will
  42. // not be cleared without re-booting the system.
  43. //
  44. // IndividualAccounts - Each user must identify an account to
  45. // logon to. This flag is only meaningful if the
  46. // PasswordProtected flag is also set. If this flag is
  47. // not set and the PasswordProtected flag is set, then all
  48. // users may logon to the same account. Once set, this value
  49. // will not be cleared without re-booting the system.
  50. //
  51. // MandatoryAccess - Indicates the system is running in a mandatory
  52. // access control mode (e.g., B-level as defined by the U.S.A's
  53. // Department of Defense's "Orange Book"). This is not utilized
  54. // in the current release of NT. This flag is only meaningful
  55. // if both the PasswordProtected and IndividualAccounts flags are
  56. // set. Once set, this value will not be cleared without
  57. // re-booting the system.
  58. //
  59. // LogFull - Indicates the system has been brought up in a mode in
  60. // which if must perform security auditing, but its audit log
  61. // is full. This may (should) restrict the operations that
  62. // can occur until the audit log is made not-full again. THIS
  63. // VALUE MAY BE CLEARED WHILE THE SYSTEM IS RUNNING (I.E., WITHOUT
  64. // REBOOTING).
  65. //
  66. // If the PasswordProtected flag is not set, then the system is running
  67. // without security, and user interface should be adjusted appropriately.
  68. //
  69. #define LSA_MODE_PASSWORD_PROTECTED (0x00000001L)
  70. #define LSA_MODE_INDIVIDUAL_ACCOUNTS (0x00000002L)
  71. #define LSA_MODE_MANDATORY_ACCESS (0x00000004L)
  72. #define LSA_MODE_LOG_FULL (0x00000008L)
  73. // end_ntsecapi
  74. /////////////////////////////////////////////////////////////////////////
  75. // //
  76. // Widely used LSA defines //
  77. // //
  78. /////////////////////////////////////////////////////////////////////////
  79. //
  80. // Defines for Count Limits on LSA API
  81. //
  82. #define LSA_MAXIMUM_SID_COUNT (0x00000100L)
  83. #define LSA_MAXIMUM_ENUMERATION_LENGTH (32000)
  84. //
  85. // Flag OR'ed into AuthenticationPackage parameter of LsaLogonUser to
  86. // request that the license server be called upon successful logon.
  87. //
  88. #define LSA_CALL_LICENSE_SERVER 0x80000000
  89. /////////////////////////////////////////////////////////////////////////
  90. // //
  91. // Data types used by logon processes //
  92. // //
  93. /////////////////////////////////////////////////////////////////////////
  94. // begin_ntsecapi
  95. #ifndef _NTLSA_IFS_
  96. // begin_ntifs
  97. //
  98. // Used by a logon process to indicate what type of logon is being
  99. // requested.
  100. //
  101. typedef enum _SECURITY_LOGON_TYPE {
  102. Interactive = 2, // Interactively logged on (locally or remotely)
  103. Network, // Accessing system via network
  104. Batch, // Started via a batch queue
  105. Service, // Service started by service controller
  106. Proxy, // Proxy logon
  107. Unlock, // Unlock workstation
  108. NetworkCleartext, // Network logon with cleartext credentials
  109. NewCredentials, // Clone caller, new default credentials
  110. RemoteInteractive, // Remote, yet interactive. Terminal server
  111. CachedInteractive, // Try cached credentials without hitting the net.
  112. CachedRemoteInteractive, // Same as RemoteInteractive, this is used internally for auditing purpose
  113. CachedUnlock // Cached Unlock workstation
  114. } SECURITY_LOGON_TYPE, *PSECURITY_LOGON_TYPE;
  115. // end_ntifs
  116. #endif // _NTLSA_IFS_
  117. // end_ntsecapi
  118. //
  119. // Security System Access Flags. These correspond to the enumerated
  120. // type values in SECURITY_LOGON_TYPE.
  121. //
  122. // IF YOU ADD A NEW LOGON TYPE HERE, ALSO ADD IT TO THE POLICY_MODE_xxx
  123. // data definitions.
  124. //
  125. #define SECURITY_ACCESS_INTERACTIVE_LOGON ((ULONG) 0x00000001L)
  126. #define SECURITY_ACCESS_NETWORK_LOGON ((ULONG) 0x00000002L)
  127. #define SECURITY_ACCESS_BATCH_LOGON ((ULONG) 0x00000004L)
  128. #define SECURITY_ACCESS_SERVICE_LOGON ((ULONG) 0x00000010L)
  129. #define SECURITY_ACCESS_PROXY_LOGON ((ULONG) 0x00000020L)
  130. #define SECURITY_ACCESS_DENY_INTERACTIVE_LOGON ((ULONG) 0x00000040L)
  131. #define SECURITY_ACCESS_DENY_NETWORK_LOGON ((ULONG) 0x00000080L)
  132. #define SECURITY_ACCESS_DENY_BATCH_LOGON ((ULONG) 0x00000100L)
  133. #define SECURITY_ACCESS_DENY_SERVICE_LOGON ((ULONG) 0x00000200L)
  134. #define SECURITY_ACCESS_REMOTE_INTERACTIVE_LOGON ((ULONG) 0x00000400L)
  135. #define SECURITY_ACCESS_DENY_REMOTE_INTERACTIVE_LOGON ((ULONG) 0x00000800L)
  136. /////////////////////////////////////////////////////////////////////////
  137. // //
  138. // Data types related to Auditing //
  139. // //
  140. /////////////////////////////////////////////////////////////////////////
  141. //
  142. // The following enumerated type is used between the reference monitor and
  143. // LSA in the generation of audit messages. It is used to indicate the
  144. // type of data being passed as a parameter from the reference monitor
  145. // to LSA. LSA is responsible for transforming the specified data type
  146. // into a set of unicode strings that are added to the event record in
  147. // the audit log.
  148. //
  149. typedef enum _SE_ADT_PARAMETER_TYPE {
  150. SeAdtParmTypeNone = 0, //Produces 1 parameter
  151. //Received value:
  152. //
  153. // None.
  154. //
  155. //Results in:
  156. //
  157. // a unicode string containing "-".
  158. //
  159. //Note: This is typically used to
  160. // indicate that a parameter value
  161. // was not available.
  162. //
  163. SeAdtParmTypeString, //Produces 1 parameter.
  164. //Received Value:
  165. //
  166. // Unicode String (variable length)
  167. //
  168. //Results in:
  169. //
  170. // No transformation. The string
  171. // entered into the event record as
  172. // received.
  173. //
  174. // The Address value of the audit info
  175. // should be a pointer to a UNICODE_STRING
  176. // structure.
  177. SeAdtParmTypeFileSpec, //Produces 1 parameter.
  178. //Received value:
  179. //
  180. // Unicode string containing a file or
  181. // directory name.
  182. //
  183. //Results in:
  184. //
  185. // Unicode string with the prefix of the
  186. // file's path replaced by a drive letter
  187. // if possible.
  188. //
  189. SeAdtParmTypeUlong, //Produces 1 parameter
  190. //Received value:
  191. //
  192. // Ulong
  193. //
  194. //Results in:
  195. //
  196. // Unicode string representation of
  197. // unsigned integer value.
  198. SeAdtParmTypeSid, //Produces 1 parameter.
  199. //Received value:
  200. //
  201. // SID (variable length)
  202. //
  203. //Results in:
  204. //
  205. // String representation of SID
  206. //
  207. SeAdtParmTypeLogonId, //Produces 3 parameters.
  208. //Received Value:
  209. //
  210. // LUID (fixed length)
  211. //
  212. //Results in:
  213. //
  214. // param 1: Username string
  215. // param 2: domain name string
  216. // param 3: Logon ID (Luid) string
  217. SeAdtParmTypeNoLogonId, //Produces 3 parameters.
  218. //Received value:
  219. //
  220. // None.
  221. //
  222. //Results in:
  223. //
  224. // param 1: "-"
  225. // param 2: "-"
  226. // param 3: "-"
  227. //
  228. //Note:
  229. //
  230. // This type is used when a logon ID
  231. // is needed, but one is not available
  232. // to pass. For example, if an
  233. // impersonation logon ID is expected
  234. // but the subject is not impersonating
  235. // anyone.
  236. //
  237. SeAdtParmTypeAccessMask, //Produces 1 parameter with formatting.
  238. //Received value:
  239. //
  240. // ACCESS_MASK followed by
  241. // a Unicode string. The unicode
  242. // string contains the name of the
  243. // type of object the access mask
  244. // applies to. The event's source
  245. // further qualifies the object type.
  246. //
  247. //Results in:
  248. //
  249. // formatted unicode string built to
  250. // take advantage of the specified
  251. // source's parameter message file.
  252. //
  253. //Note:
  254. //
  255. // An access mask containing three
  256. // access types for a Widget object
  257. // type (defined by the Foozle source)
  258. // might end up looking like:
  259. //
  260. // %%1062\n\t\t%1066\n\t\t%%601
  261. //
  262. // The %%numbers are signals to the
  263. // event viewer to perform parameter
  264. // substitution before display.
  265. //
  266. SeAdtParmTypePrivs, //Produces 1 parameter with formatting.
  267. //Received value:
  268. //
  269. // ??? Check with RobertRe and ScottBi
  270. //
  271. //Results in:
  272. //
  273. // formatted unicode string similar to
  274. // that for access types. Each priv
  275. // will be formatted to be displayed
  276. // on its own line. E.g.,
  277. //
  278. // %%642\n\t\t%%651\n\t\t%%655
  279. //
  280. SeAdtParmTypeObjectTypes, //Produces 10 parameters with formatting.
  281. //Received value:
  282. //
  283. // Produces a list a stringized GUIDS along
  284. // with information similar to that for
  285. // an access mask.
  286. SeAdtParmTypeHexUlong, //Produces 1 parameter
  287. //Received value:
  288. //
  289. // Ulong
  290. //
  291. //Results in:
  292. //
  293. // Unicode string representation of
  294. // unsigned integer value in hexadecimal.
  295. SeAdtParmTypePtr, //Produces 1 parameter
  296. //Received value:
  297. //
  298. // pointer
  299. //
  300. //Results in:
  301. //
  302. // Unicode string representation of
  303. // unsigned integer value in hexadecimal.
  304. SeAdtParmTypeTime, //Produces 2 parameters
  305. //Received value:
  306. //
  307. // LARGE_INTEGER
  308. //
  309. //Results in:
  310. //
  311. // Unicode string representation of
  312. // date and time.
  313. //
  314. SeAdtParmTypeGuid, //Produces 1 parameter
  315. //Received value:
  316. //
  317. // GUID pointer
  318. //
  319. //Results in:
  320. //
  321. // Unicode string representation of GUID
  322. // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
  323. //
  324. SeAdtParmTypeLuid, //
  325. //Produces 1 parameter
  326. //Received value:
  327. //
  328. // LUID
  329. //
  330. //Results in:
  331. //
  332. // Hex LUID
  333. //
  334. SeAdtParmTypeHexInt64, //Produces 1 parameter
  335. //Received value:
  336. //
  337. // 64 bit integer
  338. //
  339. //Results in:
  340. //
  341. // Unicode string representation of
  342. // unsigned integer value in hexadecimal.
  343. SeAdtParmTypeStringList, //Produces 1 parameter
  344. //Received value:
  345. //
  346. // ptr to LSAP_ADT_STRING_LIST
  347. //
  348. //Results in:
  349. //
  350. // Unicode string representation of
  351. // concatenation of the strings in the list
  352. SeAdtParmTypeSidList, //Produces 1 parameter
  353. //Received value:
  354. //
  355. // ptr to LSAP_ADT_SID_LIST
  356. //
  357. //Results in:
  358. //
  359. // Unicode string representation of
  360. // concatenation of the SIDs in the list
  361. SeAdtParmTypeDuration, //Produces 1 parameters
  362. //Received value:
  363. //
  364. // LARGE_INTEGER
  365. //
  366. //Results in:
  367. //
  368. // Unicode string representation of
  369. // a duration.
  370. SeAdtParmTypeUserAccountControl,//Produces 3 parameters
  371. //Received value:
  372. //
  373. // old and new UserAccountControl values
  374. //
  375. //Results in:
  376. //
  377. // Unicode string representations of
  378. // the flags in UserAccountControl.
  379. // 1 - old value in hex
  380. // 2 - new value in hex
  381. // 3 - difference as strings
  382. SeAdtParmTypeNoUac, //Produces 3 parameters
  383. //Received value:
  384. //
  385. // none
  386. //
  387. //Results in:
  388. //
  389. // Three dashes ('-') as unicode strings.
  390. SeAdtParmTypeMessage, //Produces 1 Parameter
  391. //Received value:
  392. //
  393. // ULONG (MessageNo from msobjs.mc)
  394. //
  395. //Results in:
  396. //
  397. // Unicode string representation of
  398. // %%MessageNo which the event viewer
  399. // will replace with the message string
  400. // from msobjs.mc
  401. SeAdtParmTypeDateTime, //Produces 1 Parameter
  402. //Received value:
  403. //
  404. // LARGE_INTEGER
  405. //
  406. //Results in:
  407. //
  408. // Unicode string representation of
  409. // date and time (in _one_ string).
  410. SeAdtParmTypeSockAddr // Produces 2 parameters
  411. //
  412. // Received value:
  413. //
  414. // pointer to SOCKADDR_IN/SOCKADDR_IN6
  415. // structure
  416. //
  417. // Results in:
  418. //
  419. // param 1: IP address string
  420. // param 2: Port number string
  421. //
  422. } SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
  423. #ifndef GUID_DEFINED
  424. #include <guiddef.h>
  425. #endif /* GUID_DEFINED */
  426. typedef struct _SE_ADT_OBJECT_TYPE {
  427. GUID ObjectType;
  428. USHORT Flags;
  429. #define SE_ADT_OBJECT_ONLY 0x1
  430. USHORT Level;
  431. ACCESS_MASK AccessMask;
  432. } SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
  433. typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
  434. SE_ADT_PARAMETER_TYPE Type;
  435. ULONG Length;
  436. ULONG_PTR Data[2];
  437. PVOID Address;
  438. } SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
  439. //
  440. // Structure that will be passed between the Reference Monitor and LSA
  441. // to transmit auditing information.
  442. //
  443. #define SE_MAX_AUDIT_PARAMETERS 32
  444. typedef struct _SE_ADT_PARAMETER_ARRAY {
  445. ULONG CategoryId;
  446. ULONG AuditId;
  447. ULONG ParameterCount;
  448. ULONG Length;
  449. USHORT Type;
  450. ULONG Flags;
  451. SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
  452. } SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
  453. #define SE_ADT_PARAMETERS_SELF_RELATIVE 0x00000001
  454. ///////////////////////////////////////////////////////////////////////////
  455. // //
  456. // Structures describing the complex param type SeAdtParmTypeStringList //
  457. // //
  458. ///////////////////////////////////////////////////////////////////////////
  459. typedef struct _LSA_ADT_STRING_LIST_ENTRY
  460. {
  461. ULONG Flags;
  462. UNICODE_STRING String;
  463. }
  464. LSA_ADT_STRING_LIST_ENTRY, *PLSA_ADT_STRING_LIST_ENTRY;
  465. typedef struct _LSA_ADT_STRING_LIST
  466. {
  467. ULONG cStrings;
  468. PLSA_ADT_STRING_LIST_ENTRY Strings;
  469. }
  470. LSA_ADT_STRING_LIST, *PLSA_ADT_STRING_LIST;
  471. ///////////////////////////////////////////////////////////////////////////
  472. // //
  473. // Structures describing the complex param type SeAdtParmTypeSidList //
  474. // //
  475. ///////////////////////////////////////////////////////////////////////////
  476. typedef struct _LSA_ADT_SID_LIST_ENTRY
  477. {
  478. ULONG Flags;
  479. PSID Sid;
  480. }
  481. LSA_ADT_SID_LIST_ENTRY, *PLSA_ADT_SID_LIST_ENTRY;
  482. typedef struct _LSA_ADT_SID_LIST
  483. {
  484. ULONG cSids;
  485. PLSA_ADT_SID_LIST_ENTRY Sids;
  486. }
  487. LSA_ADT_SID_LIST, *PLSA_ADT_SID_LIST;
  488. // begin_ntsecapi
  489. //
  490. // Audit Event Categories
  491. //
  492. // The following are the built-in types or Categories of audit event.
  493. // WARNING! This structure is subject to expansion. The user should not
  494. // compute the number of elements of this type directly, but instead
  495. // should obtain the count of elements by calling LsaQueryInformationPolicy()
  496. // for the PolicyAuditEventsInformation class and extracting the count from
  497. // the MaximumAuditEventCount field of the returned structure.
  498. //
  499. typedef enum _POLICY_AUDIT_EVENT_TYPE {
  500. AuditCategorySystem,
  501. AuditCategoryLogon,
  502. AuditCategoryObjectAccess,
  503. AuditCategoryPrivilegeUse,
  504. AuditCategoryDetailedTracking,
  505. AuditCategoryPolicyChange,
  506. AuditCategoryAccountManagement,
  507. AuditCategoryDirectoryServiceAccess,
  508. AuditCategoryAccountLogon
  509. } POLICY_AUDIT_EVENT_TYPE, *PPOLICY_AUDIT_EVENT_TYPE;
  510. //
  511. // The following defines describe the auditing options for each
  512. // event type
  513. //
  514. // Leave options specified for this event unchanged
  515. #define POLICY_AUDIT_EVENT_UNCHANGED (0x00000000L)
  516. // Audit successful occurrences of events of this type
  517. #define POLICY_AUDIT_EVENT_SUCCESS (0x00000001L)
  518. // Audit failed attempts to cause an event of this type to occur
  519. #define POLICY_AUDIT_EVENT_FAILURE (0x00000002L)
  520. #define POLICY_AUDIT_EVENT_NONE (0x00000004L)
  521. // Mask of valid event auditing options
  522. #define POLICY_AUDIT_EVENT_MASK \
  523. (POLICY_AUDIT_EVENT_SUCCESS | \
  524. POLICY_AUDIT_EVENT_FAILURE | \
  525. POLICY_AUDIT_EVENT_UNCHANGED | \
  526. POLICY_AUDIT_EVENT_NONE)
  527. #ifdef _NTDEF_
  528. // begin_ntifs
  529. typedef UNICODE_STRING LSA_UNICODE_STRING, *PLSA_UNICODE_STRING;
  530. typedef STRING LSA_STRING, *PLSA_STRING;
  531. typedef OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES;
  532. // end_ntifs
  533. #else // _NTDEF_
  534. #ifndef IN
  535. #define IN
  536. #endif
  537. #ifndef OUT
  538. #define OUT
  539. #endif
  540. #ifndef OPTIONAL
  541. #define OPTIONAL
  542. #endif
  543. typedef struct _LSA_UNICODE_STRING {
  544. USHORT Length;
  545. USHORT MaximumLength;
  546. #ifdef MIDL_PASS
  547. [size_is(MaximumLength/2), length_is(Length/2)]
  548. #endif // MIDL_PASS
  549. PWSTR Buffer;
  550. } LSA_UNICODE_STRING, *PLSA_UNICODE_STRING;
  551. typedef struct _LSA_STRING {
  552. USHORT Length;
  553. USHORT MaximumLength;
  554. PCHAR Buffer;
  555. } LSA_STRING, *PLSA_STRING;
  556. typedef struct _LSA_OBJECT_ATTRIBUTES {
  557. ULONG Length;
  558. HANDLE RootDirectory;
  559. PLSA_UNICODE_STRING ObjectName;
  560. ULONG Attributes;
  561. PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
  562. PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
  563. } LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES;
  564. #endif // _NTDEF_
  565. // end_ntsecapi
  566. // begin_ntsecapi
  567. //
  568. // Macro for determining whether an API succeeded.
  569. //
  570. #define LSA_SUCCESS(Error) ((LONG)(Error) >= 0)
  571. // end_ntsecapi
  572. /////////////////////////////////////////////////////////////////////////
  573. // //
  574. // Services provided for use by logon processes //
  575. // //
  576. /////////////////////////////////////////////////////////////////////////
  577. // begin_ntsecapi
  578. #ifndef _NTLSA_IFS_
  579. // begin_ntifs
  580. NTSTATUS
  581. NTAPI
  582. LsaRegisterLogonProcess (
  583. IN PLSA_STRING LogonProcessName,
  584. OUT PHANDLE LsaHandle,
  585. OUT PLSA_OPERATIONAL_MODE SecurityMode
  586. );
  587. NTSTATUS
  588. NTAPI
  589. LsaLogonUser (
  590. IN HANDLE LsaHandle,
  591. IN PLSA_STRING OriginName,
  592. IN SECURITY_LOGON_TYPE LogonType,
  593. IN ULONG AuthenticationPackage,
  594. IN PVOID AuthenticationInformation,
  595. IN ULONG AuthenticationInformationLength,
  596. IN PTOKEN_GROUPS LocalGroups OPTIONAL,
  597. IN PTOKEN_SOURCE SourceContext,
  598. OUT PVOID *ProfileBuffer,
  599. OUT PULONG ProfileBufferLength,
  600. OUT PLUID LogonId,
  601. OUT PHANDLE Token,
  602. OUT PQUOTA_LIMITS Quotas,
  603. OUT PNTSTATUS SubStatus
  604. );
  605. // end_ntifs
  606. NTSTATUS
  607. NTAPI
  608. LsaLookupAuthenticationPackage (
  609. IN HANDLE LsaHandle,
  610. IN PLSA_STRING PackageName,
  611. OUT PULONG AuthenticationPackage
  612. );
  613. // begin_ntifs
  614. NTSTATUS
  615. NTAPI
  616. LsaFreeReturnBuffer (
  617. IN PVOID Buffer
  618. );
  619. // end_ntifs
  620. NTSTATUS
  621. NTAPI
  622. LsaCallAuthenticationPackage (
  623. IN HANDLE LsaHandle,
  624. IN ULONG AuthenticationPackage,
  625. IN PVOID ProtocolSubmitBuffer,
  626. IN ULONG SubmitBufferLength,
  627. OUT PVOID *ProtocolReturnBuffer,
  628. OUT PULONG ReturnBufferLength,
  629. OUT PNTSTATUS ProtocolStatus
  630. );
  631. NTSTATUS
  632. NTAPI
  633. LsaDeregisterLogonProcess (
  634. IN HANDLE LsaHandle
  635. );
  636. NTSTATUS
  637. NTAPI
  638. LsaConnectUntrusted (
  639. OUT PHANDLE LsaHandle
  640. );
  641. #endif // _NTLSA_IFS_
  642. // end_ntsecapi
  643. // begin_ntsecpkg
  644. /////////////////////////////////////////////////////////////////////////
  645. // //
  646. // Data types used by authentication packages //
  647. // //
  648. /////////////////////////////////////////////////////////////////////////
  649. //
  650. // opaque data type which represents a client request
  651. //
  652. typedef PVOID *PLSA_CLIENT_REQUEST;
  653. //
  654. // When a logon of a user is requested, the authentication package
  655. // is expected to return one of the following structures indicating
  656. // the contents of a user's token.
  657. //
  658. typedef enum _LSA_TOKEN_INFORMATION_TYPE {
  659. LsaTokenInformationNull, // Implies LSA_TOKEN_INFORMATION_NULL data type
  660. LsaTokenInformationV1, // Implies LSA_TOKEN_INFORMATION_V1 data type
  661. LsaTokenInformationV2 // Implies LSA_TOKEN_INFORMATION_V2 data type
  662. } LSA_TOKEN_INFORMATION_TYPE, *PLSA_TOKEN_INFORMATION_TYPE;
  663. //
  664. // The NULL information is used in cases where a non-authenticated
  665. // system access is needed. For example, a non-authentication network
  666. // circuit (such as LAN Manager's null session) can be given NULL
  667. // information. This will result in an anonymous token being generated
  668. // for the logon that gives the user no ability to access protected system
  669. // resources, but does allow access to non-protected system resources.
  670. //
  671. typedef struct _LSA_TOKEN_INFORMATION_NULL {
  672. //
  673. // Time at which the security context becomes invalid.
  674. // Use a value in the distant future if the context
  675. // never expires.
  676. //
  677. LARGE_INTEGER ExpirationTime;
  678. //
  679. // The SID(s) of groups the user is to be made a member of. This should
  680. // not include WORLD or other system defined and assigned
  681. // SIDs. These will be added automatically by LSA.
  682. //
  683. // Each SID is expected to be in a separately allocated block
  684. // of memory. The TOKEN_GROUPS structure is also expected to
  685. // be in a separately allocated block of memory.
  686. //
  687. PTOKEN_GROUPS Groups;
  688. } LSA_TOKEN_INFORMATION_NULL, *PLSA_TOKEN_INFORMATION_NULL;
  689. //
  690. // The V1 token information structure is superceeded by the V2 token
  691. // information structure. The V1 strucure should only be used for
  692. // backwards compatability.
  693. // This structure contains information that an authentication package
  694. // can place in a Version 1 NT token object.
  695. //
  696. typedef struct _LSA_TOKEN_INFORMATION_V1 {
  697. //
  698. // Time at which the security context becomes invalid.
  699. // Use a value in the distant future if the context
  700. // never expires.
  701. //
  702. LARGE_INTEGER ExpirationTime;
  703. //
  704. // The SID of the user logging on. The SID value is in a
  705. // separately allocated block of memory.
  706. //
  707. TOKEN_USER User;
  708. //
  709. // The SID(s) of groups the user is a member of. This should
  710. // not include WORLD or other system defined and assigned
  711. // SIDs. These will be added automatically by LSA.
  712. //
  713. // Each SID is expected to be in a separately allocated block
  714. // of memory. The TOKEN_GROUPS structure is also expected to
  715. // be in a separately allocated block of memory.
  716. //
  717. PTOKEN_GROUPS Groups;
  718. //
  719. // This field is used to establish the primary group of the user.
  720. // This value does not have to correspond to one of the SIDs
  721. // assigned to the user.
  722. //
  723. // The SID pointed to by this structure is expected to be in
  724. // a separately allocated block of memory.
  725. //
  726. // This field is mandatory and must be filled in.
  727. //
  728. TOKEN_PRIMARY_GROUP PrimaryGroup;
  729. //
  730. // The privileges the user is assigned. This list of privileges
  731. // will be augmented or over-ridden by any local security policy
  732. // assigned privileges.
  733. //
  734. // Each privilege is expected to be in a separately allocated
  735. // block of memory. The TOKEN_PRIVILEGES structure is also
  736. // expected to be in a separately allocated block of memory.
  737. //
  738. // If there are no privileges to assign to the user, this field
  739. // may be set to NULL.
  740. //
  741. PTOKEN_PRIVILEGES Privileges;
  742. //
  743. // This field may be used to establish an explicit default
  744. // owner. Normally, the user ID is used as the default owner.
  745. // If another value is desired, it must be specified here.
  746. //
  747. // The Owner.Sid field may be set to NULL to indicate there is no
  748. // alternate default owner value.
  749. //
  750. TOKEN_OWNER Owner;
  751. //
  752. // This field may be used to establish a default
  753. // protection for the user. If no value is provided, then
  754. // a default protection that grants everyone all access will
  755. // be established.
  756. //
  757. // The DefaultDacl.DefaultDacl field may be set to NULL to indicate
  758. // there is no default protection.
  759. //
  760. TOKEN_DEFAULT_DACL DefaultDacl;
  761. } LSA_TOKEN_INFORMATION_V1, *PLSA_TOKEN_INFORMATION_V1;
  762. //
  763. // The V2 information is used in most cases of logon. The structure is identical
  764. // to the V1 token information structure, with the exception that the memory allocation
  765. // is handled differently. The LSA_TOKEN_INFORMATION_V2 structure is intended to be
  766. // allocated monolithiclly, with the privileges, DACL, sids, and group array either part of
  767. // same allocation, or allocated and freed externally.
  768. //
  769. typedef LSA_TOKEN_INFORMATION_V1 LSA_TOKEN_INFORMATION_V2, *PLSA_TOKEN_INFORMATION_V2;
  770. /////////////////////////////////////////////////////////////////////////
  771. // //
  772. // Interface definitions available for use by authentication packages //
  773. // //
  774. /////////////////////////////////////////////////////////////////////////
  775. typedef NTSTATUS
  776. (NTAPI LSA_CREATE_LOGON_SESSION) (
  777. IN PLUID LogonId
  778. );
  779. typedef NTSTATUS
  780. (NTAPI LSA_DELETE_LOGON_SESSION) (
  781. IN PLUID LogonId
  782. );
  783. typedef NTSTATUS
  784. (NTAPI LSA_ADD_CREDENTIAL) (
  785. IN PLUID LogonId,
  786. IN ULONG AuthenticationPackage,
  787. IN PLSA_STRING PrimaryKeyValue,
  788. IN PLSA_STRING Credentials
  789. );
  790. typedef NTSTATUS
  791. (NTAPI LSA_GET_CREDENTIALS) (
  792. IN PLUID LogonId,
  793. IN ULONG AuthenticationPackage,
  794. IN OUT PULONG QueryContext,
  795. IN BOOLEAN RetrieveAllCredentials,
  796. IN PLSA_STRING PrimaryKeyValue,
  797. OUT PULONG PrimaryKeyLength,
  798. IN PLSA_STRING Credentials
  799. );
  800. typedef NTSTATUS
  801. (NTAPI LSA_DELETE_CREDENTIAL) (
  802. IN PLUID LogonId,
  803. IN ULONG AuthenticationPackage,
  804. IN PLSA_STRING PrimaryKeyValue
  805. );
  806. typedef PVOID
  807. (NTAPI LSA_ALLOCATE_LSA_HEAP) (
  808. IN ULONG Length
  809. );
  810. typedef VOID
  811. (NTAPI LSA_FREE_LSA_HEAP) (
  812. IN PVOID Base
  813. );
  814. typedef PVOID
  815. (NTAPI LSA_ALLOCATE_PRIVATE_HEAP) (
  816. IN SIZE_T Length
  817. );
  818. typedef VOID
  819. (NTAPI LSA_FREE_PRIVATE_HEAP) (
  820. IN PVOID Base
  821. );
  822. typedef NTSTATUS
  823. (NTAPI LSA_ALLOCATE_CLIENT_BUFFER) (
  824. IN PLSA_CLIENT_REQUEST ClientRequest,
  825. IN ULONG LengthRequired,
  826. OUT PVOID *ClientBaseAddress
  827. );
  828. typedef NTSTATUS
  829. (NTAPI LSA_FREE_CLIENT_BUFFER) (
  830. IN PLSA_CLIENT_REQUEST ClientRequest,
  831. IN PVOID ClientBaseAddress
  832. );
  833. typedef NTSTATUS
  834. (NTAPI LSA_COPY_TO_CLIENT_BUFFER) (
  835. IN PLSA_CLIENT_REQUEST ClientRequest,
  836. IN ULONG Length,
  837. IN PVOID ClientBaseAddress,
  838. IN PVOID BufferToCopy
  839. );
  840. typedef NTSTATUS
  841. (NTAPI LSA_COPY_FROM_CLIENT_BUFFER) (
  842. IN PLSA_CLIENT_REQUEST ClientRequest,
  843. IN ULONG Length,
  844. IN PVOID BufferToCopy,
  845. IN PVOID ClientBaseAddress
  846. );
  847. typedef LSA_CREATE_LOGON_SESSION * PLSA_CREATE_LOGON_SESSION ;
  848. typedef LSA_DELETE_LOGON_SESSION * PLSA_DELETE_LOGON_SESSION ;
  849. typedef LSA_ADD_CREDENTIAL * PLSA_ADD_CREDENTIAL ;
  850. typedef LSA_GET_CREDENTIALS * PLSA_GET_CREDENTIALS ;
  851. typedef LSA_DELETE_CREDENTIAL * PLSA_DELETE_CREDENTIAL ;
  852. typedef LSA_ALLOCATE_LSA_HEAP * PLSA_ALLOCATE_LSA_HEAP ;
  853. typedef LSA_FREE_LSA_HEAP * PLSA_FREE_LSA_HEAP ;
  854. typedef LSA_ALLOCATE_PRIVATE_HEAP * PLSA_ALLOCATE_PRIVATE_HEAP ;
  855. typedef LSA_FREE_PRIVATE_HEAP * PLSA_FREE_PRIVATE_HEAP ;
  856. typedef LSA_ALLOCATE_CLIENT_BUFFER * PLSA_ALLOCATE_CLIENT_BUFFER ;
  857. typedef LSA_FREE_CLIENT_BUFFER * PLSA_FREE_CLIENT_BUFFER ;
  858. typedef LSA_COPY_TO_CLIENT_BUFFER * PLSA_COPY_TO_CLIENT_BUFFER ;
  859. typedef LSA_COPY_FROM_CLIENT_BUFFER * PLSA_COPY_FROM_CLIENT_BUFFER ;
  860. //
  861. // The dispatch table of LSA services which are available to
  862. // authentication packages.
  863. //
  864. typedef struct _LSA_DISPATCH_TABLE {
  865. PLSA_CREATE_LOGON_SESSION CreateLogonSession;
  866. PLSA_DELETE_LOGON_SESSION DeleteLogonSession;
  867. PLSA_ADD_CREDENTIAL AddCredential;
  868. PLSA_GET_CREDENTIALS GetCredentials;
  869. PLSA_DELETE_CREDENTIAL DeleteCredential;
  870. PLSA_ALLOCATE_LSA_HEAP AllocateLsaHeap;
  871. PLSA_FREE_LSA_HEAP FreeLsaHeap;
  872. PLSA_ALLOCATE_CLIENT_BUFFER AllocateClientBuffer;
  873. PLSA_FREE_CLIENT_BUFFER FreeClientBuffer;
  874. PLSA_COPY_TO_CLIENT_BUFFER CopyToClientBuffer;
  875. PLSA_COPY_FROM_CLIENT_BUFFER CopyFromClientBuffer;
  876. } LSA_DISPATCH_TABLE, *PLSA_DISPATCH_TABLE;
  877. ////////////////////////////////////////////////////////////////////////////
  878. // //
  879. // Interface definitions of services provided by authentication packages //
  880. // //
  881. ////////////////////////////////////////////////////////////////////////////
  882. //
  883. // Routine names
  884. //
  885. // The routines provided by the DLL must be assigned the following names
  886. // so that their addresses can be retrieved when the DLL is loaded.
  887. //
  888. #define LSA_AP_NAME_INITIALIZE_PACKAGE "LsaApInitializePackage\0"
  889. #define LSA_AP_NAME_LOGON_USER "LsaApLogonUser\0"
  890. #define LSA_AP_NAME_LOGON_USER_EX "LsaApLogonUserEx\0"
  891. #define LSA_AP_NAME_CALL_PACKAGE "LsaApCallPackage\0"
  892. #define LSA_AP_NAME_LOGON_TERMINATED "LsaApLogonTerminated\0"
  893. #define LSA_AP_NAME_CALL_PACKAGE_UNTRUSTED "LsaApCallPackageUntrusted\0"
  894. #define LSA_AP_NAME_CALL_PACKAGE_PASSTHROUGH "LsaApCallPackagePassthrough\0"
  895. //
  896. // Routine templates
  897. //
  898. typedef NTSTATUS
  899. (NTAPI LSA_AP_INITIALIZE_PACKAGE) (
  900. IN ULONG AuthenticationPackageId,
  901. IN PLSA_DISPATCH_TABLE LsaDispatchTable,
  902. IN PLSA_STRING Database OPTIONAL,
  903. IN PLSA_STRING Confidentiality OPTIONAL,
  904. OUT PLSA_STRING *AuthenticationPackageName
  905. );
  906. typedef NTSTATUS
  907. (NTAPI LSA_AP_LOGON_USER) (
  908. IN PLSA_CLIENT_REQUEST ClientRequest,
  909. IN SECURITY_LOGON_TYPE LogonType,
  910. IN PVOID AuthenticationInformation,
  911. IN PVOID ClientAuthenticationBase,
  912. IN ULONG AuthenticationInformationLength,
  913. OUT PVOID *ProfileBuffer,
  914. OUT PULONG ProfileBufferLength,
  915. OUT PLUID LogonId,
  916. OUT PNTSTATUS SubStatus,
  917. OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  918. OUT PVOID *TokenInformation,
  919. OUT PLSA_UNICODE_STRING *AccountName,
  920. OUT PLSA_UNICODE_STRING *AuthenticatingAuthority
  921. );
  922. typedef NTSTATUS
  923. (NTAPI LSA_AP_LOGON_USER_EX) (
  924. IN PLSA_CLIENT_REQUEST ClientRequest,
  925. IN SECURITY_LOGON_TYPE LogonType,
  926. IN PVOID AuthenticationInformation,
  927. IN PVOID ClientAuthenticationBase,
  928. IN ULONG AuthenticationInformationLength,
  929. OUT PVOID *ProfileBuffer,
  930. OUT PULONG ProfileBufferLength,
  931. OUT PLUID LogonId,
  932. OUT PNTSTATUS SubStatus,
  933. OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  934. OUT PVOID *TokenInformation,
  935. OUT PUNICODE_STRING *AccountName,
  936. OUT PUNICODE_STRING *AuthenticatingAuthority,
  937. OUT PUNICODE_STRING *MachineName
  938. );
  939. typedef NTSTATUS
  940. (NTAPI LSA_AP_CALL_PACKAGE) (
  941. IN PLSA_CLIENT_REQUEST ClientRequest,
  942. IN PVOID ProtocolSubmitBuffer,
  943. IN PVOID ClientBufferBase,
  944. IN ULONG SubmitBufferLength,
  945. OUT PVOID *ProtocolReturnBuffer,
  946. OUT PULONG ReturnBufferLength,
  947. OUT PNTSTATUS ProtocolStatus
  948. );
  949. typedef NTSTATUS
  950. (NTAPI LSA_AP_CALL_PACKAGE_PASSTHROUGH) (
  951. IN PLSA_CLIENT_REQUEST ClientRequest,
  952. IN PVOID ProtocolSubmitBuffer,
  953. IN PVOID ClientBufferBase,
  954. IN ULONG SubmitBufferLength,
  955. OUT PVOID *ProtocolReturnBuffer,
  956. OUT PULONG ReturnBufferLength,
  957. OUT PNTSTATUS ProtocolStatus
  958. );
  959. typedef VOID
  960. (NTAPI LSA_AP_LOGON_TERMINATED) (
  961. IN PLUID LogonId
  962. );
  963. typedef LSA_AP_CALL_PACKAGE LSA_AP_CALL_PACKAGE_UNTRUSTED;
  964. typedef LSA_AP_INITIALIZE_PACKAGE * PLSA_AP_INITIALIZE_PACKAGE ;
  965. typedef LSA_AP_LOGON_USER * PLSA_AP_LOGON_USER ;
  966. typedef LSA_AP_LOGON_USER_EX * PLSA_AP_LOGON_USER_EX ;
  967. typedef LSA_AP_CALL_PACKAGE * PLSA_AP_CALL_PACKAGE ;
  968. typedef LSA_AP_CALL_PACKAGE_PASSTHROUGH * PLSA_AP_CALL_PACKAGE_PASSTHROUGH ;
  969. typedef LSA_AP_LOGON_TERMINATED * PLSA_AP_LOGON_TERMINATED ;
  970. typedef LSA_AP_CALL_PACKAGE_UNTRUSTED * PLSA_AP_CALL_PACKAGE_UNTRUSTED ;
  971. // end_ntsecpkg
  972. // begin_ntsecapi
  973. ////////////////////////////////////////////////////////////////////////////
  974. // //
  975. // Local Security Policy Administration API datatypes and defines //
  976. // //
  977. ////////////////////////////////////////////////////////////////////////////
  978. //
  979. // Access types for the Policy object
  980. //
  981. #define POLICY_VIEW_LOCAL_INFORMATION 0x00000001L
  982. #define POLICY_VIEW_AUDIT_INFORMATION 0x00000002L
  983. #define POLICY_GET_PRIVATE_INFORMATION 0x00000004L
  984. #define POLICY_TRUST_ADMIN 0x00000008L
  985. #define POLICY_CREATE_ACCOUNT 0x00000010L
  986. #define POLICY_CREATE_SECRET 0x00000020L
  987. #define POLICY_CREATE_PRIVILEGE 0x00000040L
  988. #define POLICY_SET_DEFAULT_QUOTA_LIMITS 0x00000080L
  989. #define POLICY_SET_AUDIT_REQUIREMENTS 0x00000100L
  990. #define POLICY_AUDIT_LOG_ADMIN 0x00000200L
  991. #define POLICY_SERVER_ADMIN 0x00000400L
  992. #define POLICY_LOOKUP_NAMES 0x00000800L
  993. #define POLICY_NOTIFICATION 0x00001000L
  994. #define POLICY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  995. POLICY_VIEW_LOCAL_INFORMATION |\
  996. POLICY_VIEW_AUDIT_INFORMATION |\
  997. POLICY_GET_PRIVATE_INFORMATION |\
  998. POLICY_TRUST_ADMIN |\
  999. POLICY_CREATE_ACCOUNT |\
  1000. POLICY_CREATE_SECRET |\
  1001. POLICY_CREATE_PRIVILEGE |\
  1002. POLICY_SET_DEFAULT_QUOTA_LIMITS |\
  1003. POLICY_SET_AUDIT_REQUIREMENTS |\
  1004. POLICY_AUDIT_LOG_ADMIN |\
  1005. POLICY_SERVER_ADMIN |\
  1006. POLICY_LOOKUP_NAMES)
  1007. #define POLICY_READ (STANDARD_RIGHTS_READ |\
  1008. POLICY_VIEW_AUDIT_INFORMATION |\
  1009. POLICY_GET_PRIVATE_INFORMATION)
  1010. #define POLICY_WRITE (STANDARD_RIGHTS_WRITE |\
  1011. POLICY_TRUST_ADMIN |\
  1012. POLICY_CREATE_ACCOUNT |\
  1013. POLICY_CREATE_SECRET |\
  1014. POLICY_CREATE_PRIVILEGE |\
  1015. POLICY_SET_DEFAULT_QUOTA_LIMITS |\
  1016. POLICY_SET_AUDIT_REQUIREMENTS |\
  1017. POLICY_AUDIT_LOG_ADMIN |\
  1018. POLICY_SERVER_ADMIN)
  1019. #define POLICY_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  1020. POLICY_VIEW_LOCAL_INFORMATION |\
  1021. POLICY_LOOKUP_NAMES)
  1022. //
  1023. // Policy object specific data types.
  1024. //
  1025. //
  1026. // The following data type is used to identify a domain
  1027. //
  1028. typedef struct _LSA_TRUST_INFORMATION {
  1029. LSA_UNICODE_STRING Name;
  1030. PSID Sid;
  1031. } LSA_TRUST_INFORMATION, *PLSA_TRUST_INFORMATION;
  1032. // where members have the following usage:
  1033. //
  1034. // Name - The name of the domain.
  1035. //
  1036. // Sid - A pointer to the Sid of the Domain
  1037. //
  1038. //
  1039. // The following data type is used in name and SID lookup services to
  1040. // describe the domains referenced in the lookup operation.
  1041. //
  1042. typedef struct _LSA_REFERENCED_DOMAIN_LIST {
  1043. ULONG Entries;
  1044. PLSA_TRUST_INFORMATION Domains;
  1045. } LSA_REFERENCED_DOMAIN_LIST, *PLSA_REFERENCED_DOMAIN_LIST;
  1046. // where members have the following usage:
  1047. //
  1048. // Entries - Is a count of the number of domains described in the
  1049. // Domains array.
  1050. //
  1051. // Domains - Is a pointer to an array of Entries LSA_TRUST_INFORMATION data
  1052. // structures.
  1053. //
  1054. //
  1055. // The following data type is used in name to SID lookup services to describe
  1056. // the domains referenced in the lookup operation.
  1057. //
  1058. typedef struct _LSA_TRANSLATED_SID {
  1059. SID_NAME_USE Use;
  1060. ULONG RelativeId;
  1061. LONG DomainIndex;
  1062. } LSA_TRANSLATED_SID, *PLSA_TRANSLATED_SID;
  1063. // where members have the following usage:
  1064. //
  1065. // Use - identifies the use of the SID. If this value is SidUnknown or
  1066. // SidInvalid, then the remainder of the record is not set and
  1067. // should be ignored.
  1068. //
  1069. // RelativeId - Contains the relative ID of the translated SID. The
  1070. // remainder of the SID (the prefix) is obtained using the
  1071. // DomainIndex field.
  1072. //
  1073. // DomainIndex - Is the index of an entry in a related
  1074. // LSA_REFERENCED_DOMAIN_LIST data structure describing the
  1075. // domain in which the account was found.
  1076. //
  1077. // If there is no corresponding reference domain for an entry, then
  1078. // this field will contain a negative value.
  1079. //
  1080. typedef struct _LSA_TRANSLATED_SID2 {
  1081. SID_NAME_USE Use;
  1082. PSID Sid;
  1083. LONG DomainIndex;
  1084. ULONG Flags;
  1085. } LSA_TRANSLATED_SID2, *PLSA_TRANSLATED_SID2;
  1086. // where members have the following usage:
  1087. //
  1088. // Use - identifies the use of the SID. If this value is SidUnknown or
  1089. // SidInvalid, then the remainder of the record is not set and
  1090. // should be ignored.
  1091. //
  1092. // Sid - Contains the complete Sid of the tranlated SID
  1093. //
  1094. // DomainIndex - Is the index of an entry in a related
  1095. // LSA_REFERENCED_DOMAIN_LIST data structure describing the
  1096. // domain in which the account was found.
  1097. //
  1098. // If there is no corresponding reference domain for an entry, then
  1099. // this field will contain a negative value.
  1100. //
  1101. //
  1102. // The following data type is used in SID to name lookup services to
  1103. // describe the domains referenced in the lookup operation.
  1104. //
  1105. typedef struct _LSA_TRANSLATED_NAME {
  1106. SID_NAME_USE Use;
  1107. LSA_UNICODE_STRING Name;
  1108. LONG DomainIndex;
  1109. } LSA_TRANSLATED_NAME, *PLSA_TRANSLATED_NAME;
  1110. // where the members have the following usage:
  1111. //
  1112. // Use - Identifies the use of the name. If this value is SidUnknown
  1113. // or SidInvalid, then the remainder of the record is not set and
  1114. // should be ignored. If this value is SidWellKnownGroup then the
  1115. // Name field is invalid, but the DomainIndex field is not.
  1116. //
  1117. // Name - Contains the isolated name of the translated SID.
  1118. //
  1119. // DomainIndex - Is the index of an entry in a related
  1120. // LSA_REFERENCED_DOMAIN_LIST data structure describing the domain
  1121. // in which the account was found.
  1122. //
  1123. // If there is no corresponding reference domain for an entry, then
  1124. // this field will contain a negative value.
  1125. //
  1126. // end_ntsecapi
  1127. //
  1128. // The following data type specifies the ways in which a user or member of
  1129. // an alias or group may be allowed to access the system. An account may
  1130. // be granted zero or more of these types of access to the system.
  1131. //
  1132. // The types of access are:
  1133. //
  1134. // Interactive - The user or alias/group member may interactively logon
  1135. // to the system.
  1136. //
  1137. // Network - The user or alias/group member may access the system via
  1138. // the network (e.g., through shares).
  1139. //
  1140. // Service - The user or alias may be activated as a service on the
  1141. // system.
  1142. //
  1143. typedef ULONG POLICY_SYSTEM_ACCESS_MODE, *PPOLICY_SYSTEM_ACCESS_MODE;
  1144. #define POLICY_MODE_INTERACTIVE SECURITY_ACCESS_INTERACTIVE_LOGON
  1145. #define POLICY_MODE_NETWORK SECURITY_ACCESS_NETWORK_LOGON
  1146. #define POLICY_MODE_BATCH SECURITY_ACCESS_BATCH_LOGON
  1147. #define POLICY_MODE_SERVICE SECURITY_ACCESS_SERVICE_LOGON
  1148. #define POLICY_MODE_PROXY SECURITY_ACCESS_PROXY_LOGON
  1149. #define POLICY_MODE_DENY_INTERACTIVE SECURITY_ACCESS_DENY_INTERACTIVE_LOGON
  1150. #define POLICY_MODE_DENY_NETWORK SECURITY_ACCESS_DENY_NETWORK_LOGON
  1151. #define POLICY_MODE_DENY_BATCH SECURITY_ACCESS_DENY_BATCH_LOGON
  1152. #define POLICY_MODE_DENY_SERVICE SECURITY_ACCESS_DENY_SERVICE_LOGON
  1153. #define POLICY_MODE_REMOTE_INTERACTIVE SECURITY_ACCESS_REMOTE_INTERACTIVE_LOGON
  1154. #define POLICY_MODE_DENY_REMOTE_INTERACTIVE SECURITY_ACCESS_DENY_REMOTE_INTERACTIVE_LOGON
  1155. #define POLICY_MODE_ALL (POLICY_MODE_INTERACTIVE | \
  1156. POLICY_MODE_NETWORK | \
  1157. POLICY_MODE_BATCH | \
  1158. POLICY_MODE_SERVICE | \
  1159. POLICY_MODE_PROXY | \
  1160. POLICY_MODE_DENY_INTERACTIVE | \
  1161. POLICY_MODE_DENY_NETWORK | \
  1162. SECURITY_ACCESS_DENY_BATCH_LOGON | \
  1163. SECURITY_ACCESS_DENY_SERVICE_LOGON | \
  1164. POLICY_MODE_REMOTE_INTERACTIVE | \
  1165. POLICY_MODE_DENY_REMOTE_INTERACTIVE )
  1166. //
  1167. // The following is the bits allowed in NT4.0
  1168. //
  1169. #define POLICY_MODE_ALL_NT4 (POLICY_MODE_INTERACTIVE | \
  1170. POLICY_MODE_NETWORK | \
  1171. POLICY_MODE_BATCH | \
  1172. POLICY_MODE_SERVICE | \
  1173. POLICY_MODE_PROXY )
  1174. // begin_ntsecapi
  1175. //
  1176. // The following data type is used to represent the role of the LSA
  1177. // server (primary or backup).
  1178. //
  1179. typedef enum _POLICY_LSA_SERVER_ROLE {
  1180. PolicyServerRoleBackup = 2,
  1181. PolicyServerRolePrimary
  1182. } POLICY_LSA_SERVER_ROLE, *PPOLICY_LSA_SERVER_ROLE;
  1183. //
  1184. // The following data type is used to specify the auditing options for
  1185. // an Audit Event Type.
  1186. //
  1187. typedef ULONG POLICY_AUDIT_EVENT_OPTIONS, *PPOLICY_AUDIT_EVENT_OPTIONS;
  1188. // where the following flags can be set:
  1189. //
  1190. // POLICY_AUDIT_EVENT_UNCHANGED - Leave existing auditing options
  1191. // unchanged for events of this type. This flag is only used for
  1192. // set operations. If this flag is set, then all other flags
  1193. // are ignored.
  1194. //
  1195. // POLICY_AUDIT_EVENT_NONE - Cancel all auditing options for events
  1196. // of this type. If this flag is set, the success/failure flags
  1197. // are ignored.
  1198. //
  1199. // POLICY_AUDIT_EVENT_SUCCESS - When auditing is enabled, audit all
  1200. // successful occurrences of events of the given type.
  1201. //
  1202. // POLICY_AUDIT_EVENT_FAILURE - When auditing is enabled, audit all
  1203. // unsuccessful occurrences of events of the given type.
  1204. //
  1205. // end_ntsecapi
  1206. //
  1207. // The following data type is used to return information about privileges
  1208. // defined on a system.
  1209. //
  1210. typedef struct _POLICY_PRIVILEGE_DEFINITION {
  1211. LSA_UNICODE_STRING Name;
  1212. LUID LocalValue;
  1213. } POLICY_PRIVILEGE_DEFINITION, *PPOLICY_PRIVILEGE_DEFINITION;
  1214. //
  1215. // where the members have the following usage:
  1216. //
  1217. // Name - Is the architected name of the privilege. This is the
  1218. // primary key of the privilege and the only value that is
  1219. // transportable between systems.
  1220. //
  1221. // Luid - is a LUID value assigned locally for efficient representation
  1222. // of the privilege. Ths value is meaningful only on the system it
  1223. // was assigned on and is not transportable in any way.
  1224. //
  1225. //
  1226. // System Flags for LsaLookupNames2
  1227. //
  1228. //
  1229. // Note the flags start backward so that public values
  1230. // don't have gaps.
  1231. //
  1232. //
  1233. // This flag controls LsaLookupNames2 such that isolated names, including
  1234. // UPN's are not searched for off the machine. Composite names
  1235. // (domain\username) are still sent off machine if necessary.
  1236. //
  1237. #define LSA_LOOKUP_ISOLATED_AS_LOCAL 0x80000000
  1238. // begin_ntsecapi
  1239. //
  1240. // The following data type defines the classes of Policy Information
  1241. // that may be queried/set.
  1242. //
  1243. typedef enum _POLICY_INFORMATION_CLASS {
  1244. PolicyAuditLogInformation = 1,
  1245. PolicyAuditEventsInformation,
  1246. PolicyPrimaryDomainInformation,
  1247. PolicyPdAccountInformation,
  1248. PolicyAccountDomainInformation,
  1249. PolicyLsaServerRoleInformation,
  1250. PolicyReplicaSourceInformation,
  1251. PolicyDefaultQuotaInformation,
  1252. PolicyModificationInformation,
  1253. PolicyAuditFullSetInformation,
  1254. PolicyAuditFullQueryInformation,
  1255. PolicyDnsDomainInformation,
  1256. PolicyDnsDomainInformationInt
  1257. } POLICY_INFORMATION_CLASS, *PPOLICY_INFORMATION_CLASS;
  1258. //
  1259. // The following data type corresponds to the PolicyAuditLogInformation
  1260. // information class. It is used to represent information relating to
  1261. // the Audit Log.
  1262. //
  1263. // This structure may be used in both query and set operations. However,
  1264. // when used in set operations, some fields are ignored.
  1265. //
  1266. typedef struct _POLICY_AUDIT_LOG_INFO {
  1267. ULONG AuditLogPercentFull;
  1268. ULONG MaximumLogSize;
  1269. LARGE_INTEGER AuditRetentionPeriod;
  1270. BOOLEAN AuditLogFullShutdownInProgress;
  1271. LARGE_INTEGER TimeToShutdown;
  1272. ULONG NextAuditRecordId;
  1273. } POLICY_AUDIT_LOG_INFO, *PPOLICY_AUDIT_LOG_INFO;
  1274. // where the members have the following usage:
  1275. //
  1276. // AuditLogPercentFull - Indicates the percentage of the Audit Log
  1277. // currently being used.
  1278. //
  1279. // MaximumLogSize - Specifies the maximum size of the Audit Log in
  1280. // kilobytes.
  1281. //
  1282. // AuditRetentionPeriod - Indicates the length of time that Audit
  1283. // Records are to be retained. Audit Records are discardable
  1284. // if their timestamp predates the current time minus the
  1285. // retention period.
  1286. //
  1287. // AuditLogFullShutdownInProgress - Indicates whether or not a system
  1288. // shutdown is being initiated due to the security Audit Log becoming
  1289. // full. This condition will only occur if the system is configured
  1290. // to shutdown when the log becomes full.
  1291. //
  1292. // TRUE indicates that a shutdown is in progress
  1293. // FALSE indicates that a shutdown is not in progress.
  1294. //
  1295. // Once a shutdown has been initiated, this flag will be set to
  1296. // TRUE. If an administrator is able to currect the situation
  1297. // before the shutdown becomes irreversible, then this flag will
  1298. // be reset to false.
  1299. //
  1300. // This field is ignored for set operations.
  1301. //
  1302. // TimeToShutdown - If the AuditLogFullShutdownInProgress flag is set,
  1303. // then this field contains the time left before the shutdown
  1304. // becomes irreversible.
  1305. //
  1306. // This field is ignored for set operations.
  1307. //
  1308. //
  1309. // The following data type corresponds to the PolicyAuditEventsInformation
  1310. // information class. It is used to represent information relating to
  1311. // the audit requirements.
  1312. //
  1313. typedef struct _POLICY_AUDIT_EVENTS_INFO {
  1314. BOOLEAN AuditingMode;
  1315. PPOLICY_AUDIT_EVENT_OPTIONS EventAuditingOptions;
  1316. ULONG MaximumAuditEventCount;
  1317. } POLICY_AUDIT_EVENTS_INFO, *PPOLICY_AUDIT_EVENTS_INFO;
  1318. // where the members have the following usage:
  1319. //
  1320. // AuditingMode - A Boolean variable specifying the Auditing Mode value.
  1321. // This value is interpreted as follows:
  1322. //
  1323. // TRUE - Auditing is to be enabled (set operations) or is enabled
  1324. // (query operations). Audit Records will be generated according
  1325. // to the Event Auditing Options in effect (see the
  1326. // EventAuditingOptions field.
  1327. //
  1328. // FALSE - Auditing is to be disabled (set operations) or is
  1329. // disabled (query operations). No Audit Records will be
  1330. // generated. Note that for set operations the Event Auditing
  1331. // Options in effect will still be updated as specified by the
  1332. // EventAuditingOptions field whether Auditing is enabled or
  1333. // disabled.
  1334. //
  1335. // EventAuditingOptions - Pointer to an array of Auditing Options
  1336. // indexed by Audit Event Type.
  1337. //
  1338. // MaximumAuditEventCount - Specifiesa count of the number of Audit
  1339. // Event Types specified by the EventAuditingOptions parameter. If
  1340. // this count is less than the number of Audit Event Types supported
  1341. // by the system, the Auditing Options for Event Types with IDs
  1342. // higher than (MaximumAuditEventCount + 1) are left unchanged.
  1343. //
  1344. //
  1345. // The following structure corresponds to the PolicyAccountDomainInformation
  1346. // information class.
  1347. //
  1348. typedef struct _POLICY_ACCOUNT_DOMAIN_INFO {
  1349. LSA_UNICODE_STRING DomainName;
  1350. PSID DomainSid;
  1351. } POLICY_ACCOUNT_DOMAIN_INFO, *PPOLICY_ACCOUNT_DOMAIN_INFO;
  1352. // where the members have the following usage:
  1353. //
  1354. // DomainName - Is the name of the domain
  1355. //
  1356. // DomainSid - Is the Sid of the domain
  1357. //
  1358. //
  1359. // The following structure corresponds to the PolicyPrimaryDomainInformation
  1360. // information class.
  1361. //
  1362. typedef struct _POLICY_PRIMARY_DOMAIN_INFO {
  1363. LSA_UNICODE_STRING Name;
  1364. PSID Sid;
  1365. } POLICY_PRIMARY_DOMAIN_INFO, *PPOLICY_PRIMARY_DOMAIN_INFO;
  1366. // where the members have the following usage:
  1367. //
  1368. // Name - Is the name of the domain
  1369. //
  1370. // Sid - Is the Sid of the domain
  1371. //
  1372. //
  1373. // The following structure corresponds to the PolicyDnsDomainInformation
  1374. // information class
  1375. //
  1376. typedef struct _POLICY_DNS_DOMAIN_INFO
  1377. {
  1378. LSA_UNICODE_STRING Name;
  1379. LSA_UNICODE_STRING DnsDomainName;
  1380. LSA_UNICODE_STRING DnsForestName;
  1381. GUID DomainGuid;
  1382. PSID Sid;
  1383. } POLICY_DNS_DOMAIN_INFO, *PPOLICY_DNS_DOMAIN_INFO;
  1384. // where the members have the following usage:
  1385. //
  1386. // Name - Is the name of the Domain
  1387. //
  1388. // DnsDomainName - Is the DNS name of the domain
  1389. //
  1390. // DnsForestName - Is the DNS forest name of the domain
  1391. //
  1392. // DomainGuid - Is the GUID of the domain
  1393. //
  1394. // Sid - Is the Sid of the domain
  1395. //
  1396. // The following structure corresponds to the PolicyPdAccountInformation
  1397. // information class. This structure may be used in Query operations
  1398. // only.
  1399. //
  1400. typedef struct _POLICY_PD_ACCOUNT_INFO {
  1401. LSA_UNICODE_STRING Name;
  1402. } POLICY_PD_ACCOUNT_INFO, *PPOLICY_PD_ACCOUNT_INFO;
  1403. // where the members have the following usage:
  1404. //
  1405. // Name - Is the name of an account in the domain that should be used
  1406. // for authentication and name/ID lookup requests.
  1407. //
  1408. //
  1409. // The following structure corresponds to the PolicyLsaServerRoleInformation
  1410. // information class.
  1411. //
  1412. typedef struct _POLICY_LSA_SERVER_ROLE_INFO {
  1413. POLICY_LSA_SERVER_ROLE LsaServerRole;
  1414. } POLICY_LSA_SERVER_ROLE_INFO, *PPOLICY_LSA_SERVER_ROLE_INFO;
  1415. // where the fields have the following usage:
  1416. //
  1417. // TBS
  1418. //
  1419. //
  1420. // The following structure corresponds to the PolicyReplicaSourceInformation
  1421. // information class.
  1422. //
  1423. typedef struct _POLICY_REPLICA_SOURCE_INFO {
  1424. LSA_UNICODE_STRING ReplicaSource;
  1425. LSA_UNICODE_STRING ReplicaAccountName;
  1426. } POLICY_REPLICA_SOURCE_INFO, *PPOLICY_REPLICA_SOURCE_INFO;
  1427. //
  1428. // The following structure corresponds to the PolicyDefaultQuotaInformation
  1429. // information class.
  1430. //
  1431. typedef struct _POLICY_DEFAULT_QUOTA_INFO {
  1432. QUOTA_LIMITS QuotaLimits;
  1433. } POLICY_DEFAULT_QUOTA_INFO, *PPOLICY_DEFAULT_QUOTA_INFO;
  1434. //
  1435. // The following structure corresponds to the PolicyModificationInformation
  1436. // information class.
  1437. //
  1438. typedef struct _POLICY_MODIFICATION_INFO {
  1439. LARGE_INTEGER ModifiedId;
  1440. LARGE_INTEGER DatabaseCreationTime;
  1441. } POLICY_MODIFICATION_INFO, *PPOLICY_MODIFICATION_INFO;
  1442. // where the members have the following usage:
  1443. //
  1444. // ModifiedId - Is a 64-bit unsigned integer that is incremented each
  1445. // time anything in the LSA database is modified. This value is
  1446. // only modified on Primary Domain Controllers.
  1447. //
  1448. // DatabaseCreationTime - Is the date/time that the LSA Database was
  1449. // created. On Backup Domain Controllers, this value is replicated
  1450. // from the Primary Domain Controller.
  1451. //
  1452. //
  1453. // The following structure type corresponds to the PolicyAuditFullSetInformation
  1454. // Information Class.
  1455. //
  1456. typedef struct _POLICY_AUDIT_FULL_SET_INFO {
  1457. BOOLEAN ShutDownOnFull;
  1458. } POLICY_AUDIT_FULL_SET_INFO, *PPOLICY_AUDIT_FULL_SET_INFO;
  1459. //
  1460. // The following structure type corresponds to the PolicyAuditFullQueryInformation
  1461. // Information Class.
  1462. //
  1463. typedef struct _POLICY_AUDIT_FULL_QUERY_INFO {
  1464. BOOLEAN ShutDownOnFull;
  1465. BOOLEAN LogIsFull;
  1466. } POLICY_AUDIT_FULL_QUERY_INFO, *PPOLICY_AUDIT_FULL_QUERY_INFO;
  1467. //
  1468. // The following data type defines the classes of Policy Information
  1469. // that may be queried/set that has domain wide effect.
  1470. //
  1471. typedef enum _POLICY_DOMAIN_INFORMATION_CLASS {
  1472. // PolicyDomainQualityOfServiceInformation, // value was used in W2K; no longer supported
  1473. PolicyDomainEfsInformation = 2,
  1474. PolicyDomainKerberosTicketInformation
  1475. } POLICY_DOMAIN_INFORMATION_CLASS, *PPOLICY_DOMAIN_INFORMATION_CLASS;
  1476. //
  1477. // The following structure corresponds to the PolicyEfsInformation
  1478. // information class
  1479. //
  1480. typedef struct _POLICY_DOMAIN_EFS_INFO {
  1481. ULONG InfoLength;
  1482. PUCHAR EfsBlob;
  1483. } POLICY_DOMAIN_EFS_INFO, *PPOLICY_DOMAIN_EFS_INFO;
  1484. //
  1485. // where the members have the following usage:
  1486. //
  1487. // InfoLength - Length of the EFS Information blob
  1488. //
  1489. // EfsBlob - Efs blob data
  1490. //
  1491. //
  1492. // The following structure corresponds to the PolicyDomainKerberosTicketInformation
  1493. // information class
  1494. //
  1495. #define POLICY_KERBEROS_VALIDATE_CLIENT 0x00000080
  1496. typedef struct _POLICY_DOMAIN_KERBEROS_TICKET_INFO {
  1497. ULONG AuthenticationOptions;
  1498. LARGE_INTEGER MaxServiceTicketAge;
  1499. LARGE_INTEGER MaxTicketAge;
  1500. LARGE_INTEGER MaxRenewAge;
  1501. LARGE_INTEGER MaxClockSkew;
  1502. LARGE_INTEGER Reserved;
  1503. } POLICY_DOMAIN_KERBEROS_TICKET_INFO, *PPOLICY_DOMAIN_KERBEROS_TICKET_INFO;
  1504. //
  1505. // where the members have the following usage
  1506. //
  1507. // AuthenticationOptions -- allowed ticket options (POLICY_KERBEROS_* flags )
  1508. //
  1509. // MaxServiceTicketAge -- Maximum lifetime for a service ticket
  1510. //
  1511. // MaxTicketAge -- Maximum lifetime for the initial ticket
  1512. //
  1513. // MaxRenewAge -- Maximum cumulative age a renewable ticket can be with
  1514. // requring authentication
  1515. //
  1516. // MaxClockSkew -- Maximum tolerance for synchronization of computer clocks
  1517. //
  1518. // Reserved -- Reserved
  1519. //
  1520. // The following data type defines the classes of Policy Information / Policy Domain Information
  1521. // that may be used to request notification
  1522. //
  1523. typedef enum _POLICY_NOTIFICATION_INFORMATION_CLASS {
  1524. PolicyNotifyAuditEventsInformation = 1,
  1525. PolicyNotifyAccountDomainInformation,
  1526. PolicyNotifyServerRoleInformation,
  1527. PolicyNotifyDnsDomainInformation,
  1528. PolicyNotifyDomainEfsInformation,
  1529. PolicyNotifyDomainKerberosTicketInformation,
  1530. PolicyNotifyMachineAccountPasswordInformation
  1531. } POLICY_NOTIFICATION_INFORMATION_CLASS, *PPOLICY_NOTIFICATION_INFORMATION_CLASS;
  1532. // end_ntsecapi
  1533. //
  1534. // Account object type-specific Access Types
  1535. //
  1536. #define ACCOUNT_VIEW 0x00000001L
  1537. #define ACCOUNT_ADJUST_PRIVILEGES 0x00000002L
  1538. #define ACCOUNT_ADJUST_QUOTAS 0x00000004L
  1539. #define ACCOUNT_ADJUST_SYSTEM_ACCESS 0x00000008L
  1540. #define ACCOUNT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  1541. ACCOUNT_VIEW |\
  1542. ACCOUNT_ADJUST_PRIVILEGES |\
  1543. ACCOUNT_ADJUST_QUOTAS |\
  1544. ACCOUNT_ADJUST_SYSTEM_ACCESS)
  1545. #define ACCOUNT_READ (STANDARD_RIGHTS_READ |\
  1546. ACCOUNT_VIEW)
  1547. #define ACCOUNT_WRITE (STANDARD_RIGHTS_WRITE |\
  1548. ACCOUNT_ADJUST_PRIVILEGES |\
  1549. ACCOUNT_ADJUST_QUOTAS |\
  1550. ACCOUNT_ADJUST_SYSTEM_ACCESS)
  1551. #define ACCOUNT_EXECUTE (STANDARD_RIGHTS_EXECUTE)
  1552. // begin_ntsecapi
  1553. //
  1554. // LSA RPC Context Handle (Opaque form). Note that a Context Handle is
  1555. // always a pointer type unlike regular handles.
  1556. //
  1557. typedef PVOID LSA_HANDLE, *PLSA_HANDLE;
  1558. // end_ntsecapi
  1559. //
  1560. // Trusted Domain object specific access types
  1561. //
  1562. #define TRUSTED_QUERY_DOMAIN_NAME 0x00000001L
  1563. #define TRUSTED_QUERY_CONTROLLERS 0x00000002L
  1564. #define TRUSTED_SET_CONTROLLERS 0x00000004L
  1565. #define TRUSTED_QUERY_POSIX 0x00000008L
  1566. #define TRUSTED_SET_POSIX 0x00000010L
  1567. #define TRUSTED_SET_AUTH 0x00000020L
  1568. #define TRUSTED_QUERY_AUTH 0x00000040L
  1569. #define TRUSTED_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  1570. TRUSTED_QUERY_DOMAIN_NAME |\
  1571. TRUSTED_QUERY_CONTROLLERS |\
  1572. TRUSTED_SET_CONTROLLERS |\
  1573. TRUSTED_QUERY_POSIX |\
  1574. TRUSTED_SET_POSIX |\
  1575. TRUSTED_SET_AUTH |\
  1576. TRUSTED_QUERY_AUTH)
  1577. #define TRUSTED_READ (STANDARD_RIGHTS_READ |\
  1578. TRUSTED_QUERY_DOMAIN_NAME)
  1579. #define TRUSTED_WRITE (STANDARD_RIGHTS_WRITE |\
  1580. TRUSTED_SET_CONTROLLERS |\
  1581. TRUSTED_SET_POSIX |\
  1582. TRUSTED_SET_AUTH )
  1583. #define TRUSTED_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  1584. TRUSTED_QUERY_CONTROLLERS |\
  1585. TRUSTED_QUERY_POSIX)
  1586. // begin_ntsecapi
  1587. //
  1588. // Trusted Domain Object specific data types
  1589. //
  1590. //
  1591. // This data type defines the following information classes that may be
  1592. // queried or set.
  1593. //
  1594. typedef enum _TRUSTED_INFORMATION_CLASS {
  1595. TrustedDomainNameInformation = 1,
  1596. TrustedControllersInformation,
  1597. TrustedPosixOffsetInformation,
  1598. TrustedPasswordInformation,
  1599. TrustedDomainInformationBasic,
  1600. TrustedDomainInformationEx,
  1601. TrustedDomainAuthInformation,
  1602. TrustedDomainFullInformation,
  1603. TrustedDomainAuthInformationInternal,
  1604. TrustedDomainFullInformationInternal,
  1605. TrustedDomainInformationEx2Internal,
  1606. TrustedDomainFullInformation2Internal,
  1607. } TRUSTED_INFORMATION_CLASS, *PTRUSTED_INFORMATION_CLASS;
  1608. //
  1609. // The following data type corresponds to the TrustedDomainNameInformation
  1610. // information class.
  1611. //
  1612. typedef struct _TRUSTED_DOMAIN_NAME_INFO {
  1613. LSA_UNICODE_STRING Name;
  1614. } TRUSTED_DOMAIN_NAME_INFO, *PTRUSTED_DOMAIN_NAME_INFO;
  1615. // where members have the following meaning:
  1616. //
  1617. // Name - The name of the Trusted Domain.
  1618. //
  1619. //
  1620. // The following data type corresponds to the TrustedControllersInformation
  1621. // information class.
  1622. //
  1623. typedef struct _TRUSTED_CONTROLLERS_INFO {
  1624. ULONG Entries;
  1625. PLSA_UNICODE_STRING Names;
  1626. } TRUSTED_CONTROLLERS_INFO, *PTRUSTED_CONTROLLERS_INFO;
  1627. // where members have the following meaning:
  1628. //
  1629. // Entries - Indicate how mamy entries there are in the Names array.
  1630. //
  1631. // Names - Pointer to an array of LSA_UNICODE_STRING structures containing the
  1632. // names of domain controllers of the domain. This information may not
  1633. // be accurate and should be used only as a hint. The order of this
  1634. // list is considered significant and will be maintained.
  1635. //
  1636. // By convention, the first name in this list is assumed to be the
  1637. // Primary Domain Controller of the domain. If the Primary Domain
  1638. // Controller is not known, the first name should be set to the NULL
  1639. // string.
  1640. //
  1641. //
  1642. // The following data type corresponds to the TrustedPosixOffsetInformation
  1643. // information class.
  1644. //
  1645. typedef struct _TRUSTED_POSIX_OFFSET_INFO {
  1646. ULONG Offset;
  1647. } TRUSTED_POSIX_OFFSET_INFO, *PTRUSTED_POSIX_OFFSET_INFO;
  1648. // where members have the following meaning:
  1649. //
  1650. // Offset - Is an offset to use for the generation of Posix user and group
  1651. // IDs from SIDs. The Posix ID corresponding to any particular SID is
  1652. // generated by adding the RID of that SID to the Offset of the SID's
  1653. // corresponding TrustedDomain object.
  1654. //
  1655. //
  1656. // The following data type corresponds to the TrustedPasswordInformation
  1657. // information class.
  1658. //
  1659. typedef struct _TRUSTED_PASSWORD_INFO {
  1660. LSA_UNICODE_STRING Password;
  1661. LSA_UNICODE_STRING OldPassword;
  1662. } TRUSTED_PASSWORD_INFO, *PTRUSTED_PASSWORD_INFO;
  1663. typedef LSA_TRUST_INFORMATION TRUSTED_DOMAIN_INFORMATION_BASIC;
  1664. typedef PLSA_TRUST_INFORMATION PTRUSTED_DOMAIN_INFORMATION_BASIC;
  1665. //
  1666. // Direction of the trust
  1667. //
  1668. #define TRUST_DIRECTION_DISABLED 0x00000000
  1669. #define TRUST_DIRECTION_INBOUND 0x00000001
  1670. #define TRUST_DIRECTION_OUTBOUND 0x00000002
  1671. #define TRUST_DIRECTION_BIDIRECTIONAL (TRUST_DIRECTION_INBOUND | TRUST_DIRECTION_OUTBOUND)
  1672. #define TRUST_TYPE_DOWNLEVEL 0x00000001 // NT4 and before
  1673. #define TRUST_TYPE_UPLEVEL 0x00000002 // NT5
  1674. #define TRUST_TYPE_MIT 0x00000003 // Trust with a MIT Kerberos realm
  1675. // #define TRUST_TYPE_DCE 0x00000004 // Trust with a DCE realm
  1676. // Levels 0x5 - 0x000FFFFF reserved for future use
  1677. // Provider specific trust levels are from 0x00100000 to 0xFFF00000
  1678. #define TRUST_ATTRIBUTE_NON_TRANSITIVE 0x00000001 // Disallow transitivity
  1679. #define TRUST_ATTRIBUTE_UPLEVEL_ONLY 0x00000002 // Trust link only valid for uplevel client
  1680. #define TRUST_ATTRIBUTE_QUARANTINED_DOMAIN 0x00000004 // Used to quarantine domains
  1681. #define TRUST_ATTRIBUTE_FOREST_TRANSITIVE 0x00000008 // This link may contain forest trust information
  1682. #define TRUST_ATTRIBUTE_CROSS_ORGANIZATION 0x00000010 // This trust is to a domain/forest which is not part of this enterprise
  1683. #define TRUST_ATTRIBUTE_WITHIN_FOREST 0x00000020 // Trust is internal to this forest
  1684. #define TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL 0x00000040 // Trust is to be treated as external for trust boundary purposes
  1685. // Trust attributes 0x00000040 through 0x00200000 are reserved for future use
  1686. // Trust attributes 0x00400000 through 0x00800000 were used previously (up to W2K) and should not be re-used
  1687. // Trust attributes 0x01000000 through 0x80000000 are reserved for user
  1688. #define TRUST_ATTRIBUTES_VALID 0xFF03FFFF
  1689. #define TRUST_ATTRIBUTES_USER 0xFF000000
  1690. typedef struct _TRUSTED_DOMAIN_INFORMATION_EX {
  1691. LSA_UNICODE_STRING Name;
  1692. LSA_UNICODE_STRING FlatName;
  1693. PSID Sid;
  1694. ULONG TrustDirection;
  1695. ULONG TrustType;
  1696. ULONG TrustAttributes;
  1697. } TRUSTED_DOMAIN_INFORMATION_EX, *PTRUSTED_DOMAIN_INFORMATION_EX;
  1698. typedef struct _TRUSTED_DOMAIN_INFORMATION_EX2 {
  1699. LSA_UNICODE_STRING Name;
  1700. LSA_UNICODE_STRING FlatName;
  1701. PSID Sid;
  1702. ULONG TrustDirection;
  1703. ULONG TrustType;
  1704. ULONG TrustAttributes;
  1705. ULONG ForestTrustLength;
  1706. #ifdef MIDL_PASS
  1707. [size_is( ForestTrustLength )]
  1708. #endif
  1709. PUCHAR ForestTrustInfo;
  1710. } TRUSTED_DOMAIN_INFORMATION_EX2, *PTRUSTED_DOMAIN_INFORMATION_EX2;
  1711. //
  1712. // Type of authentication information
  1713. //
  1714. #define TRUST_AUTH_TYPE_NONE 0 // Ignore this entry
  1715. #define TRUST_AUTH_TYPE_NT4OWF 1 // NT4 OWF password
  1716. #define TRUST_AUTH_TYPE_CLEAR 2 // Cleartext password
  1717. #define TRUST_AUTH_TYPE_VERSION 3 // Cleartext password version number
  1718. typedef struct _LSA_AUTH_INFORMATION {
  1719. LARGE_INTEGER LastUpdateTime;
  1720. ULONG AuthType;
  1721. ULONG AuthInfoLength;
  1722. PUCHAR AuthInfo;
  1723. } LSA_AUTH_INFORMATION, *PLSA_AUTH_INFORMATION;
  1724. typedef struct _TRUSTED_DOMAIN_AUTH_INFORMATION {
  1725. ULONG IncomingAuthInfos;
  1726. PLSA_AUTH_INFORMATION IncomingAuthenticationInformation;
  1727. PLSA_AUTH_INFORMATION IncomingPreviousAuthenticationInformation;
  1728. ULONG OutgoingAuthInfos;
  1729. PLSA_AUTH_INFORMATION OutgoingAuthenticationInformation;
  1730. PLSA_AUTH_INFORMATION OutgoingPreviousAuthenticationInformation;
  1731. } TRUSTED_DOMAIN_AUTH_INFORMATION, *PTRUSTED_DOMAIN_AUTH_INFORMATION;
  1732. typedef struct _TRUSTED_DOMAIN_FULL_INFORMATION {
  1733. TRUSTED_DOMAIN_INFORMATION_EX Information;
  1734. TRUSTED_POSIX_OFFSET_INFO PosixOffset;
  1735. TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
  1736. } TRUSTED_DOMAIN_FULL_INFORMATION, *PTRUSTED_DOMAIN_FULL_INFORMATION;
  1737. typedef struct _TRUSTED_DOMAIN_FULL_INFORMATION2 {
  1738. TRUSTED_DOMAIN_INFORMATION_EX2 Information;
  1739. TRUSTED_POSIX_OFFSET_INFO PosixOffset;
  1740. TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
  1741. } TRUSTED_DOMAIN_FULL_INFORMATION2, *PTRUSTED_DOMAIN_FULL_INFORMATION2;
  1742. typedef enum {
  1743. ForestTrustTopLevelName,
  1744. ForestTrustTopLevelNameEx,
  1745. ForestTrustDomainInfo,
  1746. ForestTrustRecordTypeLast = ForestTrustDomainInfo
  1747. } LSA_FOREST_TRUST_RECORD_TYPE;
  1748. //
  1749. // Bottom 16 bits of the flags are reserved for disablement reasons
  1750. //
  1751. #define LSA_FTRECORD_DISABLED_REASONS ( 0x0000FFFFL )
  1752. //
  1753. // Reasons for a top-level name forest trust record to be disabled
  1754. //
  1755. #define LSA_TLN_DISABLED_NEW ( 0x00000001L )
  1756. #define LSA_TLN_DISABLED_ADMIN ( 0x00000002L )
  1757. #define LSA_TLN_DISABLED_CONFLICT ( 0x00000004L )
  1758. //
  1759. // Reasons for a domain information forest trust record to be disabled
  1760. //
  1761. #define LSA_SID_DISABLED_ADMIN ( 0x00000001L )
  1762. #define LSA_SID_DISABLED_CONFLICT ( 0x00000002L )
  1763. #define LSA_NB_DISABLED_ADMIN ( 0x00000004L )
  1764. #define LSA_NB_DISABLED_CONFLICT ( 0x00000008L )
  1765. typedef struct _LSA_FOREST_TRUST_DOMAIN_INFO {
  1766. #ifdef MIDL_PASS
  1767. PISID Sid;
  1768. #else
  1769. PSID Sid;
  1770. #endif
  1771. LSA_UNICODE_STRING DnsName;
  1772. LSA_UNICODE_STRING NetbiosName;
  1773. } LSA_FOREST_TRUST_DOMAIN_INFO, *PLSA_FOREST_TRUST_DOMAIN_INFO;
  1774. //
  1775. // To prevent huge data to be passed in, we should put a limit on LSA_FOREST_TRUST_BINARY_DATA.
  1776. // 128K is large enough that can't be reached in the near future, and small enough not to
  1777. // cause memory problems.
  1778. #define MAX_FOREST_TRUST_BINARY_DATA_SIZE ( 128 * 1024 )
  1779. typedef struct _LSA_FOREST_TRUST_BINARY_DATA {
  1780. #ifdef MIDL_PASS
  1781. [range(0, MAX_FOREST_TRUST_BINARY_DATA_SIZE)] ULONG Length;
  1782. [size_is( Length )] PUCHAR Buffer;
  1783. #else
  1784. ULONG Length;
  1785. PUCHAR Buffer;
  1786. #endif
  1787. } LSA_FOREST_TRUST_BINARY_DATA, *PLSA_FOREST_TRUST_BINARY_DATA;
  1788. typedef struct _LSA_FOREST_TRUST_RECORD {
  1789. ULONG Flags;
  1790. LSA_FOREST_TRUST_RECORD_TYPE ForestTrustType; // type of record
  1791. LARGE_INTEGER Time;
  1792. #ifdef MIDL_PASS
  1793. [switch_type( LSA_FOREST_TRUST_RECORD_TYPE ), switch_is( ForestTrustType )]
  1794. #endif
  1795. union { // actual data
  1796. #ifdef MIDL_PASS
  1797. [case( ForestTrustTopLevelName,
  1798. ForestTrustTopLevelNameEx )] LSA_UNICODE_STRING TopLevelName;
  1799. [case( ForestTrustDomainInfo )] LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
  1800. [default] LSA_FOREST_TRUST_BINARY_DATA Data;
  1801. #else
  1802. LSA_UNICODE_STRING TopLevelName;
  1803. LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
  1804. LSA_FOREST_TRUST_BINARY_DATA Data; // used for unrecognized types
  1805. #endif
  1806. } ForestTrustData;
  1807. } LSA_FOREST_TRUST_RECORD, *PLSA_FOREST_TRUST_RECORD;
  1808. //
  1809. // To prevent forest trust blobs of large size, number of records must be
  1810. // smaller than MAX_RECORDS_IN_FOREST_TRUST_INFO
  1811. //
  1812. #define MAX_RECORDS_IN_FOREST_TRUST_INFO 4000
  1813. typedef struct _LSA_FOREST_TRUST_INFORMATION {
  1814. #ifdef MIDL_PASS
  1815. [range(0, MAX_RECORDS_IN_FOREST_TRUST_INFO)] ULONG RecordCount;
  1816. [size_is( RecordCount )] PLSA_FOREST_TRUST_RECORD * Entries;
  1817. #else
  1818. ULONG RecordCount;
  1819. PLSA_FOREST_TRUST_RECORD * Entries;
  1820. #endif
  1821. } LSA_FOREST_TRUST_INFORMATION, *PLSA_FOREST_TRUST_INFORMATION;
  1822. typedef enum {
  1823. CollisionTdo,
  1824. CollisionXref,
  1825. CollisionOther
  1826. } LSA_FOREST_TRUST_COLLISION_RECORD_TYPE;
  1827. typedef struct _LSA_FOREST_TRUST_COLLISION_RECORD {
  1828. ULONG Index;
  1829. LSA_FOREST_TRUST_COLLISION_RECORD_TYPE Type;
  1830. ULONG Flags;
  1831. LSA_UNICODE_STRING Name;
  1832. } LSA_FOREST_TRUST_COLLISION_RECORD, *PLSA_FOREST_TRUST_COLLISION_RECORD;
  1833. typedef struct _LSA_FOREST_TRUST_COLLISION_INFORMATION {
  1834. ULONG RecordCount;
  1835. #ifdef MIDL_PASS
  1836. [size_is( RecordCount )]
  1837. #endif
  1838. PLSA_FOREST_TRUST_COLLISION_RECORD * Entries;
  1839. } LSA_FOREST_TRUST_COLLISION_INFORMATION, *PLSA_FOREST_TRUST_COLLISION_INFORMATION;
  1840. // end_ntsecapi
  1841. //
  1842. // Secret object specific access types
  1843. //
  1844. #define SECRET_SET_VALUE 0x00000001L
  1845. #define SECRET_QUERY_VALUE 0x00000002L
  1846. #define SECRET_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  1847. SECRET_SET_VALUE |\
  1848. SECRET_QUERY_VALUE)
  1849. #define SECRET_READ (STANDARD_RIGHTS_READ |\
  1850. SECRET_QUERY_VALUE)
  1851. #define SECRET_WRITE (STANDARD_RIGHTS_WRITE |\
  1852. SECRET_SET_VALUE)
  1853. #define SECRET_EXECUTE (STANDARD_RIGHTS_EXECUTE)
  1854. //
  1855. // Global secret object prefix
  1856. //
  1857. #define LSA_GLOBAL_SECRET_PREFIX L"G$"
  1858. #define LSA_GLOBAL_SECRET_PREFIX_LENGTH 2
  1859. #define LSA_LOCAL_SECRET_PREFIX L"L$"
  1860. #define LSA_LOCAL_SECRET_PREFIX_LENGTH 2
  1861. #define LSA_MACHINE_SECRET_PREFIX L"M$"
  1862. #define LSA_MACHINE_SECRET_PREFIX_LENGTH \
  1863. ( ( sizeof( LSA_MACHINE_SECRET_PREFIX ) - sizeof( WCHAR ) ) / sizeof( WCHAR ) )
  1864. //
  1865. // Secret object specific data types.
  1866. //
  1867. //
  1868. // Secret object limits
  1869. //
  1870. #define LSA_SECRET_MAXIMUM_COUNT 0x00001000L
  1871. #define LSA_SECRET_MAXIMUM_LENGTH 0x00000200L
  1872. // begin_ntsecapi
  1873. //
  1874. // LSA Enumeration Context
  1875. //
  1876. typedef ULONG LSA_ENUMERATION_HANDLE, *PLSA_ENUMERATION_HANDLE;
  1877. //
  1878. // LSA Enumeration Information
  1879. //
  1880. typedef struct _LSA_ENUMERATION_INFORMATION {
  1881. PSID Sid;
  1882. } LSA_ENUMERATION_INFORMATION, *PLSA_ENUMERATION_INFORMATION;
  1883. ////////////////////////////////////////////////////////////////////////////
  1884. // //
  1885. // Local Security Policy - Miscellaneous API function prototypes //
  1886. // //
  1887. ////////////////////////////////////////////////////////////////////////////
  1888. NTSTATUS
  1889. NTAPI
  1890. LsaFreeMemory(
  1891. IN PVOID Buffer
  1892. );
  1893. NTSTATUS
  1894. NTAPI
  1895. LsaClose(
  1896. IN LSA_HANDLE ObjectHandle
  1897. );
  1898. // end_ntsecapi
  1899. NTSTATUS
  1900. NTAPI
  1901. LsaDelete(
  1902. IN LSA_HANDLE ObjectHandle
  1903. );
  1904. NTSTATUS
  1905. NTAPI
  1906. LsaQuerySecurityObject(
  1907. IN LSA_HANDLE ObjectHandle,
  1908. IN SECURITY_INFORMATION SecurityInformation,
  1909. OUT PSECURITY_DESCRIPTOR *SecurityDescriptor
  1910. );
  1911. NTSTATUS
  1912. NTAPI
  1913. LsaSetSecurityObject(
  1914. IN LSA_HANDLE ObjectHandle,
  1915. IN SECURITY_INFORMATION SecurityInformation,
  1916. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  1917. );
  1918. NTSTATUS
  1919. NTAPI
  1920. LsaChangePassword(
  1921. IN PLSA_UNICODE_STRING ServerName,
  1922. IN PLSA_UNICODE_STRING DomainName,
  1923. IN PLSA_UNICODE_STRING AccountName,
  1924. IN PLSA_UNICODE_STRING OldPassword,
  1925. IN PLSA_UNICODE_STRING NewPassword
  1926. );
  1927. // begin_ntsecapi
  1928. typedef struct _SECURITY_LOGON_SESSION_DATA {
  1929. ULONG Size ;
  1930. LUID LogonId ;
  1931. LSA_UNICODE_STRING UserName ;
  1932. LSA_UNICODE_STRING LogonDomain ;
  1933. LSA_UNICODE_STRING AuthenticationPackage ;
  1934. ULONG LogonType ;
  1935. ULONG Session ;
  1936. PSID Sid ;
  1937. LARGE_INTEGER LogonTime ;
  1938. //
  1939. // new for whistler:
  1940. //
  1941. LSA_UNICODE_STRING LogonServer ;
  1942. LSA_UNICODE_STRING DnsDomainName ;
  1943. LSA_UNICODE_STRING Upn ;
  1944. } SECURITY_LOGON_SESSION_DATA, * PSECURITY_LOGON_SESSION_DATA ;
  1945. NTSTATUS
  1946. NTAPI
  1947. LsaEnumerateLogonSessions(
  1948. OUT PULONG LogonSessionCount,
  1949. OUT PLUID * LogonSessionList
  1950. );
  1951. NTSTATUS
  1952. NTAPI
  1953. LsaGetLogonSessionData(
  1954. IN PLUID LogonId,
  1955. OUT PSECURITY_LOGON_SESSION_DATA * ppLogonSessionData
  1956. );
  1957. // end_ntsecapi
  1958. ///////////////////////////////////////////////////////////////////////////////
  1959. // //
  1960. // Local Security Policy - Policy Object API function prototypes //
  1961. // //
  1962. ///////////////////////////////////////////////////////////////////////////////
  1963. // begin_ntsecapi
  1964. NTSTATUS
  1965. NTAPI
  1966. LsaOpenPolicy(
  1967. IN PLSA_UNICODE_STRING SystemName OPTIONAL,
  1968. IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
  1969. IN ACCESS_MASK DesiredAccess,
  1970. IN OUT PLSA_HANDLE PolicyHandle
  1971. );
  1972. // end_ntsecapi
  1973. NTSTATUS
  1974. NTAPI
  1975. LsaOpenPolicySce(
  1976. IN PLSA_UNICODE_STRING SystemName OPTIONAL,
  1977. IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
  1978. IN ACCESS_MASK DesiredAccess,
  1979. IN OUT PLSA_HANDLE PolicyHandle
  1980. );
  1981. // begin_ntsecapi
  1982. NTSTATUS
  1983. NTAPI
  1984. LsaQueryInformationPolicy(
  1985. IN LSA_HANDLE PolicyHandle,
  1986. IN POLICY_INFORMATION_CLASS InformationClass,
  1987. OUT PVOID *Buffer
  1988. );
  1989. NTSTATUS
  1990. NTAPI
  1991. LsaSetInformationPolicy(
  1992. IN LSA_HANDLE PolicyHandle,
  1993. IN POLICY_INFORMATION_CLASS InformationClass,
  1994. IN PVOID Buffer
  1995. );
  1996. NTSTATUS
  1997. NTAPI
  1998. LsaQueryDomainInformationPolicy(
  1999. IN LSA_HANDLE PolicyHandle,
  2000. IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
  2001. OUT PVOID *Buffer
  2002. );
  2003. NTSTATUS
  2004. NTAPI
  2005. LsaSetDomainInformationPolicy(
  2006. IN LSA_HANDLE PolicyHandle,
  2007. IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
  2008. IN PVOID Buffer
  2009. );
  2010. NTSTATUS
  2011. NTAPI
  2012. LsaRegisterPolicyChangeNotification(
  2013. IN POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
  2014. IN HANDLE NotificationEventHandle
  2015. );
  2016. NTSTATUS
  2017. NTAPI
  2018. LsaUnregisterPolicyChangeNotification(
  2019. IN POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
  2020. IN HANDLE NotificationEventHandle
  2021. );
  2022. // end_ntsecapi
  2023. NTSTATUS
  2024. NTAPI
  2025. LsaClearAuditLog(
  2026. IN LSA_HANDLE PolicyHandle
  2027. );
  2028. NTSTATUS
  2029. NTAPI
  2030. LsaCreateAccount(
  2031. IN LSA_HANDLE PolicyHandle,
  2032. IN PSID AccountSid,
  2033. IN ACCESS_MASK DesiredAccess,
  2034. OUT PLSA_HANDLE AccountHandle
  2035. );
  2036. NTSTATUS
  2037. NTAPI
  2038. LsaEnumerateAccounts(
  2039. IN LSA_HANDLE PolicyHandle,
  2040. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  2041. OUT PVOID *EnumerationBuffer,
  2042. IN ULONG PreferedMaximumLength,
  2043. OUT PULONG CountReturned
  2044. );
  2045. NTSTATUS
  2046. NTAPI
  2047. LsaCreateTrustedDomain(
  2048. IN LSA_HANDLE PolicyHandle,
  2049. IN PLSA_TRUST_INFORMATION TrustedDomainInformation,
  2050. IN ACCESS_MASK DesiredAccess,
  2051. OUT PLSA_HANDLE TrustedDomainHandle
  2052. );
  2053. // begin_ntsecapi
  2054. NTSTATUS
  2055. NTAPI
  2056. LsaEnumerateTrustedDomains(
  2057. IN LSA_HANDLE PolicyHandle,
  2058. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  2059. OUT PVOID *Buffer,
  2060. IN ULONG PreferedMaximumLength,
  2061. OUT PULONG CountReturned
  2062. );
  2063. // end_ntsecapi
  2064. NTSTATUS
  2065. NTAPI
  2066. LsaEnumeratePrivileges(
  2067. IN LSA_HANDLE PolicyHandle,
  2068. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  2069. OUT PVOID *Buffer,
  2070. IN ULONG PreferedMaximumLength,
  2071. OUT PULONG CountReturned
  2072. );
  2073. // begin_ntsecapi
  2074. NTSTATUS
  2075. NTAPI
  2076. LsaLookupNames(
  2077. IN LSA_HANDLE PolicyHandle,
  2078. IN ULONG Count,
  2079. IN PLSA_UNICODE_STRING Names,
  2080. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  2081. OUT PLSA_TRANSLATED_SID *Sids
  2082. );
  2083. NTSTATUS
  2084. NTAPI
  2085. LsaLookupNames2(
  2086. IN LSA_HANDLE PolicyHandle,
  2087. IN ULONG Flags, // Reserved
  2088. IN ULONG Count,
  2089. IN PLSA_UNICODE_STRING Names,
  2090. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  2091. OUT PLSA_TRANSLATED_SID2 *Sids
  2092. );
  2093. NTSTATUS
  2094. NTAPI
  2095. LsaLookupSids(
  2096. IN LSA_HANDLE PolicyHandle,
  2097. IN ULONG Count,
  2098. IN PSID *Sids,
  2099. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  2100. OUT PLSA_TRANSLATED_NAME *Names
  2101. );
  2102. // end_ntsecapi
  2103. NTSTATUS
  2104. NTAPI
  2105. LsaCreateSecret(
  2106. IN LSA_HANDLE PolicyHandle,
  2107. IN PLSA_UNICODE_STRING SecretName,
  2108. IN ACCESS_MASK DesiredAccess,
  2109. OUT PLSA_HANDLE SecretHandle
  2110. );
  2111. ///////////////////////////////////////////////////////////////////////////////
  2112. // //
  2113. // Local Security Policy - Account Object API function prototypes //
  2114. // //
  2115. ///////////////////////////////////////////////////////////////////////////////
  2116. NTSTATUS
  2117. NTAPI
  2118. LsaOpenAccount(
  2119. IN LSA_HANDLE PolicyHandle,
  2120. IN PSID AccountSid,
  2121. IN ACCESS_MASK DesiredAccess,
  2122. OUT PLSA_HANDLE AccountHandle
  2123. );
  2124. NTSTATUS
  2125. NTAPI
  2126. LsaEnumeratePrivilegesOfAccount(
  2127. IN LSA_HANDLE AccountHandle,
  2128. OUT PPRIVILEGE_SET *Privileges
  2129. );
  2130. NTSTATUS
  2131. NTAPI
  2132. LsaAddPrivilegesToAccount(
  2133. IN LSA_HANDLE AccountHandle,
  2134. IN PPRIVILEGE_SET Privileges
  2135. );
  2136. NTSTATUS
  2137. NTAPI
  2138. LsaRemovePrivilegesFromAccount(
  2139. IN LSA_HANDLE AccountHandle,
  2140. IN BOOLEAN AllPrivileges,
  2141. IN PPRIVILEGE_SET Privileges
  2142. );
  2143. NTSTATUS
  2144. NTAPI
  2145. LsaGetQuotasForAccount(
  2146. IN LSA_HANDLE AccountHandle,
  2147. OUT PQUOTA_LIMITS QuotaLimits
  2148. );
  2149. NTSTATUS
  2150. NTAPI
  2151. LsaSetQuotasForAccount(
  2152. IN LSA_HANDLE AccountHandle,
  2153. IN PQUOTA_LIMITS QuotaLimits
  2154. );
  2155. NTSTATUS
  2156. NTAPI
  2157. LsaGetSystemAccessAccount(
  2158. IN LSA_HANDLE AccountHandle,
  2159. OUT PULONG SystemAccess
  2160. );
  2161. NTSTATUS
  2162. NTAPI
  2163. LsaSetSystemAccessAccount(
  2164. IN LSA_HANDLE AccountHandle,
  2165. IN ULONG SystemAccess
  2166. );
  2167. ///////////////////////////////////////////////////////////////////////////////
  2168. // //
  2169. // Local Security Policy - Trusted Domain Object API function prototypes //
  2170. // //
  2171. ///////////////////////////////////////////////////////////////////////////////
  2172. NTSTATUS
  2173. NTAPI
  2174. LsaOpenTrustedDomain(
  2175. IN LSA_HANDLE PolicyHandle,
  2176. IN PSID TrustedDomainSid,
  2177. IN ACCESS_MASK DesiredAccess,
  2178. OUT PLSA_HANDLE TrustedDomainHandle
  2179. );
  2180. NTSTATUS
  2181. NTAPI
  2182. LsaQueryInfoTrustedDomain(
  2183. IN LSA_HANDLE TrustedDomainHandle,
  2184. IN TRUSTED_INFORMATION_CLASS InformationClass,
  2185. OUT PVOID *Buffer
  2186. );
  2187. NTSTATUS
  2188. NTAPI
  2189. LsaSetInformationTrustedDomain(
  2190. IN LSA_HANDLE TrustedDomainHandle,
  2191. IN TRUSTED_INFORMATION_CLASS InformationClass,
  2192. IN PVOID Buffer
  2193. );
  2194. ///////////////////////////////////////////////////////////////////////////////
  2195. // //
  2196. // Local Security Policy - Secret Object API function prototypes //
  2197. // //
  2198. ///////////////////////////////////////////////////////////////////////////////
  2199. NTSTATUS
  2200. NTAPI
  2201. LsaOpenSecret(
  2202. IN LSA_HANDLE PolicyHandle,
  2203. IN PLSA_UNICODE_STRING SecretName,
  2204. IN ACCESS_MASK DesiredAccess,
  2205. OUT PLSA_HANDLE SecretHandle
  2206. );
  2207. NTSTATUS
  2208. NTAPI
  2209. LsaSetSecret(
  2210. IN LSA_HANDLE SecretHandle,
  2211. IN OPTIONAL PLSA_UNICODE_STRING CurrentValue,
  2212. IN OPTIONAL PLSA_UNICODE_STRING OldValue
  2213. );
  2214. NTSTATUS
  2215. NTAPI
  2216. LsaQuerySecret(
  2217. IN LSA_HANDLE SecretHandle,
  2218. OUT OPTIONAL PLSA_UNICODE_STRING *CurrentValue,
  2219. OUT OPTIONAL PLARGE_INTEGER CurrentValueSetTime,
  2220. OUT OPTIONAL PLSA_UNICODE_STRING *OldValue,
  2221. OUT OPTIONAL PLARGE_INTEGER OldValueSetTime
  2222. );
  2223. /////////////////////////////////////////////////////////////////////////
  2224. // //
  2225. // Local Security Policy - Privilege Object API Prototypes //
  2226. // //
  2227. /////////////////////////////////////////////////////////////////////////
  2228. NTSTATUS
  2229. NTAPI
  2230. LsaLookupPrivilegeValue(
  2231. IN LSA_HANDLE PolicyHandle,
  2232. IN PLSA_UNICODE_STRING Name,
  2233. OUT PLUID Value
  2234. );
  2235. NTSTATUS
  2236. NTAPI
  2237. LsaLookupPrivilegeName(
  2238. IN LSA_HANDLE PolicyHandle,
  2239. IN PLUID Value,
  2240. OUT PLSA_UNICODE_STRING *Name
  2241. );
  2242. NTSTATUS
  2243. NTAPI
  2244. LsaLookupPrivilegeDisplayName(
  2245. IN LSA_HANDLE PolicyHandle,
  2246. IN PLSA_UNICODE_STRING Name,
  2247. OUT PLSA_UNICODE_STRING *DisplayName,
  2248. OUT PSHORT LanguageReturned
  2249. );
  2250. /////////////////////////////////////////////////////////////////////////
  2251. // //
  2252. // Local Security Policy - New APIs for NT 4.0 (SUR release) //
  2253. // //
  2254. /////////////////////////////////////////////////////////////////////////
  2255. NTSTATUS
  2256. LsaGetUserName(
  2257. OUT PLSA_UNICODE_STRING * UserName,
  2258. OUT OPTIONAL PLSA_UNICODE_STRING * DomainName
  2259. );
  2260. NTSTATUS
  2261. LsaGetRemoteUserName(
  2262. IN OPTIONAL PLSA_UNICODE_STRING SystemName,
  2263. OUT PLSA_UNICODE_STRING * UserName,
  2264. OUT OPTIONAL PLSA_UNICODE_STRING * DomainName
  2265. );
  2266. /////////////////////////////////////////////////////////////////////////
  2267. // //
  2268. // Local Security Policy - New APIs for NT 3.51 (PPC release) //
  2269. // //
  2270. /////////////////////////////////////////////////////////////////////////
  2271. // begin_ntsecapi
  2272. #define SE_INTERACTIVE_LOGON_NAME TEXT("SeInteractiveLogonRight")
  2273. #define SE_NETWORK_LOGON_NAME TEXT("SeNetworkLogonRight")
  2274. #define SE_BATCH_LOGON_NAME TEXT("SeBatchLogonRight")
  2275. #define SE_SERVICE_LOGON_NAME TEXT("SeServiceLogonRight")
  2276. #define SE_DENY_INTERACTIVE_LOGON_NAME TEXT("SeDenyInteractiveLogonRight")
  2277. #define SE_DENY_NETWORK_LOGON_NAME TEXT("SeDenyNetworkLogonRight")
  2278. #define SE_DENY_BATCH_LOGON_NAME TEXT("SeDenyBatchLogonRight")
  2279. #define SE_DENY_SERVICE_LOGON_NAME TEXT("SeDenyServiceLogonRight")
  2280. #define SE_REMOTE_INTERACTIVE_LOGON_NAME TEXT("SeRemoteInteractiveLogonRight")
  2281. #define SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME TEXT("SeDenyRemoteInteractiveLogonRight")
  2282. //
  2283. // This new API returns all the accounts with a certain privilege
  2284. //
  2285. NTSTATUS
  2286. NTAPI
  2287. LsaEnumerateAccountsWithUserRight(
  2288. IN LSA_HANDLE PolicyHandle,
  2289. IN OPTIONAL PLSA_UNICODE_STRING UserRights,
  2290. OUT PVOID *EnumerationBuffer,
  2291. OUT PULONG CountReturned
  2292. );
  2293. //
  2294. // These new APIs differ by taking a SID instead of requiring the caller
  2295. // to open the account first and passing in an account handle
  2296. //
  2297. NTSTATUS
  2298. NTAPI
  2299. LsaEnumerateAccountRights(
  2300. IN LSA_HANDLE PolicyHandle,
  2301. IN PSID AccountSid,
  2302. OUT PLSA_UNICODE_STRING *UserRights,
  2303. OUT PULONG CountOfRights
  2304. );
  2305. NTSTATUS
  2306. NTAPI
  2307. LsaAddAccountRights(
  2308. IN LSA_HANDLE PolicyHandle,
  2309. IN PSID AccountSid,
  2310. IN PLSA_UNICODE_STRING UserRights,
  2311. IN ULONG CountOfRights
  2312. );
  2313. NTSTATUS
  2314. NTAPI
  2315. LsaRemoveAccountRights(
  2316. IN LSA_HANDLE PolicyHandle,
  2317. IN PSID AccountSid,
  2318. IN BOOLEAN AllRights,
  2319. IN PLSA_UNICODE_STRING UserRights,
  2320. IN ULONG CountOfRights
  2321. );
  2322. ///////////////////////////////////////////////////////////////////////////////
  2323. // //
  2324. // Local Security Policy - Trusted Domain Object API function prototypes //
  2325. // //
  2326. ///////////////////////////////////////////////////////////////////////////////
  2327. NTSTATUS
  2328. NTAPI
  2329. LsaOpenTrustedDomainByName(
  2330. IN LSA_HANDLE PolicyHandle,
  2331. IN PLSA_UNICODE_STRING TrustedDomainName,
  2332. IN ACCESS_MASK DesiredAccess,
  2333. OUT PLSA_HANDLE TrustedDomainHandle
  2334. );
  2335. NTSTATUS
  2336. NTAPI
  2337. LsaQueryTrustedDomainInfo(
  2338. IN LSA_HANDLE PolicyHandle,
  2339. IN PSID TrustedDomainSid,
  2340. IN TRUSTED_INFORMATION_CLASS InformationClass,
  2341. OUT PVOID *Buffer
  2342. );
  2343. NTSTATUS
  2344. NTAPI
  2345. LsaSetTrustedDomainInformation(
  2346. IN LSA_HANDLE PolicyHandle,
  2347. IN PSID TrustedDomainSid,
  2348. IN TRUSTED_INFORMATION_CLASS InformationClass,
  2349. IN PVOID Buffer
  2350. );
  2351. NTSTATUS
  2352. NTAPI
  2353. LsaDeleteTrustedDomain(
  2354. IN LSA_HANDLE PolicyHandle,
  2355. IN PSID TrustedDomainSid
  2356. );
  2357. NTSTATUS
  2358. NTAPI
  2359. LsaQueryTrustedDomainInfoByName(
  2360. IN LSA_HANDLE PolicyHandle,
  2361. IN PLSA_UNICODE_STRING TrustedDomainName,
  2362. IN TRUSTED_INFORMATION_CLASS InformationClass,
  2363. OUT PVOID *Buffer
  2364. );
  2365. NTSTATUS
  2366. NTAPI
  2367. LsaSetTrustedDomainInfoByName(
  2368. IN LSA_HANDLE PolicyHandle,
  2369. IN PLSA_UNICODE_STRING TrustedDomainName,
  2370. IN TRUSTED_INFORMATION_CLASS InformationClass,
  2371. IN PVOID Buffer
  2372. );
  2373. NTSTATUS
  2374. NTAPI
  2375. LsaEnumerateTrustedDomainsEx(
  2376. IN LSA_HANDLE PolicyHandle,
  2377. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  2378. OUT PVOID *Buffer,
  2379. IN ULONG PreferedMaximumLength,
  2380. OUT PULONG CountReturned
  2381. );
  2382. NTSTATUS
  2383. NTAPI
  2384. LsaCreateTrustedDomainEx(
  2385. IN LSA_HANDLE PolicyHandle,
  2386. IN PTRUSTED_DOMAIN_INFORMATION_EX TrustedDomainInformation,
  2387. IN PTRUSTED_DOMAIN_AUTH_INFORMATION AuthenticationInformation,
  2388. IN ACCESS_MASK DesiredAccess,
  2389. OUT PLSA_HANDLE TrustedDomainHandle
  2390. );
  2391. NTSTATUS
  2392. NTAPI
  2393. LsaQueryForestTrustInformation(
  2394. IN LSA_HANDLE PolicyHandle,
  2395. IN PLSA_UNICODE_STRING TrustedDomainName,
  2396. OUT PLSA_FOREST_TRUST_INFORMATION * ForestTrustInfo
  2397. );
  2398. NTSTATUS
  2399. NTAPI
  2400. LsaSetForestTrustInformation(
  2401. IN LSA_HANDLE PolicyHandle,
  2402. IN PLSA_UNICODE_STRING TrustedDomainName,
  2403. IN PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
  2404. IN BOOLEAN CheckOnly,
  2405. OUT PLSA_FOREST_TRUST_COLLISION_INFORMATION * CollisionInfo
  2406. );
  2407. // #define TESTING_MATCHING_ROUTINE
  2408. #ifdef TESTING_MATCHING_ROUTINE
  2409. NTSTATUS
  2410. NTAPI
  2411. LsaForestTrustFindMatch(
  2412. IN LSA_HANDLE PolicyHandle,
  2413. IN ULONG Type,
  2414. IN PLSA_UNICODE_STRING Name,
  2415. OUT PLSA_UNICODE_STRING * Match
  2416. );
  2417. #endif
  2418. //
  2419. // This API sets the workstation password (equivalent of setting/getting
  2420. // the SSI_SECRET_NAME secret)
  2421. //
  2422. NTSTATUS
  2423. NTAPI
  2424. LsaStorePrivateData(
  2425. IN LSA_HANDLE PolicyHandle,
  2426. IN PLSA_UNICODE_STRING KeyName,
  2427. IN PLSA_UNICODE_STRING PrivateData
  2428. );
  2429. NTSTATUS
  2430. NTAPI
  2431. LsaRetrievePrivateData(
  2432. IN LSA_HANDLE PolicyHandle,
  2433. IN PLSA_UNICODE_STRING KeyName,
  2434. OUT PLSA_UNICODE_STRING * PrivateData
  2435. );
  2436. ULONG
  2437. NTAPI
  2438. LsaNtStatusToWinError(
  2439. NTSTATUS Status
  2440. );
  2441. //
  2442. // Define a symbol so we can tell if ntifs.h has been included.
  2443. //
  2444. // begin_ntifs
  2445. #ifndef _NTLSA_IFS_
  2446. #define _NTLSA_IFS_
  2447. #endif
  2448. // end_ntifs
  2449. //
  2450. // SPNEGO package stuff
  2451. //
  2452. enum NEGOTIATE_MESSAGES {
  2453. NegEnumPackagePrefixes = 0,
  2454. NegGetCallerName = 1,
  2455. NegCallPackageMax
  2456. } ;
  2457. #define NEGOTIATE_MAX_PREFIX 32
  2458. typedef struct _NEGOTIATE_PACKAGE_PREFIX {
  2459. ULONG_PTR PackageId ;
  2460. PVOID PackageDataA ;
  2461. PVOID PackageDataW ;
  2462. ULONG_PTR PrefixLen ;
  2463. UCHAR Prefix[ NEGOTIATE_MAX_PREFIX ];
  2464. } NEGOTIATE_PACKAGE_PREFIX, * PNEGOTIATE_PACKAGE_PREFIX ;
  2465. typedef struct _NEGOTIATE_PACKAGE_PREFIXES {
  2466. ULONG MessageType ;
  2467. ULONG PrefixCount ;
  2468. ULONG Offset ; // Offset to array of _PREFIX above
  2469. ULONG Pad ; // Align structure for 64-bit
  2470. } NEGOTIATE_PACKAGE_PREFIXES, *PNEGOTIATE_PACKAGE_PREFIXES ;
  2471. typedef struct _NEGOTIATE_CALLER_NAME_REQUEST {
  2472. ULONG MessageType ;
  2473. LUID LogonId ;
  2474. } NEGOTIATE_CALLER_NAME_REQUEST, *PNEGOTIATE_CALLER_NAME_REQUEST ;
  2475. typedef struct _NEGOTIATE_CALLER_NAME_RESPONSE {
  2476. ULONG MessageType ;
  2477. PWSTR CallerName ;
  2478. } NEGOTIATE_CALLER_NAME_RESPONSE, * PNEGOTIATE_CALLER_NAME_RESPONSE ;
  2479. // end_ntsecapi
  2480. #define NEGOTIATE_ALLOW_NTLM 0x10000000
  2481. #define NEGOTIATE_NEG_NTLM 0x20000000
  2482. //
  2483. // Define parallel structures for WOW64 environment. These
  2484. // *must* stay in sync with their complements above.
  2485. //
  2486. typedef struct _NEGOTIATE_PACKAGE_PREFIX_WOW {
  2487. ULONG PackageId ;
  2488. ULONG PackageDataA ;
  2489. ULONG PackageDataW ;
  2490. ULONG PrefixLen ;
  2491. UCHAR Prefix[ NEGOTIATE_MAX_PREFIX ];
  2492. } NEGOTIATE_PACKAGE_PREFIX_WOW, * PNEGOTIATE_PACKAGE_PREFIX_WOW ;
  2493. typedef struct _NEGOTIATE_CALLER_NAME_RESPONSE_WOW {
  2494. ULONG MessageType ;
  2495. ULONG CallerName ;
  2496. } NEGOTIATE_CALLER_NAME_RESPONSE_WOW, * PNEGOTIATE_CALLER_NAME_RESPONSE_WOW ;
  2497. NTSTATUS
  2498. NTAPI
  2499. LsaSetPolicyReplicationHandle(
  2500. IN OUT PLSA_HANDLE PolicyHandle
  2501. );
  2502. #ifdef __cplusplus
  2503. }
  2504. #endif
  2505. #endif // _NTLSA_