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.

366 lines
12 KiB

  1. /*++ BUILD Version: 0005 Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. subauth.h
  5. Abstract:
  6. This module defines types and macros for Subauthentication Packages.
  7. Revision History:
  8. --*/
  9. #ifndef _NTSUBAUTH_
  10. #define _NTSUBAUTH_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #if (!defined(_NTDEF_)) && (!defined(_NTSECAPI_))
  15. typedef LONG NTSTATUS, *PNTSTATUS;
  16. typedef struct _UNICODE_STRING {
  17. USHORT Length;
  18. USHORT MaximumLength;
  19. PWSTR Buffer;
  20. } UNICODE_STRING, *PUNICODE_STRING;
  21. typedef struct _STRING {
  22. USHORT Length;
  23. USHORT MaximumLength;
  24. PCHAR Buffer;
  25. } STRING, *PSTRING;
  26. #endif
  27. #ifndef _NTDEF_
  28. typedef struct _OLD_LARGE_INTEGER {
  29. ULONG LowPart;
  30. LONG HighPart;
  31. } OLD_LARGE_INTEGER, *POLD_LARGE_INTEGER;
  32. #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
  33. #endif
  34. #ifndef _NTSAM_SAM_HANDLE_
  35. typedef PVOID SAM_HANDLE, *PSAM_HANDLE;
  36. #define _NTSAM_SAM_HANDLE_
  37. #endif
  38. #ifndef _NTSAM_USER_ACCOUNT_FLAGS_
  39. //
  40. // User account control flags...
  41. //
  42. #define USER_ACCOUNT_DISABLED (0x00000001)
  43. #define USER_HOME_DIRECTORY_REQUIRED (0x00000002)
  44. #define USER_PASSWORD_NOT_REQUIRED (0x00000004)
  45. #define USER_TEMP_DUPLICATE_ACCOUNT (0x00000008)
  46. #define USER_NORMAL_ACCOUNT (0x00000010)
  47. #define USER_MNS_LOGON_ACCOUNT (0x00000020)
  48. #define USER_INTERDOMAIN_TRUST_ACCOUNT (0x00000040)
  49. #define USER_WORKSTATION_TRUST_ACCOUNT (0x00000080)
  50. #define USER_SERVER_TRUST_ACCOUNT (0x00000100)
  51. #define USER_DONT_EXPIRE_PASSWORD (0x00000200)
  52. #define USER_ACCOUNT_AUTO_LOCKED (0x00000400)
  53. #define USER_ENCRYPTED_TEXT_PASSWORD_ALLOWED (0x00000800)
  54. #define USER_SMARTCARD_REQUIRED (0x00001000)
  55. #define USER_TRUSTED_FOR_DELEGATION (0x00002000)
  56. #define USER_NOT_DELEGATED (0x00004000)
  57. #define USER_USE_DES_KEY_ONLY (0x00008000)
  58. #define USER_DONT_REQUIRE_PREAUTH (0x00010000)
  59. #define USER_PASSWORD_EXPIRED (0x00020000)
  60. #define USER_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION (0x00040000)
  61. #define NEXT_FREE_ACCOUNT_CONTROL_BIT (USER_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION << 1)
  62. #define USER_MACHINE_ACCOUNT_MASK \
  63. ( USER_INTERDOMAIN_TRUST_ACCOUNT |\
  64. USER_WORKSTATION_TRUST_ACCOUNT |\
  65. USER_SERVER_TRUST_ACCOUNT)
  66. #define USER_ACCOUNT_TYPE_MASK \
  67. ( USER_TEMP_DUPLICATE_ACCOUNT |\
  68. USER_NORMAL_ACCOUNT |\
  69. USER_MACHINE_ACCOUNT_MASK )
  70. #define USER_COMPUTED_ACCOUNT_CONTROL_BITS \
  71. (USER_ACCOUNT_AUTO_LOCKED | \
  72. USER_PASSWORD_EXPIRED )
  73. //
  74. // Logon times may be expressed in day, hour, or minute granularity.
  75. //
  76. // Days per week = 7
  77. // Hours per week = 168
  78. // Minutes per week = 10080
  79. //
  80. #define SAM_DAYS_PER_WEEK (7)
  81. #define SAM_HOURS_PER_WEEK (24 * SAM_DAYS_PER_WEEK)
  82. #define SAM_MINUTES_PER_WEEK (60 * SAM_HOURS_PER_WEEK)
  83. typedef struct _LOGON_HOURS {
  84. USHORT UnitsPerWeek;
  85. //
  86. // UnitsPerWeek is the number of equal length time units the week is
  87. // divided into. This value is used to compute the length of the bit
  88. // string in logon_hours. Must be less than or equal to
  89. // SAM_UNITS_PER_WEEK (10080) for this release.
  90. //
  91. // LogonHours is a bit map of valid logon times. Each bit represents
  92. // a unique division in a week. The largest bit map supported is 1260
  93. // bytes (10080 bits), which represents minutes per week. In this case
  94. // the first bit (bit 0, byte 0) is Sunday, 00:00:00 - 00-00:59; bit 1,
  95. // byte 0 is Sunday, 00:01:00 - 00:01:59, etc. A NULL pointer means
  96. // DONT_CHANGE for SamSetInformationUser() calls.
  97. //
  98. PUCHAR LogonHours;
  99. } LOGON_HOURS, *PLOGON_HOURS;
  100. typedef struct _SR_SECURITY_DESCRIPTOR {
  101. ULONG Length;
  102. PUCHAR SecurityDescriptor;
  103. } SR_SECURITY_DESCRIPTOR, *PSR_SECURITY_DESCRIPTOR;
  104. #define _NTSAM_USER_ACCOUNT_FLAG_
  105. #endif
  106. #ifndef _NTSAM_USER_ALL_INFO_
  107. #include "pshpack4.h"
  108. typedef struct _USER_ALL_INFORMATION {
  109. LARGE_INTEGER LastLogon;
  110. LARGE_INTEGER LastLogoff;
  111. LARGE_INTEGER PasswordLastSet;
  112. LARGE_INTEGER AccountExpires;
  113. LARGE_INTEGER PasswordCanChange;
  114. LARGE_INTEGER PasswordMustChange;
  115. UNICODE_STRING UserName;
  116. UNICODE_STRING FullName;
  117. UNICODE_STRING HomeDirectory;
  118. UNICODE_STRING HomeDirectoryDrive;
  119. UNICODE_STRING ScriptPath;
  120. UNICODE_STRING ProfilePath;
  121. UNICODE_STRING AdminComment;
  122. UNICODE_STRING WorkStations;
  123. UNICODE_STRING UserComment;
  124. UNICODE_STRING Parameters;
  125. UNICODE_STRING LmPassword;
  126. UNICODE_STRING NtPassword;
  127. UNICODE_STRING PrivateData;
  128. SR_SECURITY_DESCRIPTOR SecurityDescriptor;
  129. ULONG UserId;
  130. ULONG PrimaryGroupId;
  131. ULONG UserAccountControl;
  132. ULONG WhichFields;
  133. LOGON_HOURS LogonHours;
  134. USHORT BadPasswordCount;
  135. USHORT LogonCount;
  136. USHORT CountryCode;
  137. USHORT CodePage;
  138. BOOLEAN LmPasswordPresent;
  139. BOOLEAN NtPasswordPresent;
  140. BOOLEAN PasswordExpired;
  141. BOOLEAN PrivateDataSensitive;
  142. } USER_ALL_INFORMATION, *PUSER_ALL_INFORMATION;
  143. #include "poppack.h"
  144. #define _NTSAM_USER_ALL_INFO_
  145. #endif
  146. #ifndef _NTSAM_SAM_USER_PARMS_
  147. #define USER_ALL_PARAMETERS 0x00200000
  148. #define _NTSAM_SAM_USER_PARMS_
  149. #endif
  150. #define CLEAR_BLOCK_LENGTH 8
  151. typedef struct _CLEAR_BLOCK {
  152. CHAR data[CLEAR_BLOCK_LENGTH];
  153. } CLEAR_BLOCK;
  154. typedef CLEAR_BLOCK * PCLEAR_BLOCK;
  155. #define CYPHER_BLOCK_LENGTH 8
  156. typedef struct _CYPHER_BLOCK {
  157. CHAR data[CYPHER_BLOCK_LENGTH];
  158. } CYPHER_BLOCK;
  159. typedef CYPHER_BLOCK * PCYPHER_BLOCK;
  160. typedef struct _LM_OWF_PASSWORD {
  161. CYPHER_BLOCK data[2];
  162. } LM_OWF_PASSWORD;
  163. typedef LM_OWF_PASSWORD * PLM_OWF_PASSWORD;
  164. typedef CLEAR_BLOCK LM_CHALLENGE;
  165. typedef LM_CHALLENGE * PLM_CHALLENGE;
  166. typedef LM_OWF_PASSWORD NT_OWF_PASSWORD;
  167. typedef NT_OWF_PASSWORD * PNT_OWF_PASSWORD;
  168. typedef LM_CHALLENGE NT_CHALLENGE;
  169. typedef NT_CHALLENGE * PNT_CHALLENGE;
  170. #define USER_SESSION_KEY_LENGTH (CYPHER_BLOCK_LENGTH * 2)
  171. typedef struct _USER_SESSION_KEY {
  172. CYPHER_BLOCK data[2];
  173. } USER_SESSION_KEY;
  174. typedef USER_SESSION_KEY * PUSER_SESSION_KEY;
  175. typedef enum _NETLOGON_LOGON_INFO_CLASS {
  176. NetlogonInteractiveInformation = 1,
  177. NetlogonNetworkInformation,
  178. NetlogonServiceInformation,
  179. NetlogonGenericInformation,
  180. NetlogonInteractiveTransitiveInformation,
  181. NetlogonNetworkTransitiveInformation,
  182. NetlogonServiceTransitiveInformation
  183. } NETLOGON_LOGON_INFO_CLASS;
  184. typedef struct _NETLOGON_LOGON_IDENTITY_INFO {
  185. UNICODE_STRING LogonDomainName;
  186. ULONG ParameterControl;
  187. OLD_LARGE_INTEGER LogonId;
  188. UNICODE_STRING UserName;
  189. UNICODE_STRING Workstation;
  190. } NETLOGON_LOGON_IDENTITY_INFO,
  191. *PNETLOGON_LOGON_IDENTITY_INFO;
  192. typedef struct _NETLOGON_INTERACTIVE_INFO {
  193. NETLOGON_LOGON_IDENTITY_INFO Identity;
  194. LM_OWF_PASSWORD LmOwfPassword;
  195. NT_OWF_PASSWORD NtOwfPassword;
  196. } NETLOGON_INTERACTIVE_INFO,
  197. *PNETLOGON_INTERACTIVE_INFO;
  198. typedef struct _NETLOGON_SERVICE_INFO {
  199. NETLOGON_LOGON_IDENTITY_INFO Identity;
  200. LM_OWF_PASSWORD LmOwfPassword;
  201. NT_OWF_PASSWORD NtOwfPassword;
  202. } NETLOGON_SERVICE_INFO, *PNETLOGON_SERVICE_INFO;
  203. typedef struct _NETLOGON_NETWORK_INFO {
  204. NETLOGON_LOGON_IDENTITY_INFO Identity;
  205. LM_CHALLENGE LmChallenge;
  206. STRING NtChallengeResponse;
  207. STRING LmChallengeResponse;
  208. } NETLOGON_NETWORK_INFO, *PNETLOGON_NETWORK_INFO;
  209. typedef struct _NETLOGON_GENERIC_INFO {
  210. NETLOGON_LOGON_IDENTITY_INFO Identity;
  211. UNICODE_STRING PackageName;
  212. ULONG DataLength;
  213. #ifdef MIDL_PASS
  214. [size_is(DataLength)]
  215. #endif
  216. PUCHAR LogonData;
  217. } NETLOGON_GENERIC_INFO, *PNETLOGON_GENERIC_INFO;
  218. // Values for Flags
  219. #define MSV1_0_PASSTHRU 0x01
  220. #define MSV1_0_GUEST_LOGON 0x02
  221. NTSTATUS NTAPI
  222. Msv1_0SubAuthenticationRoutine(
  223. IN NETLOGON_LOGON_INFO_CLASS LogonLevel,
  224. IN PVOID LogonInformation,
  225. IN ULONG Flags,
  226. IN PUSER_ALL_INFORMATION UserAll,
  227. OUT PULONG WhichFields,
  228. OUT PULONG UserFlags,
  229. OUT PBOOLEAN Authoritative,
  230. OUT PLARGE_INTEGER LogoffTime,
  231. OUT PLARGE_INTEGER KickoffTime
  232. );
  233. typedef struct _MSV1_0_VALIDATION_INFO {
  234. LARGE_INTEGER LogoffTime;
  235. LARGE_INTEGER KickoffTime;
  236. UNICODE_STRING LogonServer;
  237. UNICODE_STRING LogonDomainName;
  238. USER_SESSION_KEY SessionKey;
  239. BOOLEAN Authoritative;
  240. ULONG UserFlags;
  241. ULONG WhichFields;
  242. ULONG UserId;
  243. } MSV1_0_VALIDATION_INFO, *PMSV1_0_VALIDATION_INFO;
  244. // values for WhichFields
  245. #define MSV1_0_VALIDATION_LOGOFF_TIME 0x00000001
  246. #define MSV1_0_VALIDATION_KICKOFF_TIME 0x00000002
  247. #define MSV1_0_VALIDATION_LOGON_SERVER 0x00000004
  248. #define MSV1_0_VALIDATION_LOGON_DOMAIN 0x00000008
  249. #define MSV1_0_VALIDATION_SESSION_KEY 0x00000010
  250. #define MSV1_0_VALIDATION_USER_FLAGS 0x00000020
  251. #define MSV1_0_VALIDATION_USER_ID 0x00000040
  252. // legal values for ActionsPerformed
  253. #define MSV1_0_SUBAUTH_ACCOUNT_DISABLED 0x00000001
  254. #define MSV1_0_SUBAUTH_PASSWORD 0x00000002
  255. #define MSV1_0_SUBAUTH_WORKSTATIONS 0x00000004
  256. #define MSV1_0_SUBAUTH_LOGON_HOURS 0x00000008
  257. #define MSV1_0_SUBAUTH_ACCOUNT_EXPIRY 0x00000010
  258. #define MSV1_0_SUBAUTH_PASSWORD_EXPIRY 0x00000020
  259. #define MSV1_0_SUBAUTH_ACCOUNT_TYPE 0x00000040
  260. #define MSV1_0_SUBAUTH_LOCKOUT 0x00000080
  261. NTSTATUS NTAPI
  262. Msv1_0SubAuthenticationRoutineEx(
  263. IN NETLOGON_LOGON_INFO_CLASS LogonLevel,
  264. IN PVOID LogonInformation,
  265. IN ULONG Flags,
  266. IN PUSER_ALL_INFORMATION UserAll,
  267. IN SAM_HANDLE UserHandle,
  268. IN OUT PMSV1_0_VALIDATION_INFO ValidationInfo,
  269. OUT PULONG ActionsPerformed
  270. );
  271. NTSTATUS NTAPI
  272. Msv1_0SubAuthenticationRoutineGeneric(
  273. IN PVOID SubmitBuffer,
  274. IN ULONG SubmitBufferLength,
  275. OUT PULONG ReturnBufferLength,
  276. OUT PVOID *ReturnBuffer
  277. );
  278. NTSTATUS NTAPI
  279. Msv1_0SubAuthenticationFilter(
  280. IN NETLOGON_LOGON_INFO_CLASS LogonLevel,
  281. IN PVOID LogonInformation,
  282. IN ULONG Flags,
  283. IN PUSER_ALL_INFORMATION UserAll,
  284. OUT PULONG WhichFields,
  285. OUT PULONG UserFlags,
  286. OUT PBOOLEAN Authoritative,
  287. OUT PLARGE_INTEGER LogoffTime,
  288. OUT PLARGE_INTEGER KickoffTime
  289. );
  290. #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
  291. #define STATUS_INVALID_INFO_CLASS ((NTSTATUS)0xC0000003L)
  292. #define STATUS_NO_SUCH_USER ((NTSTATUS)0xC0000064L)
  293. #define STATUS_WRONG_PASSWORD ((NTSTATUS)0xC000006AL)
  294. #define STATUS_PASSWORD_RESTRICTION ((NTSTATUS)0xC000006CL)
  295. #define STATUS_LOGON_FAILURE ((NTSTATUS)0xC000006DL)
  296. #define STATUS_ACCOUNT_RESTRICTION ((NTSTATUS)0xC000006EL)
  297. #define STATUS_INVALID_LOGON_HOURS ((NTSTATUS)0xC000006FL)
  298. #define STATUS_INVALID_WORKSTATION ((NTSTATUS)0xC0000070L)
  299. #define STATUS_PASSWORD_EXPIRED ((NTSTATUS)0xC0000071L)
  300. #define STATUS_ACCOUNT_DISABLED ((NTSTATUS)0xC0000072L)
  301. #define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009AL)
  302. #define STATUS_ACCOUNT_EXPIRED ((NTSTATUS)0xC0000193L)
  303. #define STATUS_PASSWORD_MUST_CHANGE ((NTSTATUS)0xC0000224L)
  304. #define STATUS_ACCOUNT_LOCKED_OUT ((NTSTATUS)0xC0000234L)
  305. #ifdef __cplusplus
  306. }
  307. #endif
  308. #endif /* _NTSUBAUTH_ */