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.

354 lines
11 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. ntsamp.h
  5. Abstract:
  6. This file contains structures that would normally be part of ntsam.h
  7. but are intended for system use only.
  8. Author:
  9. David Chalmers (Davidc) 27-Mar-1992
  10. Environment:
  11. User Mode - Win32
  12. Revision History:
  13. --*/
  14. #ifndef _NTSAMPRIVATE_
  15. #define _NTSAMPRIVATE_
  16. #include <crypt.h>
  17. #include <lsass.h>
  18. //
  19. // Structures usable in SetUserInformation and QueryUserInformation API calls
  20. // by trusted clients only
  21. //
  22. typedef struct _USER_INTERNAL1_INFORMATION {
  23. NT_OWF_PASSWORD NtOwfPassword;
  24. LM_OWF_PASSWORD LmOwfPassword;
  25. BOOLEAN NtPasswordPresent;
  26. BOOLEAN LmPasswordPresent;
  27. BOOLEAN PasswordExpired; // A 'write-only' flag
  28. } USER_INTERNAL1_INFORMATION, *PUSER_INTERNAL1_INFORMATION;
  29. typedef struct _USER_INTERNAL2_INFORMATION {
  30. ULONG StatisticsToApply;
  31. OLD_LARGE_INTEGER LastLogon;
  32. OLD_LARGE_INTEGER LastLogoff;
  33. USHORT BadPasswordCount;
  34. USHORT LogonCount;
  35. } USER_INTERNAL2_INFORMATION;
  36. typedef struct _USER_INTERNAL2A_INFORMATION {
  37. ULONG StatisticsToApply;
  38. OLD_LARGE_INTEGER LastLogon;
  39. OLD_LARGE_INTEGER LastLogoff;
  40. USHORT BadPasswordCount;
  41. USHORT LogonCount;
  42. UNICODE_STRING Workstation;
  43. } USER_INTERNAL2A_INFORMATION, *PUSER_INTERNAL2A_INFORMATION;
  44. //
  45. //
  46. //
  47. // The following flags may be used in the StatisticsToApply field.
  48. //
  49. // USER_LOGON_STAT_LAST_LOGOFF - Replace the LastLogoff time in the
  50. // user record.
  51. //
  52. // USER_LOGON_STATUS_LAST_LOGON - Replace the LastLogon time in the
  53. // user record.
  54. //
  55. // USER_LOGON_STATUS_BAD_PWD_COUNT - Replace the BadPasswordCount
  56. // field in the user record.
  57. //
  58. // USER_LOGON_STATUS_LOGON_COUNT - Replace the LogonCount field in the
  59. // user record.
  60. //
  61. // USER_LOGON_SUCCESSFUL_LOGON - Change user field values to indicate
  62. // that a successful logon has occurred.
  63. //
  64. // USER_LOGON_SUCCESSFUL_LOGOFF - Change user field values to indicate
  65. // that a successful logoff has occurred.
  66. //
  67. // USER_LOGON_BAD_PASSWORD - Change user field values to indicate that
  68. // an attempt was made to logon to the account with a bad password.
  69. //
  70. // USER_LOGON_BAD_PASSWORD_WKSTA - Change user field values to indicate that
  71. // an attempt was made to logon to the account with a bad password.
  72. // The client workstation name is being supplied in the INTERNAL2A
  73. // structure.
  74. //
  75. // USER_LOGON_TYPE_KERBEROS - Indicates the authentication type was
  76. // KERBEROS.
  77. //
  78. // USER_LOGON_TYPE_NTLM - Indicates the authentication type was NTLM.
  79. //
  80. // USER_LOGON_NO_LOGON_SERVERS -- Indicates that no logon servers could be
  81. // found (specifically no GC's could be found)
  82. // (this is a failure case).
  83. //
  84. // USER_LOGON_NO_WRITE -- Indicates to SAM not to update the logon statistics
  85. // This can be useful to notify SAM that a logon
  86. // has completed, but not have the penalty of writing
  87. // to the disk
  88. //
  89. // USER_LOGON_INTER_FAILURE -- this indicates that it was an interactive
  90. // logon that failed
  91. //
  92. // USER_LOGON_PDC_RETRY_SUCCESS -- this indicates that the authentication
  93. // had previously failed locally but
  94. // succeeded at the PDC
  95. //
  96. // NOTE:
  97. // USER_LOGON_INTER_SUCCESS_LOGOFF
  98. // USER_LOGON_NET_SUCCESS_LOGOFF
  99. //
  100. // may not be used in conjunction with ANY other flags (including
  101. // each other). That is, when one of these flags is used, there
  102. // may be NO other flags set in StatisticsToApply.
  103. //
  104. // NOTE2:
  105. //
  106. // USER_LOGON_BAD_PASSWORD
  107. // USER_LOGON_INTER_SUCCESS_LOGON
  108. // USER_LOGON_NET_SUCCESS_LOGON
  109. //
  110. // may be used in conjunction ONLY with ONE of USER_LOGON_TYPE_KERBEROS or
  111. // USER_LOGON_TYPE_NTLM.
  112. #define USER_LOGON_STAT_LAST_LOGOFF (0x00000001L)
  113. #define USER_LOGON_STAT_LAST_LOGON (0x00000002L)
  114. #define USER_LOGON_STAT_BAD_PWD_COUNT (0x00000004L)
  115. #define USER_LOGON_STAT_LOGON_COUNT (0x00000008L)
  116. #define USER_LOGON_PDC_RETRY_SUCCESS (0x00100000L)
  117. #define USER_LOGON_INTER_FAILURE (0x00200000L)
  118. #define USER_LOGON_NO_WRITE (0x00400000L)
  119. #define USER_LOGON_NO_LOGON_SERVERS (0x00800000L)
  120. #define USER_LOGON_INTER_SUCCESS_LOGON (0x01000000L)
  121. #define USER_LOGON_TYPE_NTLM (0x02000000L)
  122. #define USER_LOGON_TYPE_KERBEROS (0x04000000L)
  123. #define USER_LOGON_BAD_PASSWORD (0x08000000L)
  124. #define USER_LOGON_BAD_PASSWORD_WKSTA (0x10000000L)
  125. #define USER_LOGON_INTER_SUCCESS_LOGOFF (0x20000000L)
  126. #define USER_LOGON_NET_SUCCESS_LOGON (0x40000000L)
  127. #define USER_LOGON_NET_SUCCESS_LOGOFF (0x80000000L)
  128. typedef struct _USER_INTERNAL3_INFORMATION {
  129. USER_ALL_INFORMATION I1;
  130. LARGE_INTEGER LastBadPasswordTime;
  131. } USER_INTERNAL3_INFORMATION, *PUSER_INTERNAL3_INFORMATION;
  132. typedef struct _USER_ALLOWED_TO_DELEGATE_TO_LIST {
  133. ULONG Size;
  134. ULONG NumSPNs;
  135. UNICODE_STRING SPNList[ANYSIZE_ARRAY];
  136. } USER_ALLOWED_TO_DELEGATE_TO_LIST, *PUSER_ALLOWED_TO_DELEGATE_TO_LIST;
  137. typedef USER_ALLOWED_TO_DELEGATE_TO_LIST USER_SPN_LIST, *PUSER_SPN_LIST;
  138. typedef struct _USER_INTERNAL6_INFORMATION {
  139. USER_ALL_INFORMATION I1;
  140. LARGE_INTEGER LastBadPasswordTime;
  141. ULONG ExtendedFields;
  142. BOOLEAN UPNDefaulted;
  143. UNICODE_STRING UPN;
  144. PUSER_ALLOWED_TO_DELEGATE_TO_LIST A2D2List;
  145. PUSER_SPN_LIST RegisteredSPNs;
  146. ULONG KeyVersionNumber;
  147. ULONG LockoutThreshold;
  148. } USER_INTERNAL6_INFORMATION, *PUSER_INTERNAL6_INFORMATION;
  149. //
  150. // The following fields are to be used in the extended fields
  151. // member of USER_INTERNAL6_INFORMATION
  152. //
  153. #define USER_EXTENDED_FIELD_UPN (0x00000001L)
  154. #define USER_EXTENDED_FIELD_A2D2 (0x00000002L)
  155. #define USER_EXTENDED_FIELD_SPN (0x00000004L)
  156. #define USER_EXTENDED_FIELD_KVNO (0x00000008L)
  157. #define USER_EXTENDED_FIELD_LOCKOUT_THRESHOLD (0x00000010L)
  158. // Reserved for internal use
  159. #define USER_EXTENDED_FIELD_RESERVED (0xFF000000L)
  160. //
  161. // The following is for SamrGetUserDomainPasswordInformation(), which is
  162. // only used in wrappers.c.
  163. //
  164. typedef struct _USER_DOMAIN_PASSWORD_INFORMATION {
  165. USHORT MinPasswordLength;
  166. ULONG PasswordProperties;
  167. } USER_DOMAIN_PASSWORD_INFORMATION, *PUSER_DOMAIN_PASSWORD_INFORMATION;
  168. //
  169. // This flag may be or'd with the length field of SAMP_USER_PASSWORD to
  170. // indicate that the password is not case sensitive.
  171. //
  172. #define SAM_PASSWORD_CASE_INSENSITIVE 0x80000000
  173. //
  174. // Structure to pass an encrypted password over the wire. The Length is the
  175. // length of the password, which should be placed at the end of the buffer.
  176. // The size of the buffer (256) should be kept in sync with
  177. // SAM_MAX_PASSWORD_LENGTH, which is defined in ntsam.h. Unfortunately,
  178. // MIDL does not let #define'd constants be imported, so we have to
  179. // use 256 instead of the constant here.
  180. //
  181. typedef struct _SAMPR_USER_PASSWORD {
  182. WCHAR Buffer[SAM_MAX_PASSWORD_LENGTH];
  183. ULONG Length;
  184. } SAMPR_USER_PASSWORD, *PSAMPR_USER_PASSWORD;
  185. typedef struct _SAMPR_USER_PASSWORD_NEW {
  186. WCHAR Buffer[SAM_MAX_PASSWORD_LENGTH];
  187. ULONG Length;
  188. UCHAR ClearSalt[SAM_PASSWORD_ENCRYPTION_SALT_LEN];
  189. } SAMPR_USER_PASSWORD_NEW, *PSAMPR_USER_PASSWORD_NEW;
  190. //
  191. // Buffer - contains random fill with the password filling up the end
  192. // of the buffer (the last Length bytes).
  193. // Length - Length, in bytes, of the buffer.
  194. //
  195. //
  196. // This is the encrypted version of the above structure, and is passed
  197. // on the wire.
  198. //
  199. typedef struct _SAMPR_ENCRYPTED_USER_PASSWORD {
  200. UCHAR Buffer[ (SAM_MAX_PASSWORD_LENGTH * 2) + 4 ];
  201. } SAMPR_ENCRYPTED_USER_PASSWORD, *PSAMPR_ENCRYPTED_USER_PASSWORD;
  202. typedef struct _SAMPR_ENCRYPTED_USER_PASSWORD_NEW {
  203. UCHAR Buffer[ (SAM_MAX_PASSWORD_LENGTH * 2) + 4 + 16];
  204. } SAMPR_ENCRYPTED_USER_PASSWORD_NEW, *PSAMPR_ENCRYPTED_USER_PASSWORD_NEW;
  205. typedef enum _SAMPR_BOOT_TYPE {
  206. SamBootKeyNone = 0,
  207. SamBootKeyStored,
  208. SamBootKeyPassword,
  209. SamBootKeyDisk,
  210. SamBootChangePasswordEncryptionKey
  211. } SAMPR_BOOT_TYPE, *PSAMPR_BOOT_TYPE;
  212. //
  213. // ChangePassword API for One-Way-Function-aware clients
  214. //
  215. NTSTATUS
  216. SamiChangePasswordUser(
  217. IN SAM_HANDLE UserHandle,
  218. IN BOOLEAN LmOldPresent,
  219. IN PLM_OWF_PASSWORD LmOldOwfPassword,
  220. IN PLM_OWF_PASSWORD LmNewOwfPassword,
  221. IN BOOLEAN NtPresent,
  222. IN PNT_OWF_PASSWORD NtOldOwfPassword,
  223. IN PNT_OWF_PASSWORD NtNewOwfPassword
  224. );
  225. NTSTATUS
  226. SamiLmChangePasswordUser(
  227. IN SAM_HANDLE UserHandle,
  228. IN PENCRYPTED_LM_OWF_PASSWORD LmOldEncryptedWithLmNew,
  229. IN PENCRYPTED_LM_OWF_PASSWORD LmNewEncryptedWithLmOld
  230. );
  231. NTSTATUS
  232. SamiEncryptPasswords(
  233. IN PUNICODE_STRING OldPassword,
  234. IN PUNICODE_STRING NewPassword,
  235. OUT PSAMPR_ENCRYPTED_USER_PASSWORD NewEncryptedWithOldNt,
  236. OUT PENCRYPTED_NT_OWF_PASSWORD OldNtOwfEncryptedWithNewNt,
  237. OUT PBOOLEAN LmPresent,
  238. OUT PSAMPR_ENCRYPTED_USER_PASSWORD NewEncryptedWithOldLm,
  239. OUT PENCRYPTED_NT_OWF_PASSWORD OldLmOwfEncryptedWithNewNt
  240. );
  241. NTSTATUS
  242. SamiChangePasswordUser2(
  243. PUNICODE_STRING ServerName,
  244. PUNICODE_STRING UserName,
  245. PSAMPR_ENCRYPTED_USER_PASSWORD NewPasswordEncryptedWithOldNt,
  246. PENCRYPTED_NT_OWF_PASSWORD OldNtOwfPasswordEncryptedWithNewNt,
  247. BOOLEAN LmPresent,
  248. PSAMPR_ENCRYPTED_USER_PASSWORD NewPasswordEncryptedWithOldLm,
  249. PENCRYPTED_LM_OWF_PASSWORD OldLmOwfPasswordEncryptedWithNewLmOrNt
  250. );
  251. NTSTATUS
  252. SamiOemChangePasswordUser2(
  253. PSTRING ServerName,
  254. PSTRING UserName,
  255. PSAMPR_ENCRYPTED_USER_PASSWORD NewPasswordEncryptedWithOldLm,
  256. PENCRYPTED_LM_OWF_PASSWORD OldLmOwfPasswordEncryptedWithNewLm
  257. );
  258. NTSTATUS
  259. SamiGetBootKeyInformation(
  260. IN SAM_HANDLE DomainHandle,
  261. OUT PSAMPR_BOOT_TYPE BootOptions
  262. );
  263. NTSTATUS
  264. SamiSetBootKeyInformation(
  265. IN SAM_HANDLE DomainHandle,
  266. IN SAMPR_BOOT_TYPE BootOptions,
  267. IN PUNICODE_STRING OldBootKey, OPTIONAL
  268. IN PUNICODE_STRING NewBootKey OPTIONAL
  269. );
  270. NTSTATUS
  271. SamiSetDSRMPassword(
  272. IN PUNICODE_STRING ServerName,
  273. IN ULONG UserId,
  274. IN PUNICODE_STRING ClearPassword
  275. );
  276. NTSTATUS
  277. SamiSetDSRMPasswordOWF(
  278. IN PUNICODE_STRING ServerName,
  279. IN ULONG UserId,
  280. IN PNT_OWF_PASSWORD NtPassword
  281. );
  282. NTSTATUS
  283. SamiChangeKeys();
  284. #endif // _NTSAMPRIVATE_