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.

451 lines
12 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1992 - 1996
  6. //
  7. // File: kerb.h
  8. //
  9. // Contents: precompiled global include file for Kerberos security package
  10. //
  11. //
  12. // History: 14-Jan-1997 Created MikeSw
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef __KERB_H__
  16. #define __KERB_H__
  17. //
  18. // All global variables declared as EXTERN will be allocated in the file
  19. // that defines KERBP_ALLOCATE
  20. //
  21. #include "krbprgma.h"
  22. #ifndef WIN32_CHICAGO
  23. #ifndef UNICODE
  24. #define UNICODE
  25. #endif // UNICODE
  26. #endif // WIN32_CHICAGO
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif // __cplusplus
  31. #include <nt.h>
  32. #include <ntrtl.h>
  33. #include <nturtl.h>
  34. #ifndef WIN32_CHICAGO
  35. #include <ntlsa.h>
  36. #include <ntsam.h>
  37. #ifndef WIN32_LEAN_AND_MEAN
  38. #define WIN32_LEAN_AND_MEAN
  39. #endif // WIN32_LEAN_AND_MEAN
  40. #endif // WIN32_CHICAGO
  41. #include <windows.h>
  42. #include <minmax.h>
  43. #ifndef WIN32_CHICAGO
  44. #ifndef RPC_NO_WINDOWS_H
  45. #define RPC_NO_WINDOWS_H
  46. #endif // RPC_NO_WINDOWS_H
  47. #include <rpc.h>
  48. #endif // WIN32_CHICAGO
  49. #ifndef SECURITY_WIN32
  50. #define SECURITY_WIN32
  51. #endif // SECURITY_WIN32
  52. #include <malloc.h>
  53. #include <alloca.h>
  54. #define SECURITY_PACKAGE
  55. #define SECURITY_KERBEROS
  56. #ifdef WIN32_CHICAGO
  57. typedef LONG NTSTATUS, *PNTSTATUS;
  58. #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth
  59. #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L)
  60. #define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009AL) // ntsubauth
  61. #define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL)
  62. #define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS)0xC0000034L)
  63. #define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023L)
  64. #define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0L)
  65. #define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005L)
  66. #define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BBL)
  67. #define STATUS_INVALID_SERVER_STATE ((NTSTATUS)0xC00000DCL)
  68. #define STATUS_INTERNAL_ERROR ((NTSTATUS)0xC00000E5L)
  69. #define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L)
  70. #define STATUS_NO_SUCH_LOGON_SESSION ((NTSTATUS)0xC000005FL)
  71. #define STATUS_NETLOGON_NOT_STARTED ((NTSTATUS)0xC0000192L)
  72. #define STATUS_DOMAIN_CONTROLLER_NOT_FOUND ((NTSTATUS)0xC0000233L)
  73. #define STATUS_NO_LOGON_SERVERS ((NTSTATUS)0xC000005EL)
  74. #define STATUS_NO_SUCH_DOMAIN ((NTSTATUS)0xC00000DFL)
  75. #define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS)0xC0000061L)
  76. #define STATUS_INVALID_HANDLE ((NTSTATUS)0xC0000008L) // winnt
  77. #define STATUS_LOGON_FAILURE ((NTSTATUS)0xC000006DL) // ntsubauth
  78. #define STATUS_NO_SUCH_USER ((NTSTATUS)0xC0000064L) // ntsubauth
  79. #define STATUS_ACCOUNT_DISABLED ((NTSTATUS)0xC0000072L) // ntsubauth
  80. #define STATUS_ACCOUNT_RESTRICTION ((NTSTATUS)0xC000006EL) // ntsubauth
  81. #define STATUS_ACCOUNT_LOCKED_OUT ((NTSTATUS)0xC0000234L) // ntsubauth
  82. #define STATUS_WRONG_PASSWORD ((NTSTATUS)0xC000006AL) // ntsubauth
  83. #define STATUS_ACCOUNT_EXPIRED ((NTSTATUS)0xC0000193L) // ntsubauth
  84. #define STATUS_PASSWORD_EXPIRED ((NTSTATUS)0xC0000071L) // ntsubauth
  85. #define STATUS_ILL_FORMED_PASSWORD ((NTSTATUS)0xC000006BL)
  86. #define STATUS_NOT_COMMITTED ((NTSTATUS)0xC000002DL)
  87. #define STATUS_INVALID_INFO_CLASS ((NTSTATUS)0xC0000003L) // ntsubauth
  88. #define STATUS_INVALID_LOGON_TYPE ((NTSTATUS)0xC000010BL)
  89. #define STATUS_INVALID_LOGON_HOURS ((NTSTATUS)0xC000006FL) // ntsubauth
  90. #define STATUS_INVALID_WORKSTATION ((NTSTATUS)0xC0000070L) // ntsubauth
  91. #define STATUS_TIME_DIFFERENCE_AT_DC ((NTSTATUS)0xC0000133L)
  92. // from net\inc\ssi.h
  93. #define SSI_ACCOUNT_NAME_POSTFIX_CHAR L'$'
  94. typedef UNICODE_STRING *PUNICODE_STRING;
  95. #define UNICODE_NULL ((WCHAR)0) // winnt
  96. typedef ULONG CLONG;
  97. typedef short CSHORT;
  98. typedef STRING ANSI_STRING;
  99. typedef PSTRING PANSI_STRING;
  100. #endif // WIN32_CHICAGO
  101. #include <security.h>
  102. #include <wincred.h>
  103. #include <secint.h>
  104. #include <lsasecpk.h>
  105. #ifndef WIN32_CHICAGO
  106. #include <dsysdbg.h>
  107. #endif // !WIN32_CHICAGO
  108. #include <lmcons.h>
  109. #include <dsgetdc.h>
  110. #include <wincrypt.h>
  111. #include <dns.h>
  112. #include <winsock2.h>
  113. #ifndef WIN32_CHICAGO
  114. #include <lsarpc.h>
  115. #include <lmapibuf.h>
  116. #include <dnsapi.h>
  117. #include <lmcons.h>
  118. #include <lmerr.h>
  119. #include <dnssrv.h>
  120. #include <crypt.h>
  121. #include <cryptdll.h>
  122. #include <ntmsv1_0.h>
  123. #include <logonmsv.h>
  124. #include <lsaitf.h>
  125. #include <align.h>
  126. #include <netlib.h>
  127. #include <netlibnt.h> // NetpApiStatusToNtStatus
  128. #include <config.h> // NetpXXXConfigXXX
  129. #include <ssi.h> // SSI_ACCOUNT_NAME_POSTFIX_CHAR
  130. #include <lmsname.h>
  131. #include <ntdsapi.h>
  132. #define _AVOID_REPL_API
  133. #include <nlrepl.h>
  134. #undef _AVOID_REPL_API
  135. #else // WIN32_CHICAGO
  136. #include <assert.h> // C run-time definitions
  137. #include <limits.h>
  138. #endif // !WIN32_CHICAGO
  139. #include <sclogon.h>
  140. #include <sclogon2.h>
  141. #include <fileno.h>
  142. #ifdef __cplusplus
  143. }
  144. #endif // __cplusplus
  145. #ifdef WIN32_CHICAGO
  146. #define DsysAssert(exp) assert(exp)
  147. // from ntrtl.h
  148. // #define RtlOffsetToPointer(B,O) ((PCHAR)( ((PCHAR)(B)) + ((ULONG)(O)) ))
  149. #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
  150. // #define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && ((L1)->LowPart == (L2)->LowPart))
  151. //
  152. // Time conversion routines
  153. //
  154. typedef TIME_FIELDS *PTIME_FIELDS;
  155. //
  156. //
  157. // A time field record (Weekday ignored) -> 64 bit Time value
  158. //
  159. BOOLEAN
  160. MyRtlTimeFieldsToTime (
  161. PTIME_FIELDS TimeFields,
  162. PLARGE_INTEGER Time
  163. );
  164. #define RtlTimeFieldsToTime(x, y) MyRtlTimeFieldsToTime(x, y)
  165. VOID
  166. MyRtlTimeToTimeFields (
  167. PLARGE_INTEGER Time,
  168. PTIME_FIELDS TimeFields
  169. );
  170. #define RtlTimeToTimeFields(x, y) MyRtlTimeToTimeFields(x, y)
  171. VOID
  172. MyRtlFreeUnicodeString(
  173. PUNICODE_STRING UnicodeString
  174. );
  175. #define RtlFreeUnicodeString(x) MyRtlFreeUnicodeString(x)
  176. LONG
  177. MyRtlCompareUnicodeString(
  178. PUNICODE_STRING String1,
  179. PUNICODE_STRING String2,
  180. BOOLEAN CaseInSensitive
  181. );
  182. #define RtlCompareUnicodeString(x, y, z) MyRtlCompareUnicodeString(x, y, z)
  183. VOID
  184. MyRtlInitString(
  185. PSTRING DestinationString,
  186. PCSTR SourceString
  187. );
  188. #define RtlInitString(x, y) MyRtlInitString(x, y)
  189. VOID
  190. MyRtlInitAnsiString(
  191. PANSI_STRING DestinationString,
  192. PCSTR SourceString
  193. );
  194. #define RtlInitAnsiString(x, y) MyRtlInitAnsiString(x, y)
  195. VOID
  196. MyRtlFreeAnsiString(
  197. PANSI_STRING AnsiString
  198. );
  199. #define RtlFreeAnsiString(x) MyRtlFreeAnsiString(x)
  200. NTSTATUS
  201. MyRtlUnicodeStringToAnsiString(
  202. PANSI_STRING DestinationString,
  203. PUNICODE_STRING SourceString,
  204. BOOLEAN AllocateDestinationString
  205. );
  206. #define RtlUnicodeStringToAnsiString(x, y, z) MyRtlUnicodeStringToAnsiString(x, y, z)
  207. NTSTATUS
  208. MyRtlAnsiStringToUnicodeString(
  209. PUNICODE_STRING DestinationString,
  210. PANSI_STRING SourceString,
  211. BOOLEAN AllocateDestinationString
  212. );
  213. #define RtlAnsiStringToUnicodeString(x, y, z) MyRtlAnsiStringToUnicodeString(x, y, z)
  214. NTSYSAPI
  215. VOID
  216. NTAPI
  217. RtlRunDecodeUnicodeString(
  218. UCHAR Seed,
  219. PUNICODE_STRING String
  220. );
  221. BOOLEAN
  222. MyRtlEqualDomainName(
  223. IN PUNICODE_STRING String1,
  224. IN PUNICODE_STRING String2
  225. );
  226. #define RtlEqualDomainName(x, y) MyRtlEqualDomainName(x, y)
  227. #ifdef __cplusplus // cause it's called from passwd.c !!
  228. extern "C"
  229. {
  230. #endif // __cplusplus
  231. VOID
  232. MyRtlInitUnicodeString(
  233. PUNICODE_STRING DestinationString,
  234. PCWSTR SourceString
  235. );
  236. #define RtlInitUnicodeString(x,y) MyRtlInitUnicodeString(x, y)
  237. BOOLEAN
  238. MyRtlEqualUnicodeString(
  239. PUNICODE_STRING String1,
  240. PUNICODE_STRING String2,
  241. BOOLEAN CaseInSensitive
  242. );
  243. #define RtlEqualUnicodeString(x, y, z) MyRtlEqualUnicodeString(x, y, z)
  244. NTSTATUS
  245. MyRtlUpcaseUnicodeString(
  246. PUNICODE_STRING DestinationString,
  247. PUNICODE_STRING SourceString,
  248. BOOLEAN AllocateDestinationString
  249. );
  250. #define RtlUpcaseUnicodeString(x, y, z) MyRtlUpcaseUnicodeString(x, y, z)
  251. NTSTATUS
  252. NTAPI
  253. MyRtlConvertSidToUnicodeString(
  254. PUNICODE_STRING UnicodeString,
  255. PSID Sid,
  256. BOOLEAN AllocateDestinationString
  257. );
  258. #define RtlConvertSidToUnicodeString(x, y, z) MyRtlConvertSidToUnicodeString(x, y, z)
  259. #ifdef __cplusplus
  260. }
  261. #endif // __cplusplus
  262. NTSTATUS
  263. RtlDowncaseUnicodeString(
  264. OUT PUNICODE_STRING DestinationString,
  265. IN PUNICODE_STRING SourceString,
  266. IN BOOLEAN AllocateDestinationString
  267. );
  268. NTSYSAPI
  269. ULONG
  270. NTAPI
  271. RtlLengthSid (
  272. PSID Sid
  273. );
  274. NTSYSAPI // ntifs
  275. NTSTATUS // ntifs
  276. NTAPI // ntifs
  277. RtlCreateAcl ( // ntifs
  278. PACL Acl, // ntifs
  279. ULONG AclLength, // ntifs
  280. ULONG AclRevision // ntifs
  281. ); // ntifs
  282. NTSYSAPI // ntifs
  283. NTSTATUS // ntifs
  284. NTAPI // ntifs
  285. RtlAddAccessAllowedAce ( // ntifs
  286. PACL Acl, // ntifs
  287. ULONG AceRevision, // ntifs
  288. ACCESS_MASK AccessMask, // ntifs
  289. PSID Sid // ntifs
  290. ); // ntifs
  291. NTSYSAPI
  292. NTSTATUS
  293. NTAPI
  294. RtlCreateSecurityDescriptor (
  295. PSECURITY_DESCRIPTOR SecurityDescriptor,
  296. ULONG Revision
  297. );
  298. NTSYSAPI
  299. NTSTATUS
  300. NTAPI
  301. RtlSetDaclSecurityDescriptor (
  302. PSECURITY_DESCRIPTOR SecurityDescriptor,
  303. BOOLEAN DaclPresent,
  304. PACL Dacl,
  305. BOOLEAN DaclDefaulted
  306. );
  307. // from ntexapi.h
  308. NTSTATUS
  309. MyNtQuerySystemTime (
  310. OUT PTimeStamp SystemTime
  311. );
  312. #define NtQuerySystemTime(x) MyNtQuerySystemTime(x)
  313. NTSTATUS
  314. MyNtAllocateLocallyUniqueId(
  315. OUT PLUID Luid
  316. );
  317. #define NtAllocateLocallyUniqueId(x) MyNtAllocateLocallyUniqueId(x)
  318. // from ntobapi.h
  319. NTSYSAPI
  320. NTSTATUS
  321. NTAPI
  322. NtClose(
  323. IN HANDLE Handle
  324. );
  325. NTSYSAPI
  326. NTSTATUS
  327. NTAPI
  328. NtSetSecurityObject(
  329. IN HANDLE Handle,
  330. IN SECURITY_INFORMATION SecurityInformation,
  331. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  332. );
  333. // from ntseapi.h
  334. //
  335. // used for password manipulations
  336. //
  337. NTSYSAPI
  338. NTSTATUS
  339. NTAPI
  340. NtOpenProcessToken(
  341. IN HANDLE ProcessHandle,
  342. IN ACCESS_MASK DesiredAccess,
  343. OUT PHANDLE TokenHandle
  344. );
  345. // from ntpsapi.h
  346. #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 )
  347. // from ntdef.h
  348. #define MAXUSHORT 0xffff
  349. BOOLEAN
  350. MyRtlCreateUnicodeStringFromAsciiz(
  351. OUT PUNICODE_STRING DestinationString,
  352. IN PCSTR SourceString
  353. );
  354. #define RtlCreateUnicodeStringFromAsciiz(x, y) MyRtlCreateUnicodeStringFromAsciiz(x, y)
  355. #define RtlInitializeCriticalSection(x) (InitializeCriticalSection(x),0)
  356. #define RtlDeleteCriticalSection(x) (DeleteCriticalSection(x),0)
  357. #define RtlEnterCriticalSection(x) (EnterCriticalSection(x),0)
  358. #define RtlLeaveCriticalSection(x) (LeaveCriticalSection(x),0)
  359. #define RtlInitializeResource(x) (InitializeCriticalSection(x),0)
  360. #define RtlDeleteResource(x) (DeleteCriticalSection(x))
  361. #endif // WIN32_CHICAGO
  362. #include <kerbcomm.h>
  363. #include <kdcexp.h>
  364. #define INITGUID
  365. #include "kerbtrace.h"
  366. VOID
  367. FreAssert(
  368. IN BOOL Expression,
  369. IN CHAR * String
  370. );
  371. #define FRE_ASSERT( _x_ ) FreAssert( _x_, #_x_ )
  372. #endif // __KERB_H__