Source code of Windows XP (NT5)
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.

337 lines
9.6 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. // NOTE:
  93. // USER_LOGON_INTER_SUCCESS_LOGOFF
  94. // USER_LOGON_NET_SUCCESS_LOGOFF
  95. //
  96. // may not be used in conjunction with ANY other flags (including
  97. // each other). That is, when one of these flags is used, there
  98. // may be NO other flags set in StatisticsToApply.
  99. //
  100. // NOTE2:
  101. //
  102. // USER_LOGON_BAD_PASSWORD
  103. // USER_LOGON_INTER_SUCCESS_LOGON
  104. // USER_LOGON_NET_SUCCESS_LOGON
  105. //
  106. // may be used in conjunction ONLY with ONE of USER_LOGON_TYPE_KERBEROS or
  107. // USER_LOGON_TYPE_NTLM.
  108. #define USER_LOGON_STAT_LAST_LOGOFF (0x00000001L)
  109. #define USER_LOGON_STAT_LAST_LOGON (0x00000002L)
  110. #define USER_LOGON_STAT_BAD_PWD_COUNT (0x00000004L)
  111. #define USER_LOGON_STAT_LOGON_COUNT (0x00000008L)
  112. #define USER_LOGON_INTER_FAILURE (0x00200000L)
  113. #define USER_LOGON_NO_WRITE (0x00400000L)
  114. #define USER_LOGON_NO_LOGON_SERVERS (0x00800000L)
  115. #define USER_LOGON_TYPE_NTLM (0x02000000L)
  116. #define USER_LOGON_TYPE_KERBEROS (0x04000000L)
  117. #define USER_LOGON_BAD_PASSWORD (0x08000000L)
  118. #define USER_LOGON_INTER_SUCCESS_LOGON (0x01000000L)
  119. #define USER_LOGON_BAD_PASSWORD_WKSTA (0x10000000L)
  120. #define USER_LOGON_INTER_SUCCESS_LOGOFF (0x20000000L)
  121. #define USER_LOGON_NET_SUCCESS_LOGON (0x40000000L)
  122. #define USER_LOGON_NET_SUCCESS_LOGOFF (0x80000000L)
  123. typedef struct _USER_INTERNAL3_INFORMATION {
  124. USER_ALL_INFORMATION I1;
  125. LARGE_INTEGER LastBadPasswordTime;
  126. } USER_INTERNAL3_INFORMATION, *PUSER_INTERNAL3_INFORMATION;
  127. typedef struct _USER_ALLOWED_TO_DELEGATE_TO_LIST {
  128. ULONG Size;
  129. ULONG NumSPNs;
  130. UNICODE_STRING SPNList[ANYSIZE_ARRAY];
  131. } USER_ALLOWED_TO_DELEGATE_TO_LIST, *PUSER_ALLOWED_TO_DELEGATE_TO_LIST;
  132. typedef struct _USER_INTERNAL6_INFORMATION {
  133. USER_ALL_INFORMATION I1;
  134. LARGE_INTEGER LastBadPasswordTime;
  135. ULONG ExtendedFields;
  136. BOOLEAN UPNDefaulted;
  137. UNICODE_STRING UPN;
  138. PUSER_ALLOWED_TO_DELEGATE_TO_LIST A2D2List;
  139. } USER_INTERNAL6_INFORMATION, *PUSER_INTERNAL6_INFORMATION;
  140. //
  141. // The following fields are to be used in the extended fields
  142. // member of USER_INTERNAL6_INFORMATION
  143. //
  144. #define USER_EXTENDED_FIELD_UPN (0x00000001L)
  145. #define USER_EXTENDED_FIELD_A2D2 (0x00000002L)
  146. //
  147. // The following is for SamrGetUserDomainPasswordInformation(), which is
  148. // only used in wrappers.c.
  149. //
  150. typedef struct _USER_DOMAIN_PASSWORD_INFORMATION {
  151. USHORT MinPasswordLength;
  152. ULONG PasswordProperties;
  153. } USER_DOMAIN_PASSWORD_INFORMATION, *PUSER_DOMAIN_PASSWORD_INFORMATION;
  154. //
  155. // This flag may be or'd with the length field of SAMP_USER_PASSWORD to
  156. // indicate that the password is not case sensitive.
  157. //
  158. #define SAM_PASSWORD_CASE_INSENSITIVE 0x80000000
  159. //
  160. // Structure to pass an encrypted password over the wire. The Length is the
  161. // length of the password, which should be placed at the end of the buffer.
  162. // The size of the buffer (256) should be kept in sync with
  163. // SAM_MAX_PASSWORD_LENGTH, which is defined in ntsam.h. Unfortunately,
  164. // MIDL does not let #define'd constants be imported, so we have to
  165. // use 256 instead of the constant here.
  166. //
  167. typedef struct _SAMPR_USER_PASSWORD {
  168. WCHAR Buffer[SAM_MAX_PASSWORD_LENGTH];
  169. ULONG Length;
  170. } SAMPR_USER_PASSWORD, *PSAMPR_USER_PASSWORD;
  171. typedef struct _SAMPR_USER_PASSWORD_NEW {
  172. WCHAR Buffer[SAM_MAX_PASSWORD_LENGTH];
  173. ULONG Length;
  174. UCHAR ClearSalt[SAM_PASSWORD_ENCRYPTION_SALT_LEN];
  175. } SAMPR_USER_PASSWORD_NEW, *PSAMPR_USER_PASSWORD_NEW;
  176. //
  177. // Buffer - contains random fill with the password filling up the end
  178. // of the buffer (the last Length bytes).
  179. // Length - Length, in bytes, of the buffer.
  180. //
  181. //
  182. // This is the encrypted version of the above structure, and is passed
  183. // on the wire.
  184. //
  185. typedef struct _SAMPR_ENCRYPTED_USER_PASSWORD {
  186. UCHAR Buffer[ (SAM_MAX_PASSWORD_LENGTH * 2) + 4 ];
  187. } SAMPR_ENCRYPTED_USER_PASSWORD, *PSAMPR_ENCRYPTED_USER_PASSWORD;
  188. typedef struct _SAMPR_ENCRYPTED_USER_PASSWORD_NEW {
  189. UCHAR Buffer[ (SAM_MAX_PASSWORD_LENGTH * 2) + 4 + 16];
  190. } SAMPR_ENCRYPTED_USER_PASSWORD_NEW, *PSAMPR_ENCRYPTED_USER_PASSWORD_NEW;
  191. typedef enum _SAMPR_BOOT_TYPE {
  192. SamBootKeyNone = 0,
  193. SamBootKeyStored,
  194. SamBootKeyPassword,
  195. SamBootKeyDisk,
  196. SamBootChangePasswordEncryptionKey
  197. } SAMPR_BOOT_TYPE, *PSAMPR_BOOT_TYPE;
  198. //
  199. // ChangePassword API for One-Way-Function-aware clients
  200. //
  201. NTSTATUS
  202. SamiChangePasswordUser(
  203. IN SAM_HANDLE UserHandle,
  204. IN BOOLEAN LmOldPresent,
  205. IN PLM_OWF_PASSWORD LmOldOwfPassword,
  206. IN PLM_OWF_PASSWORD LmNewOwfPassword,
  207. IN BOOLEAN NtPresent,
  208. IN PNT_OWF_PASSWORD NtOldOwfPassword,
  209. IN PNT_OWF_PASSWORD NtNewOwfPassword
  210. );
  211. NTSTATUS
  212. SamiLmChangePasswordUser(
  213. IN SAM_HANDLE UserHandle,
  214. IN PENCRYPTED_LM_OWF_PASSWORD LmOldEncryptedWithLmNew,
  215. IN PENCRYPTED_LM_OWF_PASSWORD LmNewEncryptedWithLmOld
  216. );
  217. NTSTATUS
  218. SamiEncryptPasswords(
  219. IN PUNICODE_STRING OldPassword,
  220. IN PUNICODE_STRING NewPassword,
  221. OUT PSAMPR_ENCRYPTED_USER_PASSWORD NewEncryptedWithOldNt,
  222. OUT PENCRYPTED_NT_OWF_PASSWORD OldNtOwfEncryptedWithNewNt,
  223. OUT PBOOLEAN LmPresent,
  224. OUT PSAMPR_ENCRYPTED_USER_PASSWORD NewEncryptedWithOldLm,
  225. OUT PENCRYPTED_NT_OWF_PASSWORD OldLmOwfEncryptedWithNewNt
  226. );
  227. NTSTATUS
  228. SamiChangePasswordUser2(
  229. PUNICODE_STRING ServerName,
  230. PUNICODE_STRING UserName,
  231. PSAMPR_ENCRYPTED_USER_PASSWORD NewPasswordEncryptedWithOldNt,
  232. PENCRYPTED_NT_OWF_PASSWORD OldNtOwfPasswordEncryptedWithNewNt,
  233. BOOLEAN LmPresent,
  234. PSAMPR_ENCRYPTED_USER_PASSWORD NewPasswordEncryptedWithOldLm,
  235. PENCRYPTED_LM_OWF_PASSWORD OldLmOwfPasswordEncryptedWithNewLmOrNt
  236. );
  237. NTSTATUS
  238. SamiOemChangePasswordUser2(
  239. PSTRING ServerName,
  240. PSTRING UserName,
  241. PSAMPR_ENCRYPTED_USER_PASSWORD NewPasswordEncryptedWithOldLm,
  242. PENCRYPTED_LM_OWF_PASSWORD OldLmOwfPasswordEncryptedWithNewLm
  243. );
  244. NTSTATUS
  245. SamiGetBootKeyInformation(
  246. IN SAM_HANDLE DomainHandle,
  247. OUT PSAMPR_BOOT_TYPE BootOptions
  248. );
  249. NTSTATUS
  250. SamiSetBootKeyInformation(
  251. IN SAM_HANDLE DomainHandle,
  252. IN SAMPR_BOOT_TYPE BootOptions,
  253. IN PUNICODE_STRING OldBootKey, OPTIONAL
  254. IN PUNICODE_STRING NewBootKey OPTIONAL
  255. );
  256. NTSTATUS
  257. SamiSetDSRMPassword(
  258. IN PUNICODE_STRING ServerName,
  259. IN ULONG UserId,
  260. IN PUNICODE_STRING ClearPassword
  261. );
  262. NTSTATUS
  263. SamiSetDSRMPasswordOWF(
  264. IN PUNICODE_STRING ServerName,
  265. IN ULONG UserId,
  266. IN PNT_OWF_PASSWORD NtPassword
  267. );
  268. NTSTATUS
  269. SamiChangeKeys();
  270. #endif // _NTSAMPRIVATE_