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.

407 lines
8.9 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. uasp.h
  5. Abstract:
  6. Private declartions for function defined in uasp.c, aliasp.c,
  7. groupp.c, and userp.c
  8. Author:
  9. Cliff Van Dyke (cliffv) 20-Feb-1991
  10. Environment:
  11. User mode only.
  12. Contains NT-specific code.
  13. Requires ANSI C extensions: slash-slash comments, long external names.
  14. Revision History:
  15. 17-Apr-1991 (cliffv)
  16. Incorporated review comments.
  17. 09-Apr-1992 JohnRo
  18. Prepare for WCHAR.H (_wcsicmp vs _wcscmpi, etc).
  19. 28-Oct-1992 RitaW
  20. Added private support routines for localgroups (aliases)
  21. 30-Nov-1992 Johnl
  22. Added AliaspOpenAlias2 (same as AliaspOpenAlias except operates on
  23. RID instead of account name).
  24. --*/
  25. //
  26. // Procedure Forwards for uasp.c
  27. //
  28. NET_API_STATUS
  29. UaspOpenSam(
  30. IN LPCWSTR ServerName OPTIONAL,
  31. IN BOOL AllowNullSession,
  32. OUT PSAM_HANDLE SamServerHandle
  33. );
  34. NET_API_STATUS
  35. UaspOpenDomain(
  36. IN SAM_HANDLE SamServerHandle,
  37. IN ULONG DesiredAccess,
  38. IN BOOL AccountDomain,
  39. OUT PSAM_HANDLE DomainHandle,
  40. OUT PSID *DomainId OPTIONAL
  41. );
  42. NET_API_STATUS
  43. UaspOpenDomainWithDomainName(
  44. IN LPCWSTR DomainName,
  45. IN ULONG DesiredAccess,
  46. IN BOOL AccountDomain,
  47. OUT PSAM_HANDLE DomainHandle,
  48. OUT PSID *DomainId OPTIONAL
  49. );
  50. VOID
  51. UaspCloseDomain(
  52. IN SAM_HANDLE DomainHandle
  53. );
  54. NET_API_STATUS
  55. UaspGetDomainId(
  56. IN SAM_HANDLE SamServerHandle,
  57. OUT PSID *DomainId
  58. );
  59. NET_API_STATUS
  60. UaspLSASetServerRole(
  61. IN LPCWSTR ServerName,
  62. IN PDOMAIN_SERVER_ROLE_INFORMATION DomainServerRole
  63. );
  64. NET_API_STATUS
  65. UaspBuiltinDomainSetServerRole(
  66. IN SAM_HANDLE SamServerHandle,
  67. IN PDOMAIN_SERVER_ROLE_INFORMATION DomainServerRole
  68. );
  69. //
  70. // Procedure forwards for aliasp.c
  71. //
  72. typedef enum _ALIASP_DOMAIN_TYPE {
  73. AliaspBuiltinOrAccountDomain,
  74. AliaspAccountDomain,
  75. AliaspBuiltinDomain
  76. } ALIASP_DOMAIN_TYPE;
  77. NET_API_STATUS
  78. AliaspOpenAliasInDomain(
  79. IN SAM_HANDLE SamServerHandle,
  80. IN ALIASP_DOMAIN_TYPE DomainType,
  81. IN ACCESS_MASK DesiredAccess,
  82. IN LPCWSTR AliasName,
  83. OUT PSAM_HANDLE AliasHandle
  84. );
  85. NET_API_STATUS
  86. AliaspOpenAlias(
  87. IN SAM_HANDLE DomainHandle,
  88. IN ACCESS_MASK DesiredAccess,
  89. IN LPCWSTR AliasName,
  90. OUT PSAM_HANDLE AliasHandle
  91. );
  92. NET_API_STATUS
  93. AliaspOpenAlias2(
  94. IN SAM_HANDLE DomainHandle,
  95. IN ACCESS_MASK DesiredAccess,
  96. IN ULONG RelativeID,
  97. OUT PSAM_HANDLE AliasHandle
  98. );
  99. NET_API_STATUS
  100. AliaspChangeMember(
  101. IN LPCWSTR ServerName OPTIONAL,
  102. IN LPCWSTR AliasName,
  103. IN PSID MemberSid,
  104. IN BOOL AddMember
  105. );
  106. typedef enum {
  107. SetMembers,
  108. AddMembers,
  109. DelMembers
  110. } ALIAS_MEMBER_CHANGE_TYPE;
  111. NET_API_STATUS
  112. AliaspSetMembers (
  113. IN LPCWSTR ServerName OPTIONAL,
  114. IN LPCWSTR AliasName,
  115. IN DWORD Level,
  116. IN LPBYTE Buffer,
  117. IN DWORD NewMemberCount,
  118. IN ALIAS_MEMBER_CHANGE_TYPE
  119. );
  120. NET_API_STATUS
  121. AliaspGetInfo(
  122. IN SAM_HANDLE AliasHandle,
  123. IN DWORD Level,
  124. OUT PVOID *Buffer
  125. );
  126. VOID
  127. AliaspRelocationRoutine(
  128. IN DWORD Level,
  129. IN OUT PBUFFER_DESCRIPTOR BufferDescriptor,
  130. IN PTRDIFF_T Offset
  131. );
  132. VOID
  133. AliaspMemberRelocationRoutine(
  134. IN DWORD Level,
  135. IN OUT PBUFFER_DESCRIPTOR BufferDescriptor,
  136. IN PTRDIFF_T Offset
  137. );
  138. NET_API_STATUS
  139. AliaspPackBuf(
  140. IN DWORD Level,
  141. IN DWORD PrefMaxLen,
  142. IN DWORD EntriesCount,
  143. OUT LPDWORD EntriesRead,
  144. BUFFER_DESCRIPTOR *BufferDescriptor,
  145. DWORD FixedSize,
  146. PUNICODE_STRING Names) ;
  147. NET_API_STATUS
  148. AliaspNamesToSids (
  149. IN LPCWSTR ServerName,
  150. IN BOOL OnlyAllowUsers,
  151. IN DWORD NameCount,
  152. IN LPWSTR *Names,
  153. OUT PSID **Sids
  154. );
  155. VOID
  156. AliaspFreeSidList (
  157. IN DWORD SidCount,
  158. IN PSID *Sids
  159. );
  160. //
  161. // Procedure forwards for groupp.c
  162. //
  163. NET_API_STATUS
  164. GrouppOpenGroup(
  165. IN SAM_HANDLE DomainHandle,
  166. IN ACCESS_MASK DesiredAccess,
  167. IN LPCWSTR GroupName,
  168. OUT PSAM_HANDLE GroupHandle OPTIONAL,
  169. OUT PULONG RelativeId OPTIONAL
  170. );
  171. NET_API_STATUS
  172. GrouppChangeMember(
  173. IN LPCWSTR ServerName OPTIONAL,
  174. IN LPCWSTR GroupName,
  175. IN LPCWSTR UserName,
  176. IN BOOL AddMember
  177. );
  178. NET_API_STATUS
  179. GrouppGetInfo(
  180. IN SAM_HANDLE DomainHandle,
  181. IN ULONG RelativeId,
  182. IN DWORD Level,
  183. OUT PVOID *Buffer // Caller must deallocate buffer using NetApiBufferFree.
  184. );
  185. VOID
  186. GrouppRelocationRoutine(
  187. IN DWORD Level,
  188. IN OUT PBUFFER_DESCRIPTOR BufferDescriptor,
  189. IN PTRDIFF_T Offset
  190. );
  191. VOID
  192. GrouppMemberRelocationRoutine(
  193. IN DWORD Level,
  194. IN OUT PBUFFER_DESCRIPTOR BufferDescriptor,
  195. IN PTRDIFF_T Offset
  196. );
  197. NET_API_STATUS
  198. GrouppSetUsers (
  199. IN LPCWSTR ServerName OPTIONAL,
  200. IN LPCWSTR GroupName,
  201. IN DWORD Level,
  202. IN LPBYTE Buffer,
  203. IN DWORD NewMemberCount,
  204. IN BOOL DeleteGroup
  205. );
  206. //
  207. // Procedure forwards for userp.c
  208. //
  209. NET_API_STATUS
  210. UserpOpenUser(
  211. IN SAM_HANDLE DomainHandle,
  212. IN ACCESS_MASK DesiredAccess,
  213. IN LPCWSTR UserName,
  214. OUT PSAM_HANDLE UserHandle OPTIONAL,
  215. OUT PULONG RelativeId OPTIONAL
  216. );
  217. NET_API_STATUS
  218. UserpGetInfo(
  219. IN SAM_HANDLE DomainHandle,
  220. IN PSID DomainId,
  221. IN SAM_HANDLE BuiltinDomainHandle OPTIONAL,
  222. IN UNICODE_STRING UserName,
  223. IN ULONG UserRelativeId,
  224. IN DWORD Level,
  225. IN DWORD PrefMaxLen,
  226. IN OUT PBUFFER_DESCRIPTOR BufferDescriptor,
  227. // Caller must deallocate BD->Buffer using MIDL_user_free.
  228. IN BOOL IsGet,
  229. IN DWORD SamFilter
  230. );
  231. NET_API_STATUS
  232. UserpSetInfo(
  233. IN SAM_HANDLE DomainHandle,
  234. IN PSID DomainId,
  235. IN SAM_HANDLE UserHandle OPTIONAL,
  236. IN SAM_HANDLE BuiltinDomainHandle OPTIONAL,
  237. IN ULONG UserRelativeId,
  238. IN LPCWSTR UserName,
  239. IN DWORD Level,
  240. IN LPBYTE Buffer,
  241. IN ULONG WhichFieldsMask,
  242. OUT LPDWORD ParmError OPTIONAL // Name required by NetpSetParmError
  243. );
  244. ULONG
  245. NetpDeltaTimeToSeconds(
  246. IN LARGE_INTEGER DeltaTime
  247. );
  248. LARGE_INTEGER
  249. NetpSecondsToDeltaTime(
  250. IN ULONG Seconds
  251. );
  252. DWORD
  253. NetpGetElapsedSeconds(
  254. IN PLARGE_INTEGER Time
  255. );
  256. //
  257. // Determine if the passed in DWORD has precisely one bit set.
  258. //
  259. #define JUST_ONE_BIT( _x ) (((_x) != 0 ) && ( ( (~(_x) + 1) & (_x) ) == (_x) ))
  260. //
  261. // Local macro to add a byte offset to a pointer.
  262. //
  263. #define RELOCATE_ONE( _fieldname, _offset ) \
  264. _fieldname = (PVOID) ((LPBYTE)(_fieldname) + _offset)
  265. ////////////////////////////////////////////////////////////////////////
  266. //
  267. // UaspNameCompare
  268. //
  269. // I_NetNameCompare but always takes UNICODE strings
  270. //
  271. ////////////////////////////////////////////////////////////////////////
  272. #ifdef UNICODE
  273. #define UaspNameCompare( _name1, _name2, _nametype ) \
  274. I_NetNameCompare(NULL, (_name1), (_name2), (_nametype), 0 )
  275. #else // UNICODE
  276. #define UaspNameCompare( _name1, _name2, _nametype ) \
  277. _wcsicmp( (_name1), (_name2) )
  278. #endif // UNICODE
  279. ////////////////////////////////////////////////////////////////////////
  280. //
  281. // UASP_DOWNLEVEL
  282. //
  283. // Decide if call is to be made to a downlevel server.
  284. // This macro contains a 'return', so do not allocate any resources
  285. // before calling this macro.
  286. //
  287. ////////////////////////////////////////////////////////////////////////
  288. NET_API_STATUS
  289. UaspDownlevel(
  290. IN LPCWSTR ServerName OPTIONAL,
  291. IN NET_API_STATUS OriginalError,
  292. OUT LPBOOL TryDownLevel
  293. );
  294. #define UASP_DOWNLEVEL_BEGIN( _ServerName, _NetStatus ) \
  295. if ( _NetStatus != NERR_Success && \
  296. _NetStatus != ERROR_MORE_DATA ) { \
  297. BOOL TryDownLevel; \
  298. \
  299. _NetStatus = UaspDownlevel( \
  300. _ServerName, \
  301. _NetStatus, \
  302. &TryDownLevel \
  303. ); \
  304. \
  305. if (TryDownLevel) {
  306. #define UASP_DOWNLEVEL_END \
  307. } \
  308. }
  309. //
  310. // Debug Macros
  311. //
  312. #define UAS_DEBUG_USER 0x00000001 // NetUser APIs
  313. #define UAS_DEBUG_GROUP 0x00000002 // NetGroup APIs
  314. #define UAS_DEBUG_ACCESS 0x00000004 // NetAccess APIs
  315. #define UAS_DEBUG_ALIAS 0x00000008 // NetLocalGroup APIs
  316. #define UAS_DEBUG_UASP 0x00000010 // uasp.c
  317. #define UAS_DEBUG_AUASP 0x00000020 // uasp.c LocalGroup related functions
  318. #if DBG
  319. #define UAS_DEBUG
  320. #endif // DBG
  321. #ifdef UAS_DEBUG
  322. extern DWORD UasTrace;
  323. #define IF_DEBUG(Function) if (UasTrace & Function)
  324. #else
  325. /*lint -e614 */ /* Auto aggregate initializers need not be constant */
  326. #define IF_DEBUG(Function) if (FALSE)
  327. #endif // UAS_DEBUG