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

1340 lines
36 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. dblookup.h
  5. Abstract:
  6. LSA Database - Lookup Sid and Name Routine Private Data Definitions.
  7. NOTE: This module should remain as portable code that is independent
  8. of the implementation of the LSA Database. As such, it is
  9. permitted to use only the exported LSA Database interfaces
  10. contained in db.h and NOT the private implementation
  11. dependent functions in dbp.h.
  12. Author:
  13. Scott Birrell (ScottBi) Novwember 27, 1992
  14. Environment:
  15. Revision History:
  16. --*/
  17. #include <safelock.h>
  18. //////////////////////////////////////////////////////////////////////////
  19. // //
  20. // Private Datatypes and Defines //
  21. // //
  22. //////////////////////////////////////////////////////////////////////////
  23. //
  24. // This global controls what events are logged.
  25. // Note each level assumes that previous levels are to be logged too
  26. //
  27. // Current only two values:
  28. //
  29. // 0 : (default) none
  30. // 1 : fatal errors
  31. //
  32. extern DWORD LsapLookupLogLevel;
  33. //
  34. // This boolean indicates whether a post NT4 DC should perform
  35. // extended lookups (eg by UPN) in a mixed domain (default is FALSE).
  36. //
  37. extern BOOLEAN LsapAllowExtendedDownlevelLookup;
  38. //
  39. // Set to 0 to disable the SID cache
  40. //
  41. #define USE_SID_CACHE 1
  42. //
  43. // Maximum number of Lookup Threads and maximum number to retain.
  44. //
  45. #define LSAP_DB_LOOKUP_MAX_THREAD_COUNT ((ULONG) 0x00000002)
  46. #define LSAP_DB_LOOKUP_MAX_RET_THREAD_COUNT ((ULONG) 0x00000002)
  47. //
  48. // Work Item Granularity.
  49. //
  50. #define LSAP_DB_LOOKUP_WORK_ITEM_GRANULARITY ((ULONG) 0x0000000f)
  51. //
  52. // Parameters specific to a Lookup Sids call.
  53. //
  54. typedef struct _LSAP_DB_LOOKUP_SIDS_PARAMS {
  55. PLSAPR_SID *Sids;
  56. PLSAPR_TRANSLATED_NAMES_EX TranslatedNames;
  57. } LSAP_DB_LOOKUP_SIDS_PARAMS, *PLSAP_DB_LOOKUP_SIDS_PARAMS;
  58. //
  59. // Parameters specific to a Lookup Names call.
  60. //
  61. typedef struct _LSAP_DB_LOOKUP_NAMES_PARAMS {
  62. PLSAPR_UNICODE_STRING Names;
  63. PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids;
  64. } LSAP_DB_LOOKUP_NAMES_PARAMS, *PLSAP_DB_LOOKUP_NAMES_PARAMS;
  65. //
  66. // Types of Lookup Operation.
  67. //
  68. typedef enum {
  69. LookupSids = 1,
  70. LookupNames
  71. } LSAP_DB_LOOKUP_TYPE, *PLSAP_DB_LOOKUP_TYPE;
  72. //
  73. // Work Item states - Assignable, Assigned, Completed, Reassign
  74. //
  75. typedef enum {
  76. AssignableWorkItem = 1,
  77. AssignedWorkItem,
  78. CompletedWorkItem,
  79. ReassignWorkItem,
  80. NonAssignableWorkItem
  81. } LSAP_DB_LOOKUP_WORK_ITEM_STATE, *PLSAP_DB_LOOKUP_WORK_ITEM_STATE;
  82. //
  83. // Work Item Properties.
  84. //
  85. #define LSAP_DB_LOOKUP_WORK_ITEM_ISOL ((ULONG) 0x00000001L)
  86. #define LSAP_DB_LOOKUP_WORK_ITEM_XFOREST ((ULONG) 0x00000002L)
  87. //
  88. // Lookup Work Item. Each work item specifies a domain and an array of
  89. // Sids or Names to be looked up in that domain. This array is specified
  90. // as an array of the Sid or Name indices relevant to the arrays specified
  91. // as parameters to the lookup call.
  92. //
  93. typedef struct _LSAP_DB_LOOKUP_WORK_ITEM {
  94. LIST_ENTRY Links;
  95. LSAP_DB_LOOKUP_WORK_ITEM_STATE State;
  96. ULONG Properties;
  97. LSAPR_TRUST_INFORMATION TrustInformation;
  98. LONG DomainIndex;
  99. ULONG UsedCount;
  100. ULONG MaximumCount;
  101. PULONG Indices;
  102. } LSAP_DB_LOOKUP_WORK_ITEM, *PLSAP_DB_LOOKUP_WORK_ITEM;
  103. //
  104. // Lookup Work List State.
  105. //
  106. typedef enum {
  107. InactiveWorkList = 1,
  108. ActiveWorkList,
  109. CompletedWorkList
  110. } LSAP_DB_LOOKUP_WORK_LIST_STATE, *PLSAP_DB_LOOKUP_WORK_LIST_STATE;
  111. //
  112. // Work List for a Lookup Operation. These are linked together if
  113. // concurrent lookups are permitted.
  114. //
  115. typedef struct _LSAP_DB_LOOKUP_WORK_LIST {
  116. LIST_ENTRY WorkLists;
  117. PLSAP_DB_LOOKUP_WORK_ITEM AnchorWorkItem;
  118. NTSTATUS Status;
  119. LSAP_DB_LOOKUP_WORK_LIST_STATE State;
  120. LSAP_DB_LOOKUP_TYPE LookupType;
  121. LSAPR_HANDLE PolicyHandle;
  122. ULONG WorkItemCount;
  123. ULONG CompletedWorkItemCount;
  124. ULONG Count;
  125. LSAP_LOOKUP_LEVEL LookupLevel;
  126. PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains;
  127. PULONG MappedCount;
  128. PULONG CompletelyUnmappedCount;
  129. ULONG AdvisoryChildThreadCount;
  130. NTSTATUS NonFatalStatus;
  131. HANDLE LookupCompleteEvent;
  132. union {
  133. LSAP_DB_LOOKUP_SIDS_PARAMS LookupSidsParams;
  134. LSAP_DB_LOOKUP_NAMES_PARAMS LookupNamesParams;
  135. };
  136. LSAP_DB_LOOKUP_WORK_ITEM DummyAnchorWorkItem;
  137. } LSAP_DB_LOOKUP_WORK_LIST, *PLSAP_DB_LOOKUP_WORK_LIST;
  138. //
  139. // Lookup Operation Work Queue. The Queue is a circular doubly linked
  140. // list of Work Lists. Each Work List corresponds to a single
  141. // Lookup Operation (i.e. an LsarLookupSids or LsarLookupNames call).
  142. // A Work List is a circular doubly linked list of Work Items, each
  143. // of these being a list of Sids or Names belonging to a specific
  144. // Trusted Domain. Work Items can be given out to different threads.
  145. //
  146. typedef struct _LSAP_DB_LOOKUP_WORK_QUEUE {
  147. SAFE_CRITICAL_SECTION Lock;
  148. PLSAP_DB_LOOKUP_WORK_LIST AnchorWorkList;
  149. PLSAP_DB_LOOKUP_WORK_LIST CurrentAssignableWorkList;
  150. PLSAP_DB_LOOKUP_WORK_ITEM CurrentAssignableWorkItem;
  151. ULONG ActiveChildThreadCount;
  152. ULONG MaximumChildThreadCount;
  153. ULONG MaximumRetainedChildThreadCount;
  154. LSAP_DB_LOOKUP_WORK_LIST DummyAnchorWorkList;
  155. } LSAP_DB_LOOKUP_WORK_QUEUE, *PLSAP_DB_LOOKUP_WORK_QUEUE;
  156. static LSAP_DB_LOOKUP_WORK_QUEUE LookupWorkQueue;
  157. //
  158. // Index to table of the well known SIDs
  159. //
  160. // This type indexes the table of well-known Sids maintained by the LSA
  161. //
  162. typedef enum _LSAP_WELL_KNOWN_SID_INDEX {
  163. LsapNullSidIndex = 0,
  164. LsapWorldSidIndex,
  165. LsapLocalSidIndex,
  166. LsapCreatorOwnerSidIndex,
  167. LsapCreatorGroupSidIndex,
  168. LsapCreatorOwnerServerSidIndex,
  169. LsapCreatorGroupServerSidIndex,
  170. LsapNtAuthoritySidIndex,
  171. LsapDialupSidIndex,
  172. LsapNetworkSidIndex,
  173. LsapBatchSidIndex,
  174. LsapInteractiveSidIndex,
  175. LsapServiceSidIndex,
  176. LsapLogonSidIndex,
  177. LsapBuiltInDomainSidIndex,
  178. LsapLocalSystemSidIndex,
  179. LsapAliasAdminsSidIndex,
  180. LsapAliasUsersSidIndex,
  181. LsapAnonymousSidIndex,
  182. LsapProxySidIndex,
  183. LsapServerSidIndex,
  184. LsapSelfSidIndex,
  185. LsapAuthenticatedUserSidIndex,
  186. LsapRestrictedSidIndex,
  187. LsapInternetDomainIndex,
  188. LsapTerminalServerSidIndex,
  189. LsapLocalServiceSidIndex,
  190. LsapNetworkServiceSidIndex,
  191. LsapRemoteInteractiveSidIndex,
  192. LsapDummyLastSidIndex
  193. } LSAP_WELL_KNOWN_SID_INDEX, *PLSAP_WELL_KNOWN_SID_INDEX;
  194. //
  195. // Macro to identify SIDs the LSA should ignore for lookups (i.e., these
  196. // lookups are always done by SAM since the alias name may change)
  197. //
  198. #define SID_IS_RESOLVED_BY_SAM(SidIndex) \
  199. (((SidIndex) == LsapAliasUsersSidIndex) || ((SidIndex) == LsapAliasAdminsSidIndex))
  200. //
  201. // Mnemonics for Universal well known SIDs. These reference the corresponding
  202. // entries in the Well Known Sids table.
  203. //
  204. #define LsapNullSid WellKnownSids[LsapNullSidIndex].Sid
  205. #define LsapWorldSid WellKnownSids[LsapWorldSidIndex].Sid
  206. #define LsapLocalSid WellKnownSids[LsapLocalSidIndex].Sid
  207. #define LsapCreatorOwnerSid WellKnownSids[LsapCreatorOwnerSidIndex].Sid
  208. #define LsapCreatorGroupSid WellKnownSids[LsapCreatorGroupSidIndex].Sid
  209. #define LsapCreatorOwnerServerSid WellKnownSids[LsapCreatorOwnerServerSidIndex].Sid
  210. #define LsapCreatorGroupServerSid WellKnownSids[LsapCreatorGroupServerSidIndex].Sid
  211. //
  212. // Sids defined by NT
  213. //
  214. #define LsapNtAuthoritySid WellKnownSids[LsapNtAuthoritySid].Sid
  215. #define LsapDialupSid WellKnownSids[LsapDialupSidIndex].Sid
  216. #define LsapNetworkSid WellKnownSids[LsapNetworkSidIndex].Sid
  217. #define LsapBatchSid WellKnownSids[LsapBatchSidIndex].Sid
  218. #define LsapInteractiveSid WellKnownSids[LsapInteractiveSidIndex].Sid
  219. #define LsapServiceSid WellKnownSids[LsapServiceSidIndex].Sid
  220. #define LsapBuiltInDomainSid WellKnownSids[LsapBuiltInDomainSidIndex].Sid
  221. #define LsapLocalSystemSid WellKnownSids[LsapLocalSystemSidIndex].Sid
  222. #define LsapLocalServiceSid WellKnownSids[LsapLocalServiceSidIndex].Sid
  223. #define LsapNetworkServiceSid WellKnownSids[LsapNetworkServiceSidIndex].Sid
  224. #define LsapRemoteInteractiveSid WellKnownSids[LsapRemoteInteractiveSidIndex].Sid
  225. #define LsapRestrictedSid WellKnownSids[LsapRestrictedSidIndex].Sid
  226. #define LsapInternetDomainSid WellKnownSids[LsapInternetDomainIndex].Sid
  227. #define LsapAliasAdminsSid WellKnownSids[LsapAliasAdminsSidIndex].Sid
  228. #define LsapAliasUsersSid WellKnownSids[LsapAliasUsersSidIndex].Sid
  229. #define LsapAnonymousSid WellKnownSids[LsapAnonymousSidIndex].Sid
  230. #define LsapServerSid WellKnownSids[LsapServerSidIndex].Sid
  231. #define LsapSelfSid WellKnownSids[LsapSelfSidIndex].Sid
  232. #define LsapAuthenticatedUserSid WellKnownSids[LsapAuthenticatedUserSidIndex].Sid
  233. #define LsapTerminalServerSid WellKnownSids[LsapTerminalServerSidIndex].Sid
  234. //
  235. // Well known LUIDs
  236. //
  237. extern LUID LsapSystemLogonId;
  238. extern LUID LsapZeroLogonId;
  239. //
  240. // Well known privilege values
  241. //
  242. extern LUID LsapCreateTokenPrivilege;
  243. extern LUID LsapAssignPrimaryTokenPrivilege;
  244. extern LUID LsapLockMemoryPrivilege;
  245. extern LUID LsapIncreaseQuotaPrivilege;
  246. extern LUID LsapUnsolicitedInputPrivilege;
  247. extern LUID LsapTcbPrivilege;
  248. extern LUID LsapSecurityPrivilege;
  249. extern LUID LsapTakeOwnershipPrivilege;
  250. extern SID_IDENTIFIER_AUTHORITY LsapNullSidAuthority;
  251. extern SID_IDENTIFIER_AUTHORITY LsapWorldSidAuthority;
  252. extern SID_IDENTIFIER_AUTHORITY LsapLocalSidAuthority;
  253. extern SID_IDENTIFIER_AUTHORITY LsapCreatorSidAuthority;
  254. extern SID_IDENTIFIER_AUTHORITY LsapNtAuthority;
  255. //
  256. // Maximum number of Subauthority levels for well known Sids
  257. //
  258. #define LSAP_WELL_KNOWN_MAX_SUBAUTH_LEVEL ((ULONG) 0x00000003L)
  259. //
  260. // Constants relating to Sid's
  261. //
  262. #define LSAP_MAX_SUB_AUTH_COUNT (0x00000010L)
  263. #define LSAP_MAX_SIZE_TEXT_SUBA (0x00000009L)
  264. #define LSAP_MAX_SIZE_TEXT_SID_HDR (0x00000020L)
  265. #define LSAP_MAX_SIZE_TEXT_SID \
  266. (LSAP_MAX_SIZE_TEXT_SID_HDR + \
  267. (LSAP_MAX_SUB_AUTH_COUNT * LSAP_MAX_SIZE_TEXT_SUBA))
  268. //
  269. // Well Known Sid Table Entry
  270. //
  271. typedef struct _LSAP_WELL_KNOWN_SID_ENTRY {
  272. PSID Sid;
  273. SID_NAME_USE Use;
  274. UNICODE_STRING Name;
  275. UNICODE_STRING DomainName;
  276. } LSAP_WELL_KNOWN_SID_ENTRY, *PLSAP_WELL_KNOWN_SID_ENTRY;
  277. //
  278. // Well Known Sid Table Pointer
  279. //
  280. extern PLSAP_WELL_KNOWN_SID_ENTRY WellKnownSids;
  281. NTSTATUS
  282. LsapDbLookupGetDomainInfo(
  283. OUT PPOLICY_ACCOUNT_DOMAIN_INFO *AccountDomainInfo,
  284. OUT PPOLICY_DNS_DOMAIN_INFO *DnsDomainInfo
  285. );
  286. ///////////////////////////////////////////////////////////////////////////
  287. // //
  288. // Lookup Sids and Names - Private Function Definitions //
  289. // //
  290. ///////////////////////////////////////////////////////////////////////////
  291. BOOLEAN
  292. LsaIInitializeWellKnownSids(
  293. OUT PLSAP_WELL_KNOWN_SID_ENTRY *WellKnownSids
  294. );
  295. BOOLEAN
  296. LsaIInitializeWellKnownSid(
  297. OUT PLSAP_WELL_KNOWN_SID_ENTRY WellKnownSids,
  298. IN LSAP_WELL_KNOWN_SID_INDEX WellKnownSidIndex,
  299. IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
  300. IN UCHAR SubAuthorityCount,
  301. IN OPTIONAL PULONG SubAuthorities,
  302. IN PWSTR Name,
  303. IN PWSTR Description,
  304. IN SID_NAME_USE Use
  305. );
  306. BOOLEAN
  307. LsapDbLookupIndexWellKnownSid(
  308. IN PLSAPR_SID Sid,
  309. OUT PLSAP_WELL_KNOWN_SID_INDEX WellKnownSidIndex
  310. );
  311. BOOLEAN
  312. LsapDbLookupIndexWellKnownSidName(
  313. IN PLSAPR_UNICODE_STRING Name,
  314. OUT PLSAP_WELL_KNOWN_SID_INDEX WellKnownSidIndex
  315. );
  316. NTSTATUS
  317. LsapDbGetNameWellKnownSid(
  318. IN LSAP_WELL_KNOWN_SID_INDEX WellKnownSidIndex,
  319. OUT PLSAPR_UNICODE_STRING Name,
  320. OUT OPTIONAL PLSAPR_UNICODE_STRING DomainName
  321. );
  322. NTSTATUS
  323. LsapDbLookupIsolatedWellKnownSids(
  324. IN ULONG Count,
  325. IN PLSAPR_SID *Sids,
  326. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  327. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  328. IN OUT PULONG MappedCount,
  329. IN OUT PULONG CompletelyUnmappedCount
  330. );
  331. NTSTATUS
  332. LsapDbLookupSidsInLocalDomains(
  333. IN ULONG Count,
  334. IN PLSAPR_SID *Sids,
  335. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  336. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  337. IN OUT PULONG MappedCount,
  338. IN OUT PULONG CompletelyUnmappedCount,
  339. IN ULONG Options
  340. );
  341. NTSTATUS
  342. LsapDbLookupSidsInLocalDomain(
  343. IN ULONG LocalDomain,
  344. IN ULONG Count,
  345. IN PLSAPR_SID *Sids,
  346. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  347. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  348. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  349. IN OUT PULONG MappedCount,
  350. IN OUT PULONG CompletelyUnmappedCount
  351. );
  352. NTSTATUS
  353. LsapDbLookupSidsInPrimaryDomain(
  354. IN ULONG Count,
  355. IN PLSAPR_SID *Sids,
  356. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  357. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  358. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  359. IN LSAP_LOOKUP_LEVEL LookupLevel,
  360. IN OUT PULONG MappedCount,
  361. IN OUT PULONG CompletelyUnmappedCount,
  362. OUT NTSTATUS *NonFatalStatus,
  363. OUT BOOLEAN *fDownlevelSecureChannel
  364. );
  365. NTSTATUS
  366. LsapDbLookupSidsInTrustedDomains(
  367. IN ULONG Count,
  368. IN PLSAPR_SID *Sids,
  369. IN BOOLEAN fIncludeIntraforest,
  370. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  371. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  372. IN LSAP_LOOKUP_LEVEL LookupLevel,
  373. IN OUT PULONG MappedCount,
  374. IN OUT PULONG CompletelyUnmappedCount,
  375. OUT NTSTATUS *NonFatalStatus
  376. );
  377. NTSTATUS
  378. LsapDbLookupSidsInGlobalCatalog(
  379. IN ULONG Count,
  380. IN PLSAPR_SID *Sids,
  381. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  382. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  383. IN OUT PULONG MappedCount,
  384. IN OUT PULONG CompletelyUnmappedCount,
  385. IN BOOLEAN fDoSidHistory,
  386. OUT NTSTATUS *NonFatalStatus
  387. );
  388. NTSTATUS
  389. LsapDbLookupSidsInGlobalCatalogWks(
  390. IN ULONG Count,
  391. IN PLSAPR_SID *Sids,
  392. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  393. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  394. IN OUT PULONG MappedCount,
  395. IN OUT PULONG CompletelyUnmappedCount,
  396. OUT NTSTATUS *NonFatalStatus
  397. );
  398. NTSTATUS
  399. LsapDbLookupSidsInDomainList(
  400. IN ULONG Count,
  401. IN PLSAPR_SID *Sids,
  402. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  403. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  404. IN OUT PULONG MappedCount,
  405. IN OUT PULONG CompletelyUnmappedCount
  406. );
  407. NTSTATUS
  408. LsapDbLookupTranslateUnknownSids(
  409. IN ULONG Count,
  410. IN PLSAPR_SID *Sids,
  411. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  412. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  413. IN ULONG MappedCount
  414. );
  415. NTSTATUS
  416. LsapDbLookupTranslateUnknownSidsInDomain(
  417. IN ULONG Count,
  418. IN PLSAPR_SID *Sids,
  419. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  420. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  421. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  422. IN LSAP_LOOKUP_LEVEL LookupLevel,
  423. IN OUT PULONG MappedCount,
  424. IN OUT PULONG CompletelyUnmappedCount
  425. );
  426. NTSTATUS
  427. LsapDbLookupSimpleNames(
  428. IN ULONG Count,
  429. IN ULONG LookupLevel,
  430. IN PLSAPR_UNICODE_STRING Names,
  431. IN PLSAPR_UNICODE_STRING PrefixNames,
  432. IN PLSAPR_UNICODE_STRING SuffixNames,
  433. IN PLSAPR_TRUST_INFORMATION BuiltInDomainTrustInformation,
  434. IN PLSAPR_TRUST_INFORMATION_EX AccountDomainTrustInformation,
  435. IN PLSAPR_TRUST_INFORMATION_EX PrimaryDomainTrustInformation,
  436. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  437. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  438. IN OUT PULONG MappedCount,
  439. IN OUT PULONG CompletelyUnmappedCount
  440. );
  441. NTSTATUS
  442. LsapDbLookupWellKnownNames(
  443. IN ULONG Count,
  444. IN PLSAPR_UNICODE_STRING Names,
  445. IN PLSAPR_UNICODE_STRING PrefixNames,
  446. IN PLSAPR_UNICODE_STRING SuffixNames,
  447. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  448. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  449. IN OUT PULONG MappedCount,
  450. IN OUT PULONG CompletelyUnmappedCount
  451. );
  452. NTSTATUS
  453. LsapDbLookupIsolatedDomainNames(
  454. IN ULONG Count,
  455. IN PLSAPR_UNICODE_STRING Names,
  456. IN PLSAPR_UNICODE_STRING PrefixNames,
  457. IN PLSAPR_UNICODE_STRING SuffixNames,
  458. IN PLSAPR_TRUST_INFORMATION BuiltInDomainTrustInformation,
  459. IN PLSAPR_TRUST_INFORMATION_EX AccountDomainTrustInformation,
  460. IN PLSAPR_TRUST_INFORMATION_EX PrimaryDomainTrustInformation,
  461. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  462. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  463. IN OUT PULONG MappedCount,
  464. IN OUT PULONG CompletelyUnmappedCount
  465. );
  466. NTSTATUS
  467. LsapDbLookupIsolatedDomainName(
  468. IN ULONG NameIndex,
  469. IN PLSAPR_UNICODE_STRING IsolatedName,
  470. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  471. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  472. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  473. IN OUT PULONG MappedCount,
  474. IN OUT PULONG CompletelyUnmappedCount
  475. );
  476. NTSTATUS
  477. LsapDbLookupIsolatedDomainNameEx(
  478. IN ULONG NameIndex,
  479. IN PLSAPR_UNICODE_STRING IsolatedName,
  480. IN PLSAPR_TRUST_INFORMATION_EX TrustInformation,
  481. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  482. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  483. IN OUT PULONG MappedCount,
  484. IN OUT PULONG CompletelyUnmappedCount
  485. );
  486. NTSTATUS
  487. LsapDbLookupNamesInLocalDomains(
  488. IN ULONG Count,
  489. IN PLSAPR_UNICODE_STRING Names,
  490. IN PLSAPR_UNICODE_STRING PrefixNames,
  491. IN PLSAPR_UNICODE_STRING SuffixNames,
  492. IN PLSAPR_TRUST_INFORMATION BuiltInDomainTrustInformation,
  493. IN PLSAPR_TRUST_INFORMATION_EX AccountDomainTrustInformation,
  494. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  495. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  496. IN OUT PULONG MappedCount,
  497. IN OUT PULONG CompletelyUnmappedCount,
  498. IN ULONG Options
  499. );
  500. NTSTATUS
  501. LsapDbLookupNamesInLocalDomain(
  502. IN ULONG LocalDomain,
  503. IN ULONG Count,
  504. IN PLSAPR_UNICODE_STRING PrefixNames,
  505. IN PLSAPR_UNICODE_STRING SuffixNames,
  506. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  507. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  508. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  509. IN OUT PULONG MappedCount,
  510. IN OUT PULONG CompletelyUnmappedCount
  511. );
  512. NTSTATUS
  513. LsapDbLookupNamesInLocalDomainEx(
  514. IN ULONG LocalDomain,
  515. IN ULONG Count,
  516. IN PLSAPR_UNICODE_STRING PrefixNames,
  517. IN PLSAPR_UNICODE_STRING SuffixNames,
  518. IN PLSAPR_TRUST_INFORMATION_EX TrustInformationEx,
  519. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  520. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  521. IN OUT PULONG MappedCount,
  522. IN OUT PULONG CompletelyUnmappedCount
  523. );
  524. NTSTATUS
  525. LsapDbLookupNamesInPrimaryDomain(
  526. IN ULONG LookupOptions,
  527. IN ULONG Count,
  528. IN PLSAPR_UNICODE_STRING Names,
  529. IN PLSAPR_UNICODE_STRING PrefixNames,
  530. IN PLSAPR_UNICODE_STRING SuffixNames,
  531. IN PLSAPR_TRUST_INFORMATION_EX TrustInformation,
  532. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  533. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  534. IN LSAP_LOOKUP_LEVEL LookupLevel,
  535. IN OUT PULONG MappedCount,
  536. IN OUT PULONG CompletelyUnmappedCount,
  537. OUT BOOLEAN *fDownlevelSecureChannel,
  538. OUT NTSTATUS *NonFatalStatus
  539. );
  540. NTSTATUS
  541. LsapDbLookupNamesInTrustedDomains(
  542. IN ULONG LookupOptions,
  543. IN ULONG Count,
  544. IN BOOLEAN fIncludeIntraforest,
  545. IN PLSAPR_UNICODE_STRING Names,
  546. IN PLSAPR_UNICODE_STRING PrefixNames,
  547. IN PLSAPR_UNICODE_STRING SuffixNames,
  548. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  549. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  550. IN LSAP_LOOKUP_LEVEL LookupLevel,
  551. IN OUT PULONG MappedCount,
  552. IN OUT PULONG CompletelyUnmappedCount,
  553. OUT NTSTATUS *NonFatalStatus
  554. );
  555. NTSTATUS
  556. LsapDbLookupNamesInGlobalCatalog(
  557. IN ULONG LookupOptions,
  558. IN ULONG Count,
  559. IN PLSAPR_UNICODE_STRING Names,
  560. IN PLSAPR_UNICODE_STRING PrefixNames,
  561. IN PLSAPR_UNICODE_STRING SuffixNames,
  562. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  563. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  564. IN OUT PULONG MappedCount,
  565. IN OUT PULONG CompletelyUnmappedCount,
  566. OUT NTSTATUS *NonFatalStatus
  567. );
  568. NTSTATUS
  569. LsapDbLookupNamesInGlobalCatalogWks(
  570. IN ULONG LookupOptions,
  571. IN ULONG Count,
  572. IN PLSAPR_UNICODE_STRING Names,
  573. IN PLSAPR_UNICODE_STRING PrefixNames,
  574. IN PLSAPR_UNICODE_STRING SuffixNames,
  575. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  576. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  577. IN OUT PULONG MappedCount,
  578. IN OUT PULONG CompletelyUnmappedCount,
  579. OUT NTSTATUS *NonFatalStatus
  580. );
  581. NTSTATUS
  582. LsapDbLookupTranslateNameDomain(
  583. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  584. IN OPTIONAL PLSA_TRANSLATED_SID_EX2 TranslatedSid,
  585. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  586. OUT PLONG DomainIndex
  587. );
  588. NTSTATUS
  589. LsapDbLookupTranslateUnknownNames(
  590. IN ULONG Count,
  591. IN PLSAPR_UNICODE_STRING Names,
  592. IN PLSAPR_UNICODE_STRING PrefixNames,
  593. IN PLSAPR_UNICODE_STRING SuffixNames,
  594. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  595. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  596. IN ULONG MappedCount
  597. );
  598. NTSTATUS
  599. LsapDbLookupTranslateUnknownNamesInDomain(
  600. IN ULONG Count,
  601. IN PLSAPR_UNICODE_STRING Names,
  602. IN PLSAPR_UNICODE_STRING PrefixNames,
  603. IN PLSAPR_UNICODE_STRING SuffixNames,
  604. IN PLSAPR_TRUST_INFORMATION_EX TrustInformationEx,
  605. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  606. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  607. IN LSAP_LOOKUP_LEVEL LookupLevel,
  608. IN OUT PULONG MappedCount,
  609. IN OUT PULONG CompletelyUnmappedCount
  610. );
  611. NTSTATUS
  612. LsapDbLookupDispatchWorkerThreads(
  613. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList
  614. );
  615. NTSTATUS
  616. LsapRtlValidateControllerTrustedDomain(
  617. IN PLSAPR_UNICODE_STRING DomainControllerName,
  618. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  619. IN ACCESS_MASK DesiredAccess,
  620. IN LPWSTR ServerPrincipalName,
  621. IN PVOID ClientContext,
  622. OUT PLSA_HANDLE PolicyHandle
  623. );
  624. NTSTATUS
  625. LsapDbLookupCreateListReferencedDomains(
  626. OUT PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  627. IN ULONG InitialMaxEntries
  628. );
  629. NTSTATUS
  630. LsapDbLookupAddListReferencedDomains(
  631. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  632. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  633. OUT PLONG DomainIndex
  634. );
  635. BOOLEAN
  636. LsapDbLookupListReferencedDomains(
  637. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  638. IN PLSAPR_SID DomainSid,
  639. OUT PLONG DomainIndex
  640. );
  641. NTSTATUS
  642. LsapDbLookupGrowListReferencedDomains(
  643. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  644. IN ULONG MaximumEntries
  645. );
  646. NTSTATUS
  647. LsapDbLookupMergeDisjointReferencedDomains(
  648. IN OPTIONAL PLSAPR_REFERENCED_DOMAIN_LIST FirstReferencedDomainList,
  649. IN OPTIONAL PLSAPR_REFERENCED_DOMAIN_LIST SecondReferencedDomainList,
  650. OUT PLSAPR_REFERENCED_DOMAIN_LIST *OutputReferencedDomainList,
  651. IN ULONG Options
  652. );
  653. NTSTATUS
  654. LsapDbLookupInitialize(
  655. );
  656. NTSTATUS
  657. LsapDbLookupInitializeWorkQueue(
  658. );
  659. NTSTATUS
  660. LsapDbLookupInitializeWorkList(
  661. OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList
  662. );
  663. NTSTATUS
  664. LsapDbLookupInitializeWorkItem(
  665. OUT PLSAP_DB_LOOKUP_WORK_ITEM WorkItem
  666. );
  667. NTSTATUS
  668. LsapDbLookupAcquireWorkQueueLock(
  669. );
  670. VOID LsapDbLookupReleaseWorkQueueLock();
  671. NTSTATUS
  672. LsapDbLookupLocalDomains(
  673. OUT PLSAPR_TRUST_INFORMATION BuiltInDomainTrustInformation,
  674. OUT PLSAPR_TRUST_INFORMATION_EX AccountDomainTrustInformation,
  675. OUT PLSAPR_TRUST_INFORMATION_EX PrimaryDomainTrustInformation
  676. );
  677. NTSTATUS
  678. LsapDbLookupNamesBuildWorkList(
  679. IN ULONG LookupOptions,
  680. IN ULONG Count,
  681. IN BOOLEAN fIncludeIntraforest,
  682. IN PLSAPR_UNICODE_STRING Names,
  683. IN PLSAPR_UNICODE_STRING PrefixNames,
  684. IN PLSAPR_UNICODE_STRING SuffixNames,
  685. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  686. IN PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  687. IN LSAP_LOOKUP_LEVEL LookupLevel,
  688. IN OUT PULONG MappedCount,
  689. IN OUT PULONG CompletelyUnmappedCount,
  690. OUT PLSAP_DB_LOOKUP_WORK_LIST *WorkList
  691. );
  692. NTSTATUS
  693. LsapDbLookupSidsBuildWorkList(
  694. IN ULONG Count,
  695. IN PLSAPR_SID *Sids,
  696. IN BOOLEAN fIncludeIntraforest,
  697. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  698. IN PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  699. IN LSAP_LOOKUP_LEVEL LookupLevel,
  700. IN OUT PULONG MappedCount,
  701. IN OUT PULONG CompletelyUnmappedCount,
  702. OUT PLSAP_DB_LOOKUP_WORK_LIST *WorkList
  703. );
  704. NTSTATUS
  705. LsapDbLookupCreateWorkList(
  706. OUT PLSAP_DB_LOOKUP_WORK_LIST *WorkList
  707. );
  708. NTSTATUS
  709. LsapDbLookupInsertWorkList(
  710. IN PLSAP_DB_LOOKUP_WORK_LIST WorkList
  711. );
  712. NTSTATUS
  713. LsapDbLookupDeleteWorkList(
  714. IN PLSAP_DB_LOOKUP_WORK_LIST WorkList
  715. );
  716. NTSTATUS
  717. LsapDbLookupSignalCompletionWorkList(
  718. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList
  719. );
  720. NTSTATUS
  721. LsapDbLookupAwaitCompletionWorkList(
  722. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList
  723. );
  724. NTSTATUS
  725. LsapDbAddWorkItemToWorkList(
  726. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList,
  727. IN PLSAP_DB_LOOKUP_WORK_ITEM WorkItem
  728. );
  729. NTSTATUS
  730. LsapDbLookupStopProcessingWorkList(
  731. IN PLSAP_DB_LOOKUP_WORK_LIST WorkList,
  732. IN NTSTATUS TerminationStatus
  733. );
  734. VOID
  735. LsapDbUpdateMappedCountsWorkList(
  736. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList
  737. );
  738. NTSTATUS
  739. LsapDbLookupNamesUpdateTranslatedSids(
  740. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList,
  741. IN OUT PLSAP_DB_LOOKUP_WORK_ITEM WorkItem,
  742. IN PLSAPR_TRANSLATED_SID_EX2 TranslatedSids,
  743. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains
  744. );
  745. NTSTATUS
  746. LsapDbLookupSidsUpdateTranslatedNames(
  747. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList,
  748. IN OUT PLSAP_DB_LOOKUP_WORK_ITEM WorkItem,
  749. IN PLSA_TRANSLATED_NAME_EX TranslatedNames,
  750. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains
  751. );
  752. VOID
  753. LsapDbLookupWorkerThreadStart(
  754. );
  755. VOID
  756. LsapDbLookupWorkerThread(
  757. IN BOOLEAN PrimaryThread
  758. );
  759. NTSTATUS
  760. LsapDbLookupObtainWorkItem(
  761. OUT PLSAP_DB_LOOKUP_WORK_LIST *WorkList,
  762. OUT PLSAP_DB_LOOKUP_WORK_ITEM *WorkItem
  763. );
  764. NTSTATUS
  765. LsapDbLookupProcessWorkItem(
  766. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList,
  767. IN OUT PLSAP_DB_LOOKUP_WORK_ITEM WorkItem
  768. );
  769. NTSTATUS
  770. LsapDbLookupCreateWorkItem(
  771. IN PLSAPR_TRUST_INFORMATION TrustInformation,
  772. IN LONG DomainIndex,
  773. IN ULONG MaximumEntryCount,
  774. OUT PLSAP_DB_LOOKUP_WORK_ITEM *WorkItem
  775. );
  776. NTSTATUS
  777. LsapDbLookupAddIndicesToWorkItem(
  778. IN OUT PLSAP_DB_LOOKUP_WORK_ITEM WorkItem,
  779. IN ULONG Count,
  780. IN PULONG Indices
  781. );
  782. NTSTATUS
  783. LsapDbLookupComputeAdvisoryChildThreadCount(
  784. IN OUT PLSAP_DB_LOOKUP_WORK_LIST WorkList
  785. );
  786. NTSTATUS
  787. LsapDbLookupUpdateAssignableWorkItem(
  788. IN BOOLEAN MoveToNextWorkList
  789. );
  790. NTSTATUS
  791. LsapRtlExtractDomainSid(
  792. IN PSID Sid,
  793. OUT PSID *DomainSid
  794. );
  795. VOID LsapDbLookupReturnThreadToPool();
  796. /*++
  797. PSID
  798. LsapDbWellKnownSid(
  799. IN LSAP_WELL_KNOWN_SID_INDEX WellKnownSidIndex
  800. )
  801. Routine Description:
  802. This macro function returns the Well Known Sid corresponding
  803. to an index into the Well Known Sid table.
  804. Arguments:
  805. WellKnownSidIndex - Index into the Well Known Sid information table.
  806. It is the caller's responsibility to ensure that the given index
  807. is valid.
  808. Return Value:
  809. --*/
  810. #define LsapDbWellKnownSid( WellKnownSidIndex ) \
  811. (WellKnownSids[ WellKnownSidIndex ].Sid)
  812. PUNICODE_STRING
  813. LsapDbWellKnownSidName(
  814. IN LSAP_WELL_KNOWN_SID_INDEX WellKnownSidIndex
  815. );
  816. /*++
  817. SID_NAME_USE
  818. LsapDbWellKnownSidNameUse(
  819. IN LSAP_DB_WELL_KNOWN_SID_INDEX WellKnownSidIndex
  820. )
  821. Routine Description:
  822. This macro function returns the Sid Name Use of a Well Known Sid.
  823. Arguments:
  824. WellKnownSidIndex - Index into the Well Known Sid information table.
  825. It is the caller's responsibility to ensure that the given index
  826. is valid.
  827. Return Value:
  828. --*/
  829. #define LsapDbWellKnownSidNameUse( WellKnownSidIndex ) \
  830. (WellKnownSids[ WellKnownSidIndex ].Use)
  831. VOID
  832. LsapDbUpdateCountCompUnmappedNames(
  833. OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  834. IN OUT PULONG CompletelyUnmappedCount
  835. );
  836. /*++
  837. PUNICODE_STRING
  838. LsapDbWellKnownSidDescription(
  839. IN LSAP_WELL_KNOWN_SID_INDEX WellKnownSidIndex
  840. )
  841. Routine Description:
  842. This macro function returns the Unicode Description of a Well Known Sid.
  843. Arguments:
  844. WellKnownSidIndex - Index into the Well Known Sid information table.
  845. It is the caller's responsibility to ensure that the given index
  846. is valid.
  847. Return Value:
  848. --*/
  849. #define LsapDbWellKnownSidDescription( WellKnownSidIndex ) \
  850. (&(WellKnownSids[ WellKnownSidIndex ].DomainName))
  851. PUNICODE_STRING
  852. LsapDbWellKnownSidName(
  853. IN LSAP_WELL_KNOWN_SID_INDEX WellKnownSidIndex
  854. );
  855. #define LsapDbAccessedBySidObject( ObjectTypeId ) \
  856. (LsapDbState.DbObjectTypes[ ObjectTypeId ].AccessedBySid)
  857. #define LsapDbAccessedByNameObject( ObjectTypeId ) \
  858. (LsapDbState.DbObjectTypes[ ObjectTypeId ].AccessedByName)
  859. #define LsapDbCompletelyUnmappedName(TranslatedName) \
  860. (((TranslatedName)->DomainIndex == LSA_UNKNOWN_INDEX) && \
  861. ((TranslatedName)->Use == SidTypeUnknown))
  862. #define LsapDbCompletelyUnmappedSid(TranslatedSid) \
  863. (((TranslatedSid)->DomainIndex == LSA_UNKNOWN_INDEX) && \
  864. ((TranslatedSid)->Use == SidTypeUnknown))
  865. NTSTATUS
  866. LsapGetDomainSidByNetbiosName(
  867. IN LPWSTR NetbiosName,
  868. OUT PSID *Sid
  869. );
  870. NTSTATUS
  871. LsapGetDomainSidByDnsName(
  872. IN LPWSTR DnsName,
  873. OUT PSID *Sid
  874. );
  875. NTSTATUS
  876. LsapGetDomainNameBySid(
  877. IN PSID Sid,
  878. OUT PUNICODE_STRING DomainName
  879. );
  880. VOID
  881. LsapConvertTrustToEx(
  882. IN OUT PLSAPR_TRUST_INFORMATION_EX TrustInformationEx,
  883. IN PLSAPR_TRUST_INFORMATION TrustInformation
  884. );
  885. VOID
  886. LsapConvertExTrustToOriginal(
  887. IN OUT PLSAPR_TRUST_INFORMATION TrustInformation,
  888. IN PLSAPR_TRUST_INFORMATION_EX TrustInformationEx
  889. );
  890. NTSTATUS
  891. LsapDbOpenPolicyGc (
  892. OUT HANDLE *LsaPolicyHandle
  893. );
  894. BOOLEAN
  895. LsapRevisionCanHandleNewErrorCodes(
  896. IN ULONG Revision
  897. );
  898. BOOLEAN
  899. LsapIsDsDomainByNetbiosName(
  900. WCHAR *NetbiosName
  901. );
  902. BOOLEAN
  903. LsapIsBuiltinDomain(
  904. IN PSID Sid
  905. );
  906. BOOLEAN
  907. LsapDbIsStatusConnectionFailure(
  908. NTSTATUS st
  909. );
  910. NTSTATUS
  911. LsapDbLookupAccessCheck(
  912. IN LSAPR_HANDLE PolicyHandle
  913. );
  914. NTSTATUS
  915. LsapDbLookupXForestNamesBuildWorkList(
  916. IN ULONG Count,
  917. IN PLSAPR_UNICODE_STRING Names,
  918. IN PLSAPR_UNICODE_STRING PrefixNames,
  919. IN PLSAPR_UNICODE_STRING SuffixNames,
  920. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  921. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  922. IN LSAP_LOOKUP_LEVEL LookupLevel,
  923. IN OUT PULONG MappedCount,
  924. IN OUT PULONG CompletelyUnmappedCount,
  925. OUT PLSAP_DB_LOOKUP_WORK_LIST *WorkList
  926. );
  927. NTSTATUS
  928. LsapDbLookupXForestSidsBuildWorkList(
  929. IN ULONG Count,
  930. IN PLSAPR_SID *Sids,
  931. IN PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  932. IN PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  933. IN LSAP_LOOKUP_LEVEL LookupLevel,
  934. IN OUT PULONG MappedCount,
  935. IN OUT PULONG CompletelyUnmappedCount,
  936. OUT PLSAP_DB_LOOKUP_WORK_LIST *WorkList
  937. );
  938. NTSTATUS
  939. LsaICLookupNamesWithCreds(
  940. IN LPWSTR ServerName,
  941. IN LPWSTR ServerPrincipalName,
  942. IN ULONG AuthnLevel,
  943. IN ULONG AuthnSvc,
  944. IN RPC_AUTH_IDENTITY_HANDLE AuthIdentity,
  945. IN ULONG AuthzSvc,
  946. IN ULONG Count,
  947. IN PUNICODE_STRING Names,
  948. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  949. OUT PLSA_TRANSLATED_SID_EX2 *Sids,
  950. IN LSAP_LOOKUP_LEVEL LookupLevel,
  951. IN OUT PULONG MappedCount
  952. );
  953. NTSTATUS
  954. LsaICLookupSidsWithCreds(
  955. IN LPWSTR ServerName,
  956. IN LPWSTR ServerPrincipalName,
  957. IN ULONG AuthnLevel,
  958. IN ULONG AuthnSvc,
  959. IN RPC_AUTH_IDENTITY_HANDLE AuthIdentity,
  960. IN ULONG AuthzSvc,
  961. IN ULONG Count,
  962. IN PSID *Sids,
  963. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  964. OUT PLSA_TRANSLATED_NAME_EX *Names,
  965. IN LSAP_LOOKUP_LEVEL LookupLevel,
  966. IN OUT PULONG MappedCount
  967. );
  968. NTSTATUS
  969. LsapDbLookupNameChainRequest(
  970. IN LSAPR_TRUST_INFORMATION_EX *TrustInfo,
  971. IN ULONG Count,
  972. IN PUNICODE_STRING Names,
  973. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  974. OUT PLSA_TRANSLATED_SID_EX2 *Sids,
  975. IN LSAP_LOOKUP_LEVEL LookupLevel,
  976. OUT PULONG MappedCount,
  977. OUT PULONG ServerRevision OPTIONAL
  978. );
  979. NTSTATUS
  980. LsaDbLookupSidChainRequest(
  981. IN LSAPR_TRUST_INFORMATION_EX *TrustInfo,
  982. IN ULONG Count,
  983. IN PSID *Sids,
  984. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  985. OUT PLSA_TRANSLATED_NAME_EX *Names,
  986. IN LSAP_LOOKUP_LEVEL LookupLevel,
  987. IN OUT PULONG MappedCount,
  988. OUT PULONG ServerRevision OPTIONAL
  989. );
  990. LPWSTR
  991. LsapDbLookupGetLevel(
  992. IN LSAP_LOOKUP_LEVEL LookupLevel
  993. );
  994. #define LsapDbLookupReportEvent0(a, b, c, d, e) \
  995. if (a <= LsapLookupLogLevel) {SpmpReportEvent( TRUE, b, c, 0, d, e, 0);}
  996. #define LsapDbLookupReportEvent1(a, b, c, d, e, f) \
  997. if (a <= LsapLookupLogLevel) {SpmpReportEvent( TRUE, b, c, 0, d, e, 1, f);}
  998. #define LsapDbLookupReportEvent2(a, b, c, d, e, f, g) \
  999. if (a <= LsapLookupLogLevel) {SpmpReportEvent( TRUE, b, c, 0, d, e, 2, f, g);}
  1000. #define LsapDbLookupReportEvent3(a, b, c, d, e, f, g, h) \
  1001. if (a <= LsapLookupLogLevel) {SpmpReportEvent( TRUE, b, c, 0, d, e, 3, f, g, h);}
  1002. NTSTATUS
  1003. LsapLookupReallocateTranslations(
  1004. IN OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  1005. IN ULONG Count,
  1006. IN OUT PLSA_TRANSLATED_NAME_EX *Names, OPTIONAL
  1007. IN OUT PLSA_TRANSLATED_SID_EX2 *Sids OPTIONAL
  1008. );
  1009. //
  1010. // BOOLEAN
  1011. // LsapOutboundTrustedDomain(
  1012. // PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY x
  1013. // );
  1014. //
  1015. // This routine returns TRUE if x is a trust to a domain
  1016. //
  1017. #define LsapOutboundTrustedDomain(x) \
  1018. ( ((x)->TrustInfoEx.TrustType == TRUST_TYPE_UPLEVEL \
  1019. || (x)->TrustInfoEx.TrustType == TRUST_TYPE_DOWNLEVEL ) \
  1020. && ((x)->TrustInfoEx.Sid != NULL) \
  1021. && ((x)->TrustInfoEx.TrustDirection & TRUST_DIRECTION_OUTBOUND) \
  1022. && (((x)->TrustInfoEx.TrustAttributes & TRUST_ATTRIBUTE_FOREST_TRANSITIVE) \
  1023. == 0))
  1024. //
  1025. // BOOLEAN
  1026. // LsapOutboundTrustedForest(
  1027. // PLSAP_DB_TRUSTED_DOMAIN_LIST_ENTRY x
  1028. // );
  1029. //
  1030. // This routine returns TRUE if x is a trust to a forest
  1031. //
  1032. #define LsapOutboundTrustedForest(x) \
  1033. ( ((x)->TrustInfoEx.TrustType == TRUST_TYPE_UPLEVEL) \
  1034. && ((x)->TrustInfoEx.Sid != NULL) \
  1035. && ((x)->TrustInfoEx.TrustDirection & TRUST_DIRECTION_OUTBOUND) \
  1036. && ((x)->TrustInfoEx.TrustAttributes & TRUST_ATTRIBUTE_FOREST_TRANSITIVE)) \
  1037. //
  1038. // Return values from LsapGetDomainLookupScope
  1039. //
  1040. //
  1041. // Scope is domains that we directly trust
  1042. //
  1043. #define LSAP_LOOKUP_TRUSTED_DOMAIN_DIRECT 0x00000001
  1044. //
  1045. // Scope is domains that we transitively trust
  1046. //
  1047. #define LSAP_LOOKUP_TRUSTED_DOMAIN_TRANSITIVE 0x00000002
  1048. //
  1049. // Scope is domains that we trust via forest trust
  1050. //
  1051. #define LSAP_LOOKUP_TRUSTED_FOREST 0x00000004
  1052. //
  1053. // Scope includes to lookup trusted forest domains locally
  1054. //
  1055. #define LSAP_LOOKUP_TRUSTED_FOREST_ROOT 0x00000008
  1056. //
  1057. // Allow lookups of DNS names
  1058. //
  1059. #define LSAP_LOOKUP_DNS_SUPPORT 0x00000010
  1060. ULONG
  1061. LsapGetDomainLookupScope(
  1062. IN LSAP_LOOKUP_LEVEL LookupLevel,
  1063. IN ULONG ClientRevision
  1064. );
  1065. //
  1066. // Useful combinations
  1067. //
  1068. #define LSAP_LOOKUP_RESOLVE_ISOLATED_DOMAINS \
  1069. (LSAP_LOOKUP_TRUSTED_DOMAIN_DIRECT | \
  1070. LSAP_LOOKUP_TRUSTED_DOMAIN_TRANSITIVE | \
  1071. LSAP_LOOKUP_TRUSTED_FOREST_ROOT)
  1072. NTSTATUS
  1073. LsapDbLookupNamesAsDomainNames(
  1074. IN ULONG Flags,
  1075. IN ULONG Count,
  1076. IN PLSAPR_UNICODE_STRING Names,
  1077. IN PLSAPR_UNICODE_STRING PrefixNames,
  1078. IN PLSAPR_UNICODE_STRING SuffixNames,
  1079. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  1080. IN OUT PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
  1081. IN OUT PULONG MappedCount
  1082. );
  1083. NTSTATUS
  1084. LsapDbLookupSidsAsDomainSids(
  1085. IN ULONG Flags,
  1086. IN ULONG Count,
  1087. IN PLSAPR_SID *Sids,
  1088. IN OUT PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains,
  1089. IN OUT PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
  1090. IN OUT PULONG MappedCount
  1091. );