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.

1488 lines
38 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. dbp.h
  5. Abstract:
  6. LSA Database Private Functions, Datatypes and Defines
  7. Author:
  8. Scott Birrell (ScottBi) May 29, 1991
  9. Environment:
  10. Revision History:
  11. --*/
  12. #ifndef _LSADBP_
  13. #define _LSADBP_
  14. #ifndef DBP_TYPES_ONLY
  15. #include <dsp.h>
  16. #endif
  17. #include <safelock.h>
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif // __cplusplus
  21. //
  22. // LSA revisions
  23. //
  24. // NT 1.0 (3.1) ==> 1.0
  25. // NT 1.0A (3.5) ==> 1.1
  26. // NT 4.0, SP 4 ==> 1.2
  27. // Win2K B3 ==> 1.4
  28. // Win2K ==> 1.5
  29. // Whistler Preview ==> 1.6
  30. // Whistler Preview ==> 1.7
  31. //
  32. #define LSAP_DB_REVISION_1_0 0x00010000
  33. #define LSAP_DB_REVISION_1_1 0x00010001
  34. #define LSAP_DB_REVISION_1_2 0x00010002
  35. #define LSAP_DB_REVISION_1_3 0x00010003
  36. #define LSAP_DB_REVISION_1_4 0x00010004
  37. #define LSAP_DB_REVISION_1_5 0x00010005
  38. #define LSAP_DB_REVISION_1_6 0x00010006
  39. #define LSAP_DB_REVISION_1_7 0x00010007
  40. #define LSAP_DB_REVISION LSAP_DB_REVISION_1_7
  41. #ifndef RPC_C_AUTHN_NETLOGON
  42. #define RPC_C_AUTHN_NETLOGON 0x44
  43. #endif // RPC_C_AUTHN_NETLOGON
  44. //
  45. // Uncomment the define LSA_SAM_ACCOUNTS_DOMAIN_TEST to enable the
  46. // code needed for the ctsamdb test program. Recompile dbsamtst.c,
  47. // dbpolicy.c. rebuild lsasrv.dll and nmake UMTYPE=console UMTEST=ctsamdb.
  48. //
  49. // #define LSA_SAM_ACCOUNTS_DOMAIN_TEST
  50. //
  51. //
  52. // Prefered Maximum Length of data used for internal enumerations.
  53. //
  54. #define LSAP_DB_ENUM_DOMAIN_LENGTH ((ULONG) 0x00000100L)
  55. //
  56. // Write operations are not allowed on Backup controllers (except
  57. // for trusted clients).
  58. //
  59. #define LSAP_POLICY_WRITE_OPS (DELETE |\
  60. WRITE_OWNER |\
  61. WRITE_DAC |\
  62. POLICY_TRUST_ADMIN |\
  63. POLICY_CREATE_ACCOUNT |\
  64. POLICY_CREATE_SECRET |\
  65. POLICY_CREATE_PRIVILEGE |\
  66. POLICY_SET_DEFAULT_QUOTA_LIMITS |\
  67. POLICY_SET_AUDIT_REQUIREMENTS |\
  68. POLICY_AUDIT_LOG_ADMIN |\
  69. POLICY_SERVER_ADMIN)
  70. #define LSAP_ACCOUNT_WRITE_OPS (DELETE |\
  71. WRITE_OWNER |\
  72. WRITE_DAC |\
  73. ACCOUNT_ADJUST_PRIVILEGES |\
  74. ACCOUNT_ADJUST_QUOTAS |\
  75. ACCOUNT_ADJUST_SYSTEM_ACCESS)
  76. #define LSAP_TRUSTED_WRITE_OPS (DELETE |\
  77. WRITE_OWNER |\
  78. WRITE_DAC |\
  79. TRUSTED_SET_CONTROLLERS |\
  80. TRUSTED_SET_POSIX |\
  81. TRUSTED_SET_AUTH )
  82. #define LSAP_SECRET_WRITE_OPS (DELETE |\
  83. WRITE_OWNER |\
  84. WRITE_DAC |\
  85. SECRET_SET_VALUE)
  86. //
  87. // Maximum number of attributes an object can have
  88. //
  89. #define LSAP_DB_MAX_ATTRIBUTES (0x00000020)
  90. //
  91. // Flags that determine some of the behavior of the EnumerateTrustedDomainsEx call
  92. //
  93. #define LSAP_DB_ENUMERATE_NO_OPTIONS 0x00000000
  94. #define LSAP_DB_ENUMERATE_AS_NT4 0x00000001
  95. #define LSAP_DB_ENUMERATE_NULL_SIDS 0x00000002
  96. #define LSAP_DB_ENUMERATE_ALL 0x00000004
  97. //
  98. // Flags that determine some of the behavior of the CreateHandle call
  99. //
  100. #define LSAP_DB_CREATE_OPEN_EXISTING 0x00000001
  101. #define LSAP_DB_CREATE_HANDLE_MORPH 0x00000002
  102. #if defined(REMOTE_BOOT)
  103. //
  104. // On disked remote boot machines, the redirector needs to track changes to
  105. // the machine account password. These flags indicate what state this machine
  106. // is in with respect to that. The choices are:
  107. // - no notification, the machine is not remote boot, or is diskless.
  108. // - can't notify, machine is disked remote boot but the redir can't
  109. // handle a password change notification on this boot.
  110. // - notify, the redir should be told of changes
  111. // NOTE: These values are stored in a CHAR value in LSAP_DB_STATE.
  112. //
  113. #define LSAP_DB_REMOTE_BOOT_NO_NOTIFICATION 0x01
  114. #define LSAP_DB_REMOTE_BOOT_CANT_NOTIFY 0x02
  115. #define LSAP_DB_REMOTE_BOOT_NOTIFY 0x03
  116. #endif // defined(REMOTE_BOOT)
  117. //
  118. // The order of this enum is the order in which locks
  119. // must be acquired. Violating this order will result
  120. // in asserts firing in debug builds.
  121. //
  122. // Do not change the order of this enum without first verifying
  123. // thoroughly that the change is safe.
  124. //
  125. // If you change this enum, update the number of locks passed
  126. // to SafeLockInit() in spinit.cxx
  127. //
  128. typedef enum {
  129. POLICY_CHANGE_NOTIFICATION_LOCK_ENUM = 1,
  130. POLICY_LOCK_ENUM,
  131. TRUST_LOCK_ENUM,
  132. ACCOUNT_LOCK_ENUM,
  133. SECRET_LOCK_ENUM,
  134. REGISTRY_LOCK_ENUM,
  135. HANDLE_TABLE_LOCK_ENUM,
  136. LSAP_FIXUP_LOCK_ENUM,
  137. LOOKUP_WORK_QUEUE_LOCK_ENUM,
  138. THREAD_INFO_LIST_LOCK_ENUM,
  139. POLICY_CACHE_LOCK_ENUM,
  140. } LSAP_LOCK_ENUM;
  141. //
  142. // NOTES on Logical and Physical Names
  143. //
  144. // LogicalName - Unicode String containing the Logical Name of the object.
  145. // The Logical Name of an object is the name by which it is known
  146. // to the outside world, e.g, SCOTTBI might be a typical name for
  147. // a user account object
  148. // PhysicalName - Unicode String containing the Physical name of the object.
  149. // This is a name internal to the Lsa Database and is dependent on the
  150. // implementation. For the current implementation of the LSA Database
  151. // as a subtree of keys within the Configuration Registry, the
  152. // PhysicalName is the name of the Registry Key for the object relative
  153. // to the container object, e.g, ACCOUNTS\SCOTTBI is the Physical Name
  154. // for the user account object with Logical Name SCOTTBI.
  155. //
  156. //
  157. // LSA Database Object Containing Directories
  158. //
  159. extern UNICODE_STRING LsapDbContDirs[DummyLastObject];
  160. typedef enum _LSAP_DB_CACHE_STATE {
  161. LsapDbCacheNotSupported = 1,
  162. LsapDbCacheInvalid,
  163. LsapDbCacheBuilding,
  164. LsapDbCacheValid
  165. } LSAP_DB_CACHE_STATE, *PLSAP_DB_CACHE_STATE;
  166. //
  167. // LSA Database Object Type Structure
  168. //
  169. typedef struct _LSAP_DB_OBJECT_TYPE {
  170. GENERIC_MAPPING GenericMapping;
  171. ULONG ObjectCount;
  172. NTSTATUS ObjectCountError;
  173. ULONG MaximumObjectCount;
  174. ACCESS_MASK WriteOperations;
  175. ACCESS_MASK AliasAdminsAccess;
  176. ACCESS_MASK WorldAccess;
  177. ACCESS_MASK AnonymousLogonAccess;
  178. ACCESS_MASK LocalServiceAccess;
  179. ACCESS_MASK NetworkServiceAccess;
  180. ACCESS_MASK InvalidMappedAccess;
  181. PSID InitialOwnerSid;
  182. BOOLEAN ObjectCountLimited;
  183. BOOLEAN AccessedBySid;
  184. BOOLEAN AccessedByName;
  185. LSAP_DB_CACHE_STATE CacheState;
  186. PVOID ObjectCache;
  187. } LSAP_DB_OBJECT_TYPE, *PLSAP_DB_OBJECT_TYPE;
  188. #define LsapDbMakeCacheUnsupported( ObjectTypeId ) \
  189. \
  190. { \
  191. LsapDbState.DbObjectTypes[ ObjectTypeId ].CacheState = LsapDbCacheNotSupported; \
  192. }
  193. #define LsapDbMakeCacheSupported( ObjectTypeId ) \
  194. \
  195. { \
  196. LsapDbState.DbObjectTypes[ ObjectTypeId ].CacheState = LsapDbCacheInvalid; \
  197. }
  198. #define LsapDbMakeCacheInvalid( ObjectTypeId ) \
  199. \
  200. { \
  201. LsapDbState.DbObjectTypes[ ObjectTypeId ].CacheState = LsapDbCacheInvalid; \
  202. }
  203. #define LsapDbMakeCacheBuilding( ObjectTypeId ) \
  204. \
  205. { \
  206. LsapDbState.DbObjectTypes[ ObjectTypeId ].CacheState = LsapDbCacheBuilding; \
  207. }
  208. #define LsapDbMakeCacheValid( ObjectTypeId ) \
  209. \
  210. { \
  211. LsapDbState.DbObjectTypes[ ObjectTypeId ].CacheState = LsapDbCacheValid; \
  212. }
  213. #define LsapDbIsCacheValid( ObjectTypeId ) \
  214. (LsapDbState.DbObjectTypes[ ObjectTypeId ].CacheState == LsapDbCacheValid)
  215. #define LsapDbIsCacheSupported( ObjectTypeId ) \
  216. (LsapDbState.DbObjectTypes[ ObjectTypeId ].CacheState != LsapDbCacheNotSupported)
  217. #define LsapDbIsCacheBuilding( ObjectTypeId ) \
  218. (LsapDbState.DbObjectTypes[ ObjectTypeId ].CacheState == LsapDbCacheBuilding)
  219. #define LsapDbLockAcquire( lock ) \
  220. SafeEnterCriticalSection( (lock) )
  221. #define LsapDbLockRelease( lock ) \
  222. SafeLeaveCriticalSection( (lock) )
  223. BOOLEAN
  224. LsapDbIsLocked(
  225. IN PSAFE_CRITICAL_SECTION CritSect
  226. );
  227. BOOLEAN
  228. LsapDbResourceIsLocked(
  229. IN PSAFE_RESOURCE Resource
  230. );
  231. VOID
  232. LsapDbAcquireLockEx(
  233. IN LSAP_DB_OBJECT_TYPE_ID ObjectTypeId,
  234. IN ULONG Options
  235. );
  236. VOID
  237. LsapDbReleaseLockEx(
  238. IN LSAP_DB_OBJECT_TYPE_ID ObjectTypeId,
  239. IN ULONG Options
  240. );
  241. NTSTATUS
  242. LsapDbSetStates(
  243. IN ULONG DesiredStates,
  244. IN LSAPR_HANDLE ObjectHandle,
  245. IN LSAP_DB_OBJECT_TYPE_ID ObjectTypeId
  246. );
  247. NTSTATUS
  248. LsapDbResetStates(
  249. IN LSAPR_HANDLE ObjectHandle,
  250. IN ULONG Options,
  251. IN LSAP_DB_OBJECT_TYPE_ID ObjectTypeId,
  252. IN SECURITY_DB_DELTA_TYPE SecurityDbDeltaType,
  253. IN NTSTATUS PreliminaryStatus
  254. );
  255. //
  256. // LSA Database Local State Information. This structure contains various
  257. // global variables containing dynamic state information.
  258. //
  259. typedef struct _LSAP_DB_STATE {
  260. //
  261. //
  262. // LSA's NT 4 replication serial number
  263. //
  264. // Access serialized by RegistryLock.
  265. POLICY_MODIFICATION_INFO PolicyModificationInfo;
  266. //
  267. // Lsa Database Root Dir Reg Key Handle
  268. //
  269. // Initialized at startup (not serialized)
  270. //
  271. HANDLE DbRootRegKeyHandle; // Lsa Database Root Dir Reg Key Handle
  272. // Access serialized by HandleTableLock
  273. ULONG OpenHandleCount;
  274. // Initialized at startup (not serialized)
  275. BOOLEAN DbServerInitialized;
  276. BOOLEAN ReplicatorNotificationEnabled;
  277. // Access serialized by RegistryLock
  278. BOOLEAN RegistryTransactionOpen;
  279. #if defined(REMOTE_BOOT)
  280. CHAR RemoteBootState; // holds LSAP_DB_REMOTE_BOOT_XXX values
  281. #endif // defined(REMOTE_BOOT)
  282. //
  283. // Critical Sections.
  284. //
  285. // These are the crit sects that protect global data.
  286. //
  287. // The order below is the required locking order..
  288. //
  289. SAFE_CRITICAL_SECTION PolicyLock;
  290. SAFE_CRITICAL_SECTION AccountLock;
  291. SAFE_CRITICAL_SECTION SecretLock;
  292. SAFE_CRITICAL_SECTION RegistryLock; // Used to control access to registry transactioning
  293. SAFE_CRITICAL_SECTION HandleTableLock;
  294. SAFE_RESOURCE PolicyCacheLock;
  295. RTL_RESOURCE ScePolicyLock;
  296. HANDLE SceSyncEvent;
  297. // TrustedDomainList->Resource // Locking order comment
  298. // Access serialized by RegistryLock
  299. PRTL_RXACT_CONTEXT RXactContext;
  300. // Access serialized by RegistryLock
  301. ULONG RegistryModificationCount;
  302. // Access not serialized
  303. BOOLEAN EmulateNT4;
  304. //
  305. // Access serialized by object type specific lock.
  306. //
  307. LSAP_DB_OBJECT_TYPE DbObjectTypes[LSAP_DB_OBJECT_TYPE_COUNT];
  308. } LSAP_DB_STATE, *PLSAP_DB_STATE;
  309. //
  310. // Maximum number of SCE policy writers allowed at the same time
  311. //
  312. #define MAX_SCE_WAITING_SHARED 500
  313. extern LSAP_DB_STATE LsapDbState;
  314. #ifdef DBG
  315. extern BOOL g_ScePolicyLocked;
  316. #endif
  317. extern BOOLEAN DcInRootDomain;
  318. //
  319. // LSA Database Private Data. This Data is eligible for replication,
  320. // unlike the Local State Information above which is meaningful on
  321. // the local machine only.
  322. //
  323. typedef struct _LSAP_DB_POLICY_PRIVATE_DATA {
  324. ULONG NoneDefinedYet;
  325. } LSAP_DB_POLICY_PRIVATE_DATA, *PLSAP_DB_POLICY_PRIVATE_DATA;
  326. //
  327. // structure for storing secret encryption keys
  328. //
  329. #include <pshpack1.h>
  330. typedef struct _LSAP_DB_ENCRYPTION_KEY {
  331. ULONG Revision;
  332. ULONG BootType;
  333. ULONG Flags;
  334. GUID Authenticator;
  335. UCHAR Key [16];//128 bit key
  336. UCHAR OldSyskey[16]; // for recovery
  337. UCHAR Salt[16];//128 bit Salt
  338. } LSAP_DB_ENCRYPTION_KEY, *PLSAP_DB_ENCRYPTION_KEY;
  339. #include <poppack.h>
  340. #define LSAP_DB_ENCRYPTION_KEY_VERSION 0x1
  341. extern PLSAP_CR_CIPHER_KEY LsapDbCipherKey;
  342. extern PLSAP_CR_CIPHER_KEY LsapDbSecretCipherKeyRead;
  343. extern PLSAP_CR_CIPHER_KEY LsapDbSecretCipherKeyWrite;
  344. extern PLSAP_CR_CIPHER_KEY LsapDbSP4SecretCipherKey;
  345. extern PVOID LsapDbSysKey;
  346. extern PVOID LsapDbOldSysKey;
  347. //
  348. // Flag to let us know that the secret has been encrypted with syskey, instead of the normal
  349. // cipher key. We store this in the high order of the maximum length of the key
  350. //
  351. #define LSAP_DB_SECRET_SP4_SYSKEY_ENCRYPTED 0x10000000
  352. #define LSAP_DB_SECRET_WIN2K_SYSKEY_ENCRYPTED 0x20000000
  353. #define LsapDbSP4CipheredSecretLength( len ) ( ( len ) & ~LSAP_DB_SECRET_SYSKEY_ENCRYPTED )
  354. #define LsapDbCipheredSecretLength( len ) ( ( len ) & ~(0xF0000000)) // consider top nibble reserved for encryption type.
  355. #define LSAP_BOOT_KEY_RETRY_COUNT 3
  356. #define LSAP_SYSKEY_SIZE 16
  357. //
  358. // Object Enumeration Element Structure
  359. //
  360. typedef struct _LSAP_DB_ENUMERATION_ELEMENT {
  361. struct _LSAP_DB_ENUMERATION_ELEMENT *Next;
  362. LSAP_DB_OBJECT_INFORMATION ObjectInformation;
  363. PSID Sid;
  364. UNICODE_STRING Name;
  365. } LSAP_DB_ENUMERATION_ELEMENT, *PLSAP_DB_ENUMERATION_ELEMENT;
  366. //
  367. // Handle Table Handle Entry
  368. //
  369. typedef struct _LSAP_DB_HANDLE_TABLE_USER_ENTRY {
  370. LIST_ENTRY Next;
  371. LIST_ENTRY PolicyHandles;
  372. LIST_ENTRY ObjectHandles;
  373. ULONG PolicyHandlesCount;
  374. ULONG MaxPolicyHandles ;
  375. LUID LogonId;
  376. HANDLE UserToken;
  377. } LSAP_DB_HANDLE_TABLE_USER_ENTRY, *PLSAP_DB_HANDLE_TABLE_USER_ENTRY;
  378. //
  379. // Handle Table Header Block
  380. //
  381. // One of these structures exists for each Handle Table
  382. //
  383. #define LSAP_DB_HANDLE_FREE_LIST_SIZE 6
  384. typedef struct _LSAP_DB_HANDLE_TABLE {
  385. ULONG UserCount;
  386. LIST_ENTRY UserHandleList;
  387. ULONG FreedUserEntryCount;
  388. PLSAP_DB_HANDLE_TABLE_USER_ENTRY FreedUserEntryList[ LSAP_DB_HANDLE_FREE_LIST_SIZE ];
  389. } LSAP_DB_HANDLE_TABLE, *PLSAP_DB_HANDLE_TABLE;
  390. //
  391. // Conditions on a TDO under which forest trust information may exist
  392. //
  393. BOOLEAN
  394. LsapHavingForestTrustMakesSense(
  395. IN ULONG TrustDirection,
  396. IN ULONG TrustType,
  397. IN ULONG TrustAttributes
  398. );
  399. NTSTATUS
  400. LsapForestTrustInsertLocalInfo(
  401. );
  402. NTSTATUS
  403. LsapForestTrustUnmarshalBlob(
  404. IN ULONG Length,
  405. IN BYTE * Blob,
  406. IN LSA_FOREST_TRUST_RECORD_TYPE HighestRecordType,
  407. OUT PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo
  408. );
  409. NTSTATUS
  410. LsapForestTrustCacheInitialize(
  411. );
  412. NTSTATUS
  413. LsapForestTrustCacheInsert(
  414. IN UNICODE_STRING * TrustedDomainName,
  415. IN PSID TrustedDomainSid OPTIONAL,
  416. IN LSA_FOREST_TRUST_INFORMATION * ForestTrustInfo,
  417. IN BOOLEAN LocalForestEntry
  418. );
  419. NTSTATUS
  420. LsapForestTrustCacheRemove(
  421. IN UNICODE_STRING * TrustedDomainName
  422. );
  423. VOID
  424. LsapFreeForestTrustInfo(
  425. IN PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo
  426. );
  427. VOID
  428. LsapFreeCollisionInfo(
  429. IN OUT PLSA_FOREST_TRUST_COLLISION_INFORMATION * CollisionInfo
  430. );
  431. VOID
  432. LsapForestTrustCacheSetLocalValid();
  433. VOID
  434. LsapForestTrustCacheSetExternalValid();
  435. VOID
  436. LsapForestTrustCacheSetInvalid();
  437. BOOLEAN
  438. LsapForestTrustCacheIsLocalValid();
  439. BOOLEAN
  440. LsapForestTrustCacheIsExternalValid();
  441. NTSTATUS
  442. LsapRebuildFtCacheGC();
  443. NTSTATUS
  444. LsapValidateNetbiosName(
  445. IN const UNICODE_STRING * Name,
  446. OUT BOOLEAN * Valid
  447. );
  448. NTSTATUS
  449. LsapValidateDnsName(
  450. IN const UNICODE_STRING * Name,
  451. OUT BOOLEAN * Valid
  452. );
  453. #ifdef __cplusplus
  454. }
  455. #endif // __cplusplus
  456. ///////////////////////////////////////////////////////////////////////////////
  457. //
  458. // End of Forest Trust Cache definitions
  459. //
  460. ///////////////////////////////////////////////////////////////////////////////
  461. ///////////////////////////////////////////////////////////////////////////////
  462. //
  463. // Easy trust support routines
  464. //
  465. ///////////////////////////////////////////////////////////////////////////////
  466. //
  467. // Determine if caller can create by control access (also enforces creation
  468. // quotas)
  469. //
  470. NTSTATUS
  471. LsapCheckTDOCreationByControlAccess(
  472. IN PLSAP_DB_OBJECT_INFORMATION ObjectInformation,
  473. IN PLSAP_DB_ATTRIBUTE Attributes,
  474. IN ULONG AttributeCount
  475. );
  476. //
  477. // Modify the TDO to reflect the trust was created by control access
  478. //
  479. NTSTATUS
  480. LsapUpdateTDOAttributesForCreation(
  481. IN PUNICODE_STRING ObjectName,
  482. IN PLSAP_DB_ATTRIBUTE Attributes,
  483. IN OUT ULONG* AttributeCount,
  484. IN ULONG AttributesAllocated
  485. );
  486. //
  487. // Enforce delete quotas
  488. //
  489. NTSTATUS
  490. LsapCheckTDODeletionQuotas(
  491. IN LSAP_DB_HANDLE Handle
  492. );
  493. //
  494. // Helpers
  495. //
  496. NTSTATUS
  497. LsapGetCurrentOwnerAndPrimaryGroup(
  498. OUT PTOKEN_OWNER * Owner,
  499. OUT PTOKEN_PRIMARY_GROUP * PrimaryGroup OPTIONAL
  500. );
  501. NTSTATUS
  502. LsapMakeNewSelfRelativeSecurityDescriptor(
  503. IN PSID Owner,
  504. IN PSID Group,
  505. IN PACL Dacl,
  506. IN PACL Sacl,
  507. OUT PULONG SecurityDescriptorLength,
  508. OUT PSECURITY_DESCRIPTOR * SecurityDescriptor
  509. );
  510. ///////////////////////////////////////////////////////////////////////////////
  511. //
  512. // End of Easy trust support routines
  513. //
  514. ///////////////////////////////////////////////////////////////////////////////
  515. //
  516. // Trusted Domain List. This list caches the Trust Information for
  517. // all Trusted Domains in the Policy Database, and enables lookup
  518. // operations to locate Trusted Domains by Sid or Name without recourse
  519. // to the Trusted Domain objects themselves.
  520. //
  521. typedef struct _LSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY {
  522. LIST_ENTRY NextEntry;
  523. LSAPR_TRUSTED_DOMAIN_INFORMATION_EX TrustInfoEx;
  524. LSAPR_TRUST_INFORMATION ConstructedTrustInfo;
  525. ULONG SequenceNumber;
  526. ULONG PosixOffset;
  527. GUID ObjectGuidInDs;
  528. } LSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY, *PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY;
  529. //
  530. // Information used to manage and build the trust tree
  531. //
  532. typedef struct _LSAPDS_FOREST_TRUST_BLOB {
  533. LIST_ENTRY Next;
  534. UNICODE_STRING DomainName;
  535. UNICODE_STRING FlatName;
  536. GUID ObjectGuid;
  537. GUID Parent;
  538. GUID DomainGuid;
  539. PSID DomainSid;
  540. BOOLEAN ForestRoot; // Object is at the root of the forest
  541. BOOLEAN TreeRoot; // Object is at root of a tree
  542. BOOLEAN DomainGuidSet;
  543. BOOLEAN ParentTrust ; // Object is a child of another object
  544. } LSAPDS_FOREST_TRUST_BLOB, *PLSAPDS_FOREST_TRUST_BLOB;
  545. #define LSAPDS_FOREST_MAX_SEARCH_ITEMS 100
  546. //
  547. // List of trusted domains
  548. //
  549. typedef struct _LSAP_DB_TRUSTED_DOMAIN_LIST {
  550. ULONG TrustedDomainCount;
  551. ULONG CurrentSequenceNumber;
  552. LIST_ENTRY ListHead;
  553. SAFE_RESOURCE Resource;
  554. } LSAP_DB_TRUSTED_DOMAIN_LIST, *PLSAP_DB_TRUSTED_DOMAIN_LIST;
  555. //
  556. // Account List. This list caches the Account Information for
  557. // all Account Objects in the Policy database, and enables accounts
  558. // to queried by Sid without recourse to teh Account objects themselves.
  559. //
  560. typedef struct _LSAP_DB_ACCOUNT {
  561. LIST_ENTRY Links;
  562. PLSAPR_SID Sid;
  563. LSAP_DB_ACCOUNT_TYPE_SPECIFIC_INFO Info;
  564. } LSAP_DB_ACCOUNT, *PLSAP_DB_ACCOUNT;
  565. typedef struct _LSAP_DB_ACCOUNT_LIST {
  566. LIST_ENTRY Links;
  567. ULONG AccountCount;
  568. } LSAP_DB_ACCOUNT_LIST, *PLSAP_DB_ACCOUNT_LIST;
  569. //
  570. // Cached information for the Policy Object.
  571. //
  572. typedef struct _LSAP_DB_POLICY_ENTRY {
  573. ULONG AttributeLength;
  574. PLSAPR_POLICY_INFORMATION Attribute;
  575. } LSAP_DB_POLICY_ENTRY, *PLSAP_DB_POLICY_ENTRY;
  576. //
  577. // Cached policy Object - Initially only Quota Limits is cached.
  578. //
  579. typedef struct _LSAP_DB_POLICY {
  580. LSAP_DB_POLICY_ENTRY Info[ PolicyDnsDomainInformationInt + 1];
  581. } LSAP_DB_POLICY, *PLSAP_DB_POLICY;
  582. extern LSAP_DB_POLICY LsapDbPolicy;
  583. //
  584. // Notification list
  585. //
  586. typedef struct _LSAP_POLICY_NOTIFICATION_ENTRY {
  587. LIST_ENTRY List;
  588. pfLsaPolicyChangeNotificationCallback NotificationCallback;
  589. HANDLE NotificationEvent;
  590. ULONG OwnerProcess;
  591. HANDLE OwnerEvent;
  592. BOOLEAN HandleInvalid;
  593. } LSAP_POLICY_NOTIFICATION_ENTRY, *PLSAP_POLICY_NOTIFICATION_ENTRY;
  594. typedef struct _LSAP_POLICY_NOTIFICATION_LIST {
  595. LIST_ENTRY List;
  596. ULONG Callbacks;
  597. } LSAP_POLICY_NOTIFICATION_LIST, *PLSAP_POLICY_NOTIFICATION_LIST;
  598. extern pfLsaTrustChangeNotificationCallback LsapKerberosTrustNotificationFunction;
  599. //
  600. // Types of secrets
  601. //
  602. #define LSAP_DB_SECRET_CLIENT 0x00000000
  603. #define LSAP_DB_SECRET_LOCAL 0x00000001
  604. #define LSAP_DB_SECRET_GLOBAL 0x00000002
  605. #define LSAP_DB_SECRET_SYSTEM 0x00000004
  606. #define LSAP_DB_SECRET_TRUSTED_DOMAIN 0x00000008
  607. typedef struct _LSAP_DB_SECRET_TYPE_LOOKUP {
  608. PWSTR SecretPrefix;
  609. ULONG SecretType;
  610. } LSAP_DB_SECRET_TYPE_LOOKUP, *PLSAP_DB_SECRET_TYPE_LOOKUP;
  611. typedef struct _LSAP_DS_OBJECT_ACCESS_MAP {
  612. ULONG DesiredAccess;
  613. ULONG DsAccessRequired;
  614. USHORT Level;
  615. GUID *ObjectGuid;
  616. } LSAP_DS_OBJECT_ACCESS_MAP, *PLSAP_DS_OBJECT_ACCESS_MAP;
  617. #ifndef DBP_TYPES_ONLY
  618. #ifdef __cplusplus
  619. extern "C" {
  620. #endif // __cplusplus
  621. NTSTATUS
  622. LsapDbQueryInformationPolicy(
  623. IN LSAPR_HANDLE PolicyHandle,
  624. IN POLICY_INFORMATION_CLASS InformationClass,
  625. IN OUT PLSAPR_POLICY_INFORMATION *Buffer
  626. );
  627. NTSTATUS
  628. LsapDbSetInformationPolicy(
  629. IN LSAPR_HANDLE PolicyHandle,
  630. IN POLICY_INFORMATION_CLASS InformationClass,
  631. IN PLSAPR_POLICY_INFORMATION PolicyInformation
  632. );
  633. NTSTATUS
  634. LsapDbSlowQueryInformationPolicy(
  635. IN LSAPR_HANDLE PolicyHandle,
  636. IN POLICY_INFORMATION_CLASS InformationClass,
  637. IN OUT PLSAPR_POLICY_INFORMATION *Buffer
  638. );
  639. NTSTATUS
  640. LsapDbQueryInformationPolicyEx(
  641. IN LSAPR_HANDLE PolicyHandle,
  642. IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
  643. IN OUT PVOID *Buffer
  644. );
  645. NTSTATUS
  646. LsapDbSlowQueryInformationPolicyEx(
  647. IN LSAPR_HANDLE PolicyHandle,
  648. IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
  649. IN OUT PVOID *Buffer
  650. );
  651. NTSTATUS
  652. LsapDbSetInformationPolicyEx(
  653. IN LSAPR_HANDLE PolicyHandle,
  654. IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
  655. IN PVOID PolicyInformation
  656. );
  657. NTSTATUS
  658. LsapDbBuildPolicyCache(
  659. );
  660. NTSTATUS
  661. LsapDbBuildAccountCache(
  662. );
  663. NTSTATUS
  664. LsapDbBuildTrustedDomainCache(
  665. );
  666. VOID
  667. LsapDbPurgeTrustedDomainCache(
  668. );
  669. NTSTATUS
  670. LsapDbBuildSecretCache(
  671. );
  672. NTSTATUS
  673. LsapDbRebuildCache(
  674. IN LSAP_DB_OBJECT_TYPE_ID ObjectTypeId
  675. );
  676. NTSTATUS
  677. LsapDbCreateAccount(
  678. IN PLSAPR_SID AccountSid,
  679. OUT OPTIONAL PLSAP_DB_ACCOUNT *Account
  680. );
  681. NTSTATUS
  682. LsapDbDeleteAccount(
  683. IN PLSAPR_SID AccountSid
  684. );
  685. NTSTATUS
  686. LsapDbSlowEnumerateTrustedDomains(
  687. IN LSAPR_HANDLE PolicyHandle,
  688. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  689. IN TRUSTED_INFORMATION_CLASS InfoClass,
  690. OUT PLSAPR_TRUSTED_ENUM_BUFFER EnumerationBuffer,
  691. IN ULONG PreferedMaximumLength
  692. );
  693. NTSTATUS
  694. LsapDbLookupSidTrustedDomainList(
  695. IN PLSAPR_SID DomainSid,
  696. OUT PLSAPR_TRUST_INFORMATION *TrustInformation
  697. );
  698. NTSTATUS
  699. LsapDbLookupSidTrustedDomainListEx(
  700. IN PSID DomainSid,
  701. OUT PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY *TrustedDomainListEntry
  702. );
  703. NTSTATUS
  704. LsapDbLookupNameTrustedDomainList(
  705. IN PLSAPR_UNICODE_STRING DomainName,
  706. OUT PLSAPR_TRUST_INFORMATION *TrustInformation
  707. );
  708. NTSTATUS
  709. LsapDbLookupNameTrustedDomainListEx(
  710. IN PLSAPR_UNICODE_STRING DomainName,
  711. OUT PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY *TrustedDomainListEntry
  712. );
  713. NTSTATUS
  714. LsapDbLookupEntryTrustedDomainList(
  715. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  716. OUT PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY *TrustedDomainEntry
  717. );
  718. NTSTATUS
  719. LsapDbTraverseTrustedDomainList(
  720. IN OUT PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY *TrustedDomainEntry,
  721. OUT OPTIONAL PLSAPR_TRUST_INFORMATION *TrustInformation
  722. );
  723. NTSTATUS
  724. LsapDbLocateEntryNumberTrustedDomainList(
  725. IN ULONG EntryNumber,
  726. OUT PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY *TrustedDomainEntry,
  727. OUT OPTIONAL PLSAPR_TRUST_INFORMATION *TrustInformation
  728. );
  729. NTSTATUS
  730. LsapDbEnumerateTrustedDomainList(
  731. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  732. OUT PLSAPR_TRUSTED_ENUM_BUFFER EnumerationBuffer,
  733. IN ULONG PreferedMaximumLength,
  734. IN ULONG InfoLevel,
  735. IN BOOLEAN AllowNullSids
  736. );
  737. NTSTATUS
  738. LsapDbInitializeTrustedDomainListEntry(
  739. IN PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY TrustListEntry,
  740. IN PLSAPR_TRUSTED_DOMAIN_INFORMATION_EX2 DomainInfo,
  741. IN ULONG PosixOffset
  742. );
  743. NTSTATUS
  744. LsapDbInsertTrustedDomainList(
  745. IN PLSAPR_TRUSTED_DOMAIN_INFORMATION_EX2 DomainInfo,
  746. IN ULONG PosixOffset
  747. );
  748. NTSTATUS
  749. LsapDbFixupTrustedDomainListEntry(
  750. IN PSID TrustedDomainSid OPTIONAL,
  751. IN PLSAPR_UNICODE_STRING Name OPTIONAL,
  752. IN PLSAPR_UNICODE_STRING FlatName OPTIONAL,
  753. IN PLSAPR_TRUSTED_DOMAIN_INFORMATION_EX2 NewTrustInfo OPTIONAL,
  754. IN PULONG PosixOffset OPTIONAL
  755. );
  756. NTSTATUS
  757. LsapDbDeleteTrustedDomainList(
  758. IN PLSAPR_TRUST_INFORMATION TrustInformation
  759. );
  760. extern LSAP_DB_TRUSTED_DOMAIN_LIST LsapDbTrustedDomainList;
  761. #ifdef DBG
  762. BOOLEAN
  763. LsapDbIsValidTrustedDomainList(
  764. );
  765. #else
  766. #define LsapDbIsValidTrustedDomainList() \
  767. (( LsapDbIsCacheValid( TrustedDomainObject ) || \
  768. ( LsapDbIsCacheBuilding( TrustedDomainObject )) ? TRUE : FALSE ))
  769. #endif
  770. #define LsapDbIsLockedTrustedDomainList() \
  771. ( LsapDbResourceIsLocked( &LsapDbTrustedDomainList.Resource ))
  772. #define LsapDbAcquireWriteLockTrustedDomainList() \
  773. ( SafeAcquireResourceExclusive( \
  774. &LsapDbTrustedDomainList.Resource, \
  775. TRUE ) ? \
  776. STATUS_SUCCESS : STATUS_UNSUCCESSFUL )
  777. #define LsapDbAcquireReadLockTrustedDomainList() \
  778. ( SafeAcquireResourceShared( \
  779. &LsapDbTrustedDomainList.Resource, \
  780. TRUE ) ? \
  781. STATUS_SUCCESS : STATUS_UNSUCCESSFUL )
  782. #define LsapDbReleaseLockTrustedDomainList() \
  783. ( SafeReleaseResource( &LsapDbTrustedDomainList.Resource ))
  784. #define LsapDbConvertReadLockTrustedDomainListToExclusive() \
  785. ( SafeConvertSharedToExclusive( &LsapDbTrustedDomainList.Resource ))
  786. #define LsapDbConvertWriteLockTrustedDomainListToShared() \
  787. ( SafeConvertExclusiveToShared( &LsapDbTrustedDomainList.Resource ))
  788. NTSTATUS
  789. LsapDbAllocatePosixOffsetTrustedDomainList(
  790. OUT PULONG PosixOffset
  791. );
  792. //
  793. // Return TRUE if a TDO with the passed in attributes should have a Posix Offset
  794. //
  795. #define LsapNeedPosixOffset( _TrustDirection, _TrustType ) \
  796. (( ((_TrustDirection) & TRUST_DIRECTION_OUTBOUND) != 0 ) && \
  797. ((_TrustType) == TRUST_TYPE_UPLEVEL || (_TrustType) == TRUST_TYPE_DOWNLEVEL ) )
  798. //
  799. // Return TRUE if TDO is to be replicated to NT 4.
  800. //
  801. #define LsapReplicateTdoNt4( _TrustDirection, _TrustType ) \
  802. LsapNeedPosixOffset( _TrustDirection, _TrustType )
  803. NTSTATUS
  804. LsapDbOpenPolicyTrustedDomain(
  805. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  806. IN ACCESS_MASK DesiredAccess,
  807. OUT PLSA_HANDLE ControllerPolicyHandle,
  808. OUT LPWSTR * ServerName,
  809. OUT LPWSTR * ServerPrincipalName,
  810. OUT PVOID * ClientContext
  811. );
  812. NTSTATUS
  813. LsapDbInitHandleTables(
  814. VOID
  815. );
  816. NTSTATUS
  817. LsapDbInitializeWellKnownPrivs(
  818. );
  819. NTSTATUS
  820. LsapDbInitializeCipherKey(
  821. IN PUNICODE_STRING CipherSeed,
  822. IN PLSAP_CR_CIPHER_KEY *CipherKey
  823. );
  824. NTSTATUS
  825. LsapDbCreateHandle(
  826. IN PLSAP_DB_OBJECT_INFORMATION ObjectInformation,
  827. IN ULONG Options,
  828. IN ULONG CreateHandleOptions,
  829. OUT LSAPR_HANDLE *CreatedHandle
  830. );
  831. BOOLEAN
  832. LsapDbFindIdenticalHandleInTable(
  833. IN OUT PLSAPR_HANDLE OriginalHandle
  834. );
  835. BOOLEAN
  836. LsapDbLookupHandle(
  837. IN LSAPR_HANDLE ObjectHandle
  838. );
  839. NTSTATUS
  840. LsapDbCloseHandle(
  841. IN LSAPR_HANDLE ObjectHandle
  842. );
  843. BOOLEAN
  844. LsapDbDereferenceHandle(
  845. IN LSAPR_HANDLE ObjectHandle,
  846. IN BOOLEAN CalledInSuccessPath
  847. );
  848. NTSTATUS
  849. LsapDbMarkDeletedObjectHandles(
  850. IN LSAPR_HANDLE ObjectHandle,
  851. IN BOOLEAN MarkSelf
  852. );
  853. /*++
  854. BOOLEAN
  855. LsapDbIsTrustedHandle(
  856. IN LSAPR_HANDLE ObjectHandle
  857. )
  858. Routine Description:
  859. This macro function checks if a given handle is Trusted and returns
  860. the result.
  861. Arguments:
  862. ObjectHandle - Valid handle. It is the caller's responsibility
  863. to verify that the given handle is valid.
  864. Return Value:
  865. BOOLEAN - TRUE if handle is Trusted, else FALSE.
  866. --*/
  867. #define LsapDbIsTrustedHandle(ObjectHandle) \
  868. (((LSAP_DB_HANDLE) ObjectHandle)->Trusted)
  869. #define LsapDbSidFromHandle(ObjectHandle) \
  870. ((PLSAPR_SID)(((LSAP_DB_HANDLE)(ObjectHandle))->Sid))
  871. #define LsapDbObjectTypeIdFromHandle(ObjectHandle) \
  872. (((LSAP_DB_HANDLE)(ObjectHandle))->ObjectTypeId)
  873. #define LsapDbRegKeyFromHandle(ObjectHandle) \
  874. (((LSAP_DB_HANDLE)(ObjectHandle))->KeyHandle)
  875. #define LsapDbContainerFromHandle(ObjectHandle) \
  876. (((LSAP_DB_HANDLE) ObjectHandle)->ContainerHandle)
  877. #define LsapDbSetStatusFromSecondary( status, secondary ) \
  878. if ( NT_SUCCESS( status ) ) { \
  879. \
  880. status = secondary; \
  881. }
  882. NTSTATUS
  883. LsapDbRequestAccessObject(
  884. IN OUT LSAPR_HANDLE ObjectHandle,
  885. IN PLSAP_DB_OBJECT_INFORMATION ObjectInformation,
  886. IN ACCESS_MASK DesiredAccess,
  887. IN ULONG Options
  888. );
  889. NTSTATUS
  890. LsapDbRequestAccessNewObject(
  891. IN OUT LSAPR_HANDLE ObjectHandle,
  892. IN PLSAP_DB_OBJECT_INFORMATION ObjectInformation,
  893. IN ACCESS_MASK DesiredAccess,
  894. IN ULONG Options
  895. );
  896. NTSTATUS
  897. LsapDbInitializeObjectTypes();
  898. NTSTATUS
  899. LsapDbInitializeUnicodeNames();
  900. NTSTATUS
  901. LsapDbInitializeContainingDirs();
  902. NTSTATUS
  903. LsapDbInitializeReplication();
  904. NTSTATUS
  905. LsapDbInitializeObjectTypes();
  906. NTSTATUS
  907. LsapDbInitializePrivilegeObject();
  908. NTSTATUS
  909. LsapDbInitializeLock();
  910. NTSTATUS
  911. LsapDbOpenRootRegistryKey();
  912. NTSTATUS
  913. LsapDbInstallLsaDatabase(
  914. IN ULONG Pass
  915. );
  916. NTSTATUS
  917. LsapDbInstallPolicyObject(
  918. IN ULONG Pass
  919. );
  920. NTSTATUS
  921. LsapDbInstallAccountObjects(
  922. VOID
  923. );
  924. NTSTATUS
  925. LsapDbBuildObjectCaches(
  926. );
  927. NTSTATUS
  928. LsapDbNotifyChangeObject(
  929. IN LSAPR_HANDLE ObjectHandle,
  930. IN SECURITY_DB_DELTA_TYPE SecurityDbDeltaType
  931. );
  932. NTSTATUS
  933. LsapDbLogicalToPhysicalSubKey(
  934. IN LSAPR_HANDLE ObjectHandle,
  935. OUT PUNICODE_STRING PhysicalSubKeyNameU,
  936. IN PUNICODE_STRING LogicalSubKeyNameU
  937. );
  938. NTSTATUS
  939. LsapDbJoinSubPaths(
  940. IN PUNICODE_STRING MajorSubPath,
  941. IN PUNICODE_STRING MinorSubPath,
  942. OUT PUNICODE_STRING JoinedPath
  943. );
  944. NTSTATUS
  945. LsapDbGetNamesObject(
  946. IN PLSAP_DB_OBJECT_INFORMATION ObjectInformation,
  947. IN ULONG CreateHandleOptions,
  948. OUT OPTIONAL PUNICODE_STRING LogicalNameU,
  949. OUT OPTIONAL PUNICODE_STRING PhysicalNameU,
  950. OUT OPTIONAL PUNICODE_STRING PhysicalNameDs
  951. );
  952. NTSTATUS
  953. LsapDbCheckCountObject(
  954. IN LSAP_DB_OBJECT_TYPE_ID ObjectTypeId
  955. );
  956. #define LsapDbIncrementCountObject(ObjectTypeId) \
  957. { \
  958. LsapDbState.DbObjectTypes[ObjectTypeId].ObjectCount++; \
  959. }
  960. #define LsapDbDecrementCountObject(ObjectTypeId) \
  961. { \
  962. LsapDbState.DbObjectTypes[ObjectTypeId].ObjectCount--; \
  963. }
  964. NTSTATUS
  965. LsapDbCreateSDObject(
  966. IN LSAPR_HANDLE ContainerHandle,
  967. IN LSAPR_HANDLE ObjectHandle,
  968. OUT PSECURITY_DESCRIPTOR * NewDescriptor
  969. );
  970. NTSTATUS
  971. LsapDbCreateSDAttributeObject(
  972. IN LSAPR_HANDLE ObjectHandle,
  973. IN PLSAP_DB_OBJECT_INFORMATION ObjectInformation
  974. );
  975. NTSTATUS
  976. LsapDbQueryValueSecret(
  977. IN LSAPR_HANDLE SecretHandle,
  978. IN LSAP_DB_NAMES ValueIndex,
  979. IN OPTIONAL PLSAP_CR_CIPHER_KEY SessionKey,
  980. OUT PLSAP_CR_CIPHER_VALUE *CipherValue
  981. );
  982. NTSTATUS
  983. LsapDbGetScopeSecret(
  984. IN PLSAPR_UNICODE_STRING SecretName,
  985. OUT PBOOLEAN GlobalSecret
  986. );
  987. VOID
  988. LsapDbMakeInvalidInformationPolicy(
  989. IN ULONG InformationClass
  990. );
  991. NTSTATUS
  992. LsapDbPhysicalNameFromHandle(
  993. IN LSAPR_HANDLE ObjectHandle,
  994. IN BOOLEAN MakeCopy,
  995. OUT PLSAPR_UNICODE_STRING ObjectName
  996. );
  997. NTSTATUS
  998. LsapEnumerateTrustedDomainsEx(
  999. IN LSAPR_HANDLE PolicyHandle,
  1000. IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
  1001. IN TRUSTED_INFORMATION_CLASS InfoClass,
  1002. OUT PLSAPR_TRUSTED_DOMAIN_INFO *TrustedDomainInformation,
  1003. IN ULONG PreferedMaximumLength,
  1004. OUT PULONG CountReturned,
  1005. IN ULONG EnumerationFlags
  1006. );
  1007. VOID
  1008. LsapFreeTrustedDomainsEx(
  1009. IN TRUSTED_INFORMATION_CLASS InfoClass,
  1010. IN PLSAPR_TRUSTED_DOMAIN_INFO TrustedDomainInformation,
  1011. IN ULONG TrustedDomainCount
  1012. );
  1013. NTSTATUS
  1014. LsapNotifyNetlogonOfTrustChange(
  1015. IN PSID pChangeSid,
  1016. IN SECURITY_DB_DELTA_TYPE ChangeType
  1017. );
  1018. BOOLEAN
  1019. LsapDbSecretIsMachineAcc(
  1020. IN LSAPR_HANDLE SecretHandle
  1021. );
  1022. PLSADS_PER_THREAD_INFO
  1023. LsapCreateThreadInfo(
  1024. VOID
  1025. );
  1026. VOID
  1027. LsapClearThreadInfo(
  1028. VOID
  1029. );
  1030. VOID
  1031. LsapSaveDsThreadState(
  1032. VOID
  1033. );
  1034. VOID
  1035. LsapRestoreDsThreadState(
  1036. VOID
  1037. );
  1038. extern LSADS_INIT_STATE LsaDsInitState ;
  1039. ULONG
  1040. LsapDbGetSecretType(
  1041. IN PLSAPR_UNICODE_STRING SecretName
  1042. );
  1043. NTSTATUS
  1044. LsapDbUpgradeSecretForKeyChange(
  1045. VOID
  1046. );
  1047. NTSTATUS
  1048. LsapDbUpgradeRevision(
  1049. IN BOOLEAN SyskeyUpgrade,
  1050. IN BOOLEAN GenerateNewSyskey
  1051. );
  1052. VOID
  1053. LsapDbEnableReplicatorNotification();
  1054. VOID
  1055. LsapDbDisableReplicatorNotification();
  1056. BOOLEAN
  1057. LsapDbDcInRootDomain();
  1058. BOOLEAN
  1059. LsapDbNoMoreWin2KForest();
  1060. BOOLEAN
  1061. LsapDbNoMoreWin2KDomain();
  1062. //
  1063. // Routines related to Syskey'ing of the LSA Database
  1064. //
  1065. NTSTATUS
  1066. LsapDbGenerateNewKey(
  1067. IN LSAP_DB_ENCRYPTION_KEY * NewEncryptionKey
  1068. );
  1069. VOID
  1070. LsapDbEncryptKeyWithSyskey(
  1071. OUT LSAP_DB_ENCRYPTION_KEY * KeyToEncrypt,
  1072. IN PVOID Syskey,
  1073. IN ULONG SyskeyLength
  1074. );
  1075. NTSTATUS
  1076. LsapDbDecryptKeyWithSyskey(
  1077. IN LSAP_DB_ENCRYPTION_KEY * KeyToDecrypt,
  1078. IN PVOID Syskey,
  1079. IN ULONG SyskeyLength
  1080. );
  1081. NTSTATUS
  1082. LsapDbSetupInitialSyskey(
  1083. OUT PULONG SyskeyLength,
  1084. OUT PVOID *Syskey
  1085. );
  1086. VOID
  1087. LsapDbSetSyskey(PVOID Syskey, ULONG SyskeyLength);
  1088. NTSTATUS
  1089. LsapDbGetSyskeyFromWinlogon();
  1090. NTSTATUS
  1091. LsapForestTrustFindMatch(
  1092. IN LSA_ROUTING_MATCH_TYPE Type,
  1093. IN PVOID Data,
  1094. IN BOOLEAN SearchLocal,
  1095. OUT OPTIONAL PLSA_UNICODE_STRING MatchName,
  1096. OUT OPTIONAL PSID * MatchSid
  1097. );
  1098. NTSTATUS
  1099. LsapRegisterForUpnListNotifications();
  1100. NTSTATUS
  1101. LsapDeleteObject(
  1102. IN OUT LSAPR_HANDLE *ObjectHandle,
  1103. IN BOOL LockSce
  1104. );
  1105. NTSTATUS
  1106. LsapSetSystemAccessAccount(
  1107. IN LSAPR_HANDLE AccountHandle,
  1108. IN ULONG SystemAccess,
  1109. IN BOOL LockSce
  1110. );
  1111. NTSTATUS
  1112. LsapAddPrivilegesToAccount(
  1113. IN LSAPR_HANDLE AccountHandle,
  1114. IN PLSAPR_PRIVILEGE_SET Privileges,
  1115. IN BOOL LockSce
  1116. );
  1117. NTSTATUS
  1118. LsapRemovePrivilegesFromAccount(
  1119. IN LSAPR_HANDLE AccountHandle,
  1120. IN BOOLEAN AllPrivileges,
  1121. IN OPTIONAL PLSAPR_PRIVILEGE_SET Privileges,
  1122. IN BOOL LockSce
  1123. );
  1124. NTSTATUS
  1125. LsapSidOnFtInfo(
  1126. IN PUNICODE_STRING TrustedDomainName,
  1127. IN PSID Sid
  1128. );
  1129. BOOLEAN
  1130. LsapIsRunningOnPersonal(
  1131. VOID
  1132. );
  1133. NTSTATUS
  1134. LsapIsValidDomainSid(
  1135. IN PSID DomainSid
  1136. );
  1137. NTSTATUS
  1138. LsapNotifyNetlogonOfTrustWithParent(
  1139. VOID
  1140. );
  1141. BOOL
  1142. LsapNotifyPrepareToImpersonate(
  1143. IN ULONG Client,
  1144. IN ULONG Server,
  1145. IN VOID **ImpersonateData
  1146. );
  1147. VOID
  1148. LsapNotifyStopImpersonating(
  1149. IN ULONG Client,
  1150. IN ULONG Server,
  1151. IN VOID *ImpersonateData
  1152. );
  1153. PACL LsapGetDacl(
  1154. IN PSECURITY_DESCRIPTOR Sd
  1155. );
  1156. PACL LsapGetSacl(
  1157. IN PSECURITY_DESCRIPTOR Sd
  1158. );
  1159. VOID
  1160. LsapDbInitializeSecretCipherKeyRead(
  1161. PLSAP_DB_ENCRYPTION_KEY PassedInEncryptionKeyData
  1162. );
  1163. VOID
  1164. LsapDbInitializeSecretCipherKeyWrite(
  1165. PLSAP_DB_ENCRYPTION_KEY PassedInEncryptionKeyData
  1166. );
  1167. #ifdef __cplusplus
  1168. }
  1169. #endif // __cplusplus
  1170. #endif
  1171. #endif //_LSADBP_