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.

438 lines
9.5 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. lsads.h
  5. Abstract:
  6. Private macros/definitions/prototypes for implementing portions of the LSA store
  7. in the DS and in the registry, simultaneously
  8. Author:
  9. Mac McLain (MacM) Jan 17, 1997
  10. Environment:
  11. User Mode
  12. Revision History:
  13. --*/
  14. #ifndef __LSADS_H__
  15. #define __LSADS_H__
  16. #include <ntdsa.h>
  17. #include <dsysdbg.h>
  18. #include <safelock.h>
  19. #if DBG == 1
  20. #ifdef ASSERT
  21. #undef ASSERT
  22. #endif
  23. #define ASSERT DsysAssert
  24. #define DEB_UPGRADE 0x10
  25. #define DEB_POLICY 0x20
  26. #define DEB_FIXUP 0x80
  27. #define DEB_NOTIFY 0x100
  28. #define DEB_DSNOTIFY 0x200
  29. #define DEB_FTRACE 0x400
  30. #define DEB_LOOKUP 0x800
  31. #define DEB_HANDLE 0x1000
  32. #define DEB_FTINFO 0x2000
  33. #define DEB_SIDFILTER 0x4000
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif // __cplusplus
  37. DECLARE_DEBUG2( LsaDs )
  38. #ifdef __cplusplus
  39. }
  40. #endif // __cplusplus
  41. #define LsapDsDebugOut( args ) LsaDsDebugPrint args
  42. #define LsapEnterFunc( x ) \
  43. LsaDsDebugPrint( DEB_FTRACE, "0x%lx: Entering %s\n", GetCurrentThreadId(), x );
  44. #define LsapExitFunc( x, y ) \
  45. LsaDsDebugPrint( DEB_FTRACE, "0x%lx: Leaving %s: 0x%lx\n", GetCurrentThreadId(), x, y );
  46. #else
  47. #define LsapDsDebugOut(args)
  48. #define LsapEnterFunc( x )
  49. #define LsapExitFunc( x, y )
  50. #endif // DBG
  51. //
  52. // These function prototypes control how the Ds transactioning is done. In
  53. // the Ds case, the pointers are initialized to routines that actually do
  54. // transactioning. In the non-Ds case, they point to dummy rountines that
  55. // do nothing.
  56. //
  57. typedef NTSTATUS ( *pfDsOpenTransaction ) ( ULONG );
  58. typedef NTSTATUS ( *pfDsApplyTransaction ) ( ULONG );
  59. typedef NTSTATUS ( *pfDsAbortTransaction ) ( ULONG );
  60. //
  61. // Ds functions that behave differently for the Ds and non-Ds case exist
  62. // in this function table.
  63. //
  64. typedef struct _LSADS_DS_FUNC_TABLE {
  65. pfDsOpenTransaction pOpenTransaction;
  66. pfDsApplyTransaction pApplyTransaction;
  67. pfDsAbortTransaction pAbortTransaction;
  68. } LSADS_DS_FUNC_TABLE, *PLSADS_DS_FUNC_TABLE;
  69. typedef struct _LSADS_DS_SYSTEM_CONTAINER_ITEMS {
  70. PDSNAME TrustedDomainObject;
  71. PDSNAME SecretObject;
  72. } LSADS_DS_SYSTEM_CONTAINER_ITEMS, *PLSADS_DS_SYSTEM_CONTAINER_ITEMS;
  73. //
  74. // Basic LsaDs information structure
  75. //
  76. typedef struct _LSADS_DS_STATE_INFO {
  77. PDSNAME DsRoot; // DSNAME of the root of the Ds
  78. PDSNAME DsPartitionsContainer; // DSNAME of the partitions container
  79. PDSNAME DsSystemContainer; // DSNAME of the system container
  80. PDSNAME DsConfigurationContainer; // DSNAME of the configuration container
  81. ULONG DsDomainHandle; // DS Handle of the domain
  82. LSADS_DS_FUNC_TABLE DsFuncTable; // Function table for Ds specific
  83. // functions
  84. LSADS_DS_SYSTEM_CONTAINER_ITEMS SystemContainerItems;
  85. PVOID SavedThreadState; // Results from THSave
  86. BOOLEAN DsTransactionSave;
  87. BOOLEAN DsTHStateSave;
  88. BOOLEAN DsOperationSave;
  89. BOOLEAN WriteLocal; // Can we write to the registry?
  90. BOOLEAN UseDs; // Is the Ds active?
  91. BOOLEAN FunctionTableInitialized; // Is the function table initialized
  92. BOOLEAN DsInitializedAndRunning; // Has the Ds started
  93. BOOLEAN Nt4UpgradeInProgress; // Is this the case of an upgrade from NT4
  94. } LSADS_DS_STATE_INFO, *PLSADS_DS_STATE_INFO;
  95. typedef struct _LSADS_PER_THREAD_INFO {
  96. BOOLEAN SavedTransactionValid;
  97. ULONG UseCount;
  98. ULONG DsThreadStateUseCount;
  99. ULONG DsTransUseCount;
  100. ULONG DsOperationCount;
  101. PVOID SavedThreadState;
  102. PVOID InitialThreadState;
  103. ULONG OldTrustDirection;
  104. ULONG OldTrustType;
  105. } LSADS_PER_THREAD_INFO, *PLSADS_PER_THREAD_INFO;
  106. #if DBG
  107. typedef struct _LSADS_THREAD_INFO_NODE {
  108. PLSADS_PER_THREAD_INFO ThreadInfo;
  109. ULONG ThreadId;
  110. } LSADS_THREAD_INFO_NODE, *PLSADS_THREAD_INFO_NODE;
  111. #define LSAP_THREAD_INFO_LIST_MAX 15
  112. extern LSADS_THREAD_INFO_NODE LsapDsThreadInfoList[ LSAP_THREAD_INFO_LIST_MAX ];
  113. extern SAFE_RESOURCE LsapDsThreadInfoListResource;
  114. #endif
  115. //
  116. // Extern definitions
  117. //
  118. extern LSADS_DS_STATE_INFO LsaDsStateInfo;
  119. #ifdef __cplusplus
  120. extern "C" {
  121. #endif // __cplusplus
  122. extern DWORD LsapDsThreadState;
  123. #ifdef __cplusplus
  124. }
  125. #endif // __cplusplus
  126. //
  127. // Implemented as a macro for performance reasons
  128. //
  129. // PLSADS_PER_THREAD_INFO
  130. // LsapQueryThreadInfo(
  131. // VOID
  132. // );
  133. #define LsapQueryThreadInfo( ) TlsGetValue( LsapDsThreadState )
  134. VOID
  135. LsapDsDebugInitialize(
  136. VOID
  137. );
  138. //
  139. // Registry specific functions
  140. //
  141. NTSTATUS
  142. LsapRegReadObjectSD(
  143. IN LSAPR_HANDLE ObjectHandle,
  144. OUT PSECURITY_DESCRIPTOR *ppSD
  145. );
  146. NTSTATUS
  147. LsapRegGetPhysicalObjectName(
  148. IN PLSAP_DB_OBJECT_INFORMATION ObjectInformation,
  149. IN PUNICODE_STRING LogicalNameU,
  150. OUT OPTIONAL PUNICODE_STRING PhysicalNameU
  151. );
  152. NTSTATUS
  153. LsapRegOpenObject(
  154. IN LSAP_DB_HANDLE ObjectHandle,
  155. IN ULONG OpenMode,
  156. OUT PVOID *pvKey
  157. );
  158. NTSTATUS
  159. LsapRegOpenTransaction(
  160. );
  161. NTSTATUS
  162. LsapRegApplyTransaction(
  163. );
  164. NTSTATUS
  165. LsapRegAbortTransaction(
  166. );
  167. NTSTATUS
  168. LsapRegCreateObject(
  169. IN PUNICODE_STRING ObjectPath,
  170. IN LSAP_DB_OBJECT_TYPE_ID ObjectType
  171. );
  172. NTSTATUS
  173. LsapRegDeleteObject(
  174. IN PUNICODE_STRING ObjectPath
  175. );
  176. NTSTATUS
  177. LsapRegWriteAttribute(
  178. IN PUNICODE_STRING AttributePath,
  179. IN PVOID pvAttribute,
  180. IN ULONG AttributeLength
  181. );
  182. NTSTATUS
  183. LsapRegDeleteAttribute(
  184. IN PUNICODE_STRING AttributePath,
  185. IN BOOLEAN DeleteSecurely,
  186. IN ULONG AttributeLength
  187. );
  188. NTSTATUS
  189. LsapRegReadAttribute(
  190. IN LSAPR_HANDLE ObjectHandle,
  191. IN PUNICODE_STRING AttributeName,
  192. IN OPTIONAL PVOID AttributeValue,
  193. IN OUT PULONG AttributeValueLength
  194. );
  195. //
  196. // Counterpart Ds functions
  197. //
  198. NTSTATUS
  199. LsapDsReadObjectSD(
  200. IN LSAPR_HANDLE ObjectHandle,
  201. OUT PSECURITY_DESCRIPTOR *ppSD
  202. );
  203. NTSTATUS
  204. LsapDsGetPhysicalObjectName(
  205. IN PLSAP_DB_OBJECT_INFORMATION ObjectInformation,
  206. IN BOOLEAN DefaultName,
  207. IN PUNICODE_STRING LogicalNameU,
  208. OUT OPTIONAL PUNICODE_STRING PhysicalNameU
  209. );
  210. NTSTATUS
  211. LsapDsOpenObject(
  212. IN LSAP_DB_HANDLE ObjectHandle,
  213. IN ULONG OpenMode,
  214. OUT PVOID *pvKey
  215. );
  216. NTSTATUS
  217. LsapDsVerifyObjectExistenceByDsName(
  218. IN PDSNAME DsName
  219. );
  220. NTSTATUS
  221. LsapDsOpenTransaction(
  222. IN ULONG Options
  223. );
  224. //
  225. // Assert that there is a DS transaction open
  226. //
  227. #define LsapAssertDsTransactionOpen() \
  228. { \
  229. PLSADS_PER_THREAD_INFO CurrentThreadInfo; \
  230. CurrentThreadInfo = LsapQueryThreadInfo(); \
  231. \
  232. ASSERT( CurrentThreadInfo != NULL ); \
  233. if ( CurrentThreadInfo != NULL ) { \
  234. ASSERT( CurrentThreadInfo->DsTransUseCount > 0 ); \
  235. } \
  236. }
  237. NTSTATUS
  238. LsapDsOpenTransactionDummy(
  239. IN ULONG Options
  240. );
  241. NTSTATUS
  242. LsapDsApplyTransaction(
  243. IN ULONG Options
  244. );
  245. NTSTATUS
  246. LsapDsApplyTransactionDummy(
  247. IN ULONG Options
  248. );
  249. NTSTATUS
  250. LsapDsAbortTransaction(
  251. IN ULONG Options
  252. );
  253. NTSTATUS
  254. LsapDsAbortTransactionDummy(
  255. IN ULONG Options
  256. );
  257. NTSTATUS
  258. LsapDsCreateObject(
  259. IN PUNICODE_STRING ObjectPath,
  260. IN ULONG Flags,
  261. IN LSAP_DB_OBJECT_TYPE_ID ObjectType
  262. );
  263. NTSTATUS
  264. LsapDsDeleteObject(
  265. IN PUNICODE_STRING ObjectPath
  266. );
  267. NTSTATUS
  268. LsapDsWriteAttributes(
  269. IN PUNICODE_STRING ObjectPath,
  270. IN PLSAP_DB_ATTRIBUTE Attributes,
  271. IN ULONG AttributeCount,
  272. IN ULONG Options
  273. );
  274. NTSTATUS
  275. LsapDsWriteAttributesByDsName(
  276. IN PDSNAME ObjectPath,
  277. IN PLSAP_DB_ATTRIBUTE Attributes,
  278. IN ULONG AttributeCount,
  279. IN ULONG Options
  280. );
  281. NTSTATUS
  282. LsapDsReadAttributes(
  283. IN PUNICODE_STRING ObjectPath,
  284. IN ULONG Options,
  285. IN OUT PLSAP_DB_ATTRIBUTE Attributes,
  286. IN ULONG AttributeCount
  287. );
  288. NTSTATUS
  289. LsapDsReadAttributesByDsName(
  290. IN PDSNAME ObjectPath,
  291. IN ULONG Options,
  292. IN OUT PLSAP_DB_ATTRIBUTE Attributes,
  293. IN ULONG AttributeCount
  294. );
  295. NTSTATUS
  296. LsapDsRenameObject(
  297. IN PDSNAME OldObject,
  298. IN PDSNAME NewParent,
  299. IN ULONG AttrType,
  300. IN PUNICODE_STRING NewObject
  301. );
  302. NTSTATUS
  303. LsapDsDeleteAttributes(
  304. IN PUNICODE_STRING ObjectPath,
  305. IN OUT PLSAP_DB_ATTRIBUTE Attributes,
  306. IN ULONG AttributeCount
  307. );
  308. //
  309. // Interesting or global functions
  310. //
  311. PVOID
  312. LsapDsAlloc(
  313. IN DWORD dwLen
  314. );
  315. VOID
  316. LsapDsFree(
  317. IN PVOID pvMemory
  318. );
  319. NTSTATUS
  320. LsapDsInitializePromoteInterface(
  321. VOID
  322. );
  323. BOOLEAN
  324. LsapDsIsValidSid(
  325. IN PSID Sid,
  326. IN BOOLEAN DsSid
  327. );
  328. NTSTATUS
  329. LsapDsTruncateNameToFitCN(
  330. IN PUNICODE_STRING OriginalName,
  331. OUT PUNICODE_STRING TruncatedName
  332. );
  333. BOOLEAN
  334. LsapDsIsNtStatusResourceError(
  335. NTSTATUS NtStatus
  336. );
  337. NTSTATUS
  338. LsapDsReadObjectSDByDsName(
  339. IN DSNAME* Object,
  340. OUT PSECURITY_DESCRIPTOR *pSD
  341. );
  342. NTSTATUS
  343. LsapDsGetDefaultSecurityDescriptor(
  344. IN ULONG ClassId,
  345. OUT PSECURITY_DESCRIPTOR *ppSD,
  346. OUT ULONG *cbSD
  347. );
  348. #endif