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.

2117 lines
70 KiB

  1. /*++ BUILD Version: 0006 // Increment this if a change has global effects
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. ntsam.h
  5. Abstract:
  6. This module describes the data types and procedure prototypes
  7. that make up the NT Security Accounts Manager. This includes
  8. API's exported by SAM and related subsystems.
  9. Author:
  10. Edwin Hoogerbeets (w-edwinh) 3-May-1990
  11. Revision History:
  12. 30-Nov-1990 [w-mikep] Updated code to reflect changes in version 1.4
  13. of Sam Document.
  14. 20-May-1991 (JimK) Updated to version 1.8 of SAM spec.
  15. 10-Sep-1991 (JohnRo) PC-LINT found a portability problem.
  16. 23-Jan-1991 (ChadS) Udated to version 1.14 of SAM spec.
  17. --*/
  18. #ifndef _NTSAM_
  19. #define _NTSAM_
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #ifndef PPULONG
  27. typedef PULONG *PPULONG;
  28. #endif //PPULONG
  29. //
  30. // An attempt to lookup more than this number of names or SIDs in
  31. // a single call will be rejected with an INSUFFICIENT_RESOURCES
  32. // status.
  33. //
  34. #define SAM_MAXIMUM_LOOKUP_COUNT (1000)
  35. //
  36. // An attempt to pass names totalling more than the following number
  37. // of bytes in length will be rejected with an INSUFFICIENT_RESOURCES
  38. // status.
  39. //
  40. #define SAM_MAXIMUM_LOOKUP_LENGTH (32000)
  41. //
  42. // An attempt to set a password longer than this number of characters
  43. // will fail.
  44. //
  45. #define SAM_MAX_PASSWORD_LENGTH (256)
  46. //
  47. // Length of the salt used in the clear password encryption
  48. //
  49. #define SAM_PASSWORD_ENCRYPTION_SALT_LEN (16)
  50. #ifndef _NTSAM_SAM_HANDLE_ // ntsubauth
  51. typedef PVOID SAM_HANDLE, *PSAM_HANDLE; // ntsubauth
  52. #define _NTSAM_SAM_HANDLE_ // ntsubauth
  53. #endif // ntsubauth
  54. typedef ULONG SAM_ENUMERATE_HANDLE, *PSAM_ENUMERATE_HANDLE;
  55. typedef struct _SAM_RID_ENUMERATION {
  56. ULONG RelativeId;
  57. UNICODE_STRING Name;
  58. } SAM_RID_ENUMERATION, *PSAM_RID_ENUMERATION;
  59. typedef struct _SAM_SID_ENUMERATION {
  60. PSID Sid;
  61. UNICODE_STRING Name;
  62. } SAM_SID_ENUMERATION, *PSAM_SID_ENUMERATION;
  63. /////////////////////////////////////////////////////////////////////////////
  64. // //
  65. // obsolete well-known account names. //
  66. // These became obsolete with the flexadmin model. //
  67. // These will be deleted shortly - DON'T USE THESE //
  68. // //
  69. /////////////////////////////////////////////////////////////////////////////
  70. #define DOMAIN_ADMIN_USER_NAME "ADMIN"
  71. #define DOMAIN_ADMIN_NAME "D_ADMIN"
  72. #define DOMAIN_ADMIN_NAMEW L"D_ADMIN"
  73. #define DOMAIN_USERS_NAME "D_USERS"
  74. #define DOMAIN_USERS_NAMEW L"D_USERS"
  75. #define DOMAIN_GUESTS_NAME "D_GUESTS"
  76. #define DOMAIN_ACCOUNT_OPERATORS_NAME "D_ACCOUN"
  77. #define DOMAIN_ACCOUNT_OPERATORS_NAMEW L"D_ACCOUN"
  78. #define DOMAIN_SERVER_OPERATORS_NAME "D_SERVER"
  79. #define DOMAIN_SERVER_OPERATORS_NAMEW L"D_SERVER"
  80. #define DOMAIN_PRINT_OPERATORS_NAME "D_PRINT"
  81. #define DOMAIN_PRINT_OPERATORS_NAMEW L"D_PRINT"
  82. #define DOMAIN_COMM_OPERATORS_NAME "D_COMM"
  83. #define DOMAIN_COMM_OPERATORS_NAMEW L"D_COMM"
  84. #define DOMAIN_BACKUP_OPERATORS_NAME "D_BACKUP"
  85. #define DOMAIN_RESTORE_OPERATORS_NAME "D_RESTOR"
  86. ///////////////////////////////////////////////////////////////////////////////
  87. // //
  88. // Server Object Related Definitions //
  89. // //
  90. ///////////////////////////////////////////////////////////////////////////////
  91. //
  92. // Access rights for server object
  93. //
  94. #define SAM_SERVER_CONNECT 0x0001
  95. #define SAM_SERVER_SHUTDOWN 0x0002
  96. #define SAM_SERVER_INITIALIZE 0x0004
  97. #define SAM_SERVER_CREATE_DOMAIN 0x0008
  98. #define SAM_SERVER_ENUMERATE_DOMAINS 0x0010
  99. #define SAM_SERVER_LOOKUP_DOMAIN 0x0020
  100. #define SAM_SERVER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  101. SAM_SERVER_CONNECT |\
  102. SAM_SERVER_INITIALIZE |\
  103. SAM_SERVER_CREATE_DOMAIN |\
  104. SAM_SERVER_SHUTDOWN |\
  105. SAM_SERVER_ENUMERATE_DOMAINS |\
  106. SAM_SERVER_LOOKUP_DOMAIN)
  107. #define SAM_SERVER_READ (STANDARD_RIGHTS_READ |\
  108. SAM_SERVER_ENUMERATE_DOMAINS)
  109. #define SAM_SERVER_WRITE (STANDARD_RIGHTS_WRITE |\
  110. SAM_SERVER_INITIALIZE |\
  111. SAM_SERVER_CREATE_DOMAIN |\
  112. SAM_SERVER_SHUTDOWN)
  113. #define SAM_SERVER_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  114. SAM_SERVER_CONNECT |\
  115. SAM_SERVER_LOOKUP_DOMAIN)
  116. ///////////////////////////////////////////////////////////////////////////////
  117. // //
  118. // Domain Object Related Definitions //
  119. // //
  120. ///////////////////////////////////////////////////////////////////////////////
  121. //
  122. // Access rights for domain object
  123. //
  124. #define DOMAIN_READ_PASSWORD_PARAMETERS 0x0001
  125. #define DOMAIN_WRITE_PASSWORD_PARAMS 0x0002
  126. #define DOMAIN_READ_OTHER_PARAMETERS 0x0004
  127. #define DOMAIN_WRITE_OTHER_PARAMETERS 0x0008
  128. #define DOMAIN_CREATE_USER 0x0010
  129. #define DOMAIN_CREATE_GROUP 0x0020
  130. #define DOMAIN_CREATE_ALIAS 0x0040
  131. #define DOMAIN_GET_ALIAS_MEMBERSHIP 0x0080
  132. #define DOMAIN_LIST_ACCOUNTS 0x0100
  133. #define DOMAIN_LOOKUP 0x0200
  134. #define DOMAIN_ADMINISTER_SERVER 0x0400
  135. #define DOMAIN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  136. DOMAIN_READ_OTHER_PARAMETERS |\
  137. DOMAIN_WRITE_OTHER_PARAMETERS |\
  138. DOMAIN_WRITE_PASSWORD_PARAMS |\
  139. DOMAIN_CREATE_USER |\
  140. DOMAIN_CREATE_GROUP |\
  141. DOMAIN_CREATE_ALIAS |\
  142. DOMAIN_GET_ALIAS_MEMBERSHIP |\
  143. DOMAIN_LIST_ACCOUNTS |\
  144. DOMAIN_READ_PASSWORD_PARAMETERS |\
  145. DOMAIN_LOOKUP |\
  146. DOMAIN_ADMINISTER_SERVER)
  147. #define DOMAIN_READ (STANDARD_RIGHTS_READ |\
  148. DOMAIN_GET_ALIAS_MEMBERSHIP |\
  149. DOMAIN_READ_OTHER_PARAMETERS)
  150. #define DOMAIN_WRITE (STANDARD_RIGHTS_WRITE |\
  151. DOMAIN_WRITE_OTHER_PARAMETERS |\
  152. DOMAIN_WRITE_PASSWORD_PARAMS |\
  153. DOMAIN_CREATE_USER |\
  154. DOMAIN_CREATE_GROUP |\
  155. DOMAIN_CREATE_ALIAS |\
  156. DOMAIN_ADMINISTER_SERVER)
  157. #define DOMAIN_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  158. DOMAIN_READ_PASSWORD_PARAMETERS |\
  159. DOMAIN_LIST_ACCOUNTS |\
  160. DOMAIN_LOOKUP)
  161. //
  162. // Normal modifications cause a domain's ModifiedCount to be
  163. // incremented by 1. Domain promotion to Primary domain controller
  164. // cause the ModifiedCount to be incremented by the following
  165. // amount. This causes the upper 24-bits of the ModifiedCount
  166. // to be a promotion count and the lower 40-bits as a modification
  167. // count.
  168. //
  169. #define DOMAIN_PROMOTION_INCREMENT {0x0,0x10}
  170. #define DOMAIN_PROMOTION_MASK {0x0,0xFFFFFFF0}
  171. //
  172. // Domain information classes and their corresponding data structures
  173. //
  174. typedef enum _DOMAIN_INFORMATION_CLASS {
  175. DomainPasswordInformation = 1,
  176. DomainGeneralInformation,
  177. DomainLogoffInformation,
  178. DomainOemInformation,
  179. DomainNameInformation,
  180. DomainReplicationInformation,
  181. DomainServerRoleInformation,
  182. DomainModifiedInformation,
  183. DomainStateInformation,
  184. DomainUasInformation,
  185. DomainGeneralInformation2,
  186. DomainLockoutInformation,
  187. DomainModifiedInformation2
  188. } DOMAIN_INFORMATION_CLASS;
  189. typedef enum _DOMAIN_SERVER_ENABLE_STATE {
  190. DomainServerEnabled = 1,
  191. DomainServerDisabled
  192. } DOMAIN_SERVER_ENABLE_STATE, *PDOMAIN_SERVER_ENABLE_STATE;
  193. typedef enum _DOMAIN_SERVER_ROLE {
  194. DomainServerRoleBackup = 2,
  195. DomainServerRolePrimary
  196. } DOMAIN_SERVER_ROLE, *PDOMAIN_SERVER_ROLE;
  197. #include "pshpack4.h"
  198. typedef struct _DOMAIN_GENERAL_INFORMATION {
  199. LARGE_INTEGER ForceLogoff;
  200. UNICODE_STRING OemInformation;
  201. UNICODE_STRING DomainName;
  202. UNICODE_STRING ReplicaSourceNodeName;
  203. LARGE_INTEGER DomainModifiedCount;
  204. DOMAIN_SERVER_ENABLE_STATE DomainServerState;
  205. DOMAIN_SERVER_ROLE DomainServerRole;
  206. BOOLEAN UasCompatibilityRequired;
  207. ULONG UserCount;
  208. ULONG GroupCount;
  209. ULONG AliasCount;
  210. } DOMAIN_GENERAL_INFORMATION, *PDOMAIN_GENERAL_INFORMATION;
  211. #include "poppack.h"
  212. #include "pshpack4.h"
  213. typedef struct _DOMAIN_GENERAL_INFORMATION2 {
  214. DOMAIN_GENERAL_INFORMATION I1;
  215. //
  216. // New fields added for this structure (NT1.0A).
  217. //
  218. LARGE_INTEGER LockoutDuration; //Must be a Delta time
  219. LARGE_INTEGER LockoutObservationWindow; //Must be a Delta time
  220. USHORT LockoutThreshold;
  221. } DOMAIN_GENERAL_INFORMATION2, *PDOMAIN_GENERAL_INFORMATION2;
  222. #include "poppack.h"
  223. typedef struct _DOMAIN_UAS_INFORMATION {
  224. BOOLEAN UasCompatibilityRequired;
  225. } DOMAIN_UAS_INFORMATION;
  226. //
  227. // This needs to be guarded, because ntsecapi.h is a generated
  228. // public file, and ntsam.h is an internal file, but people like
  229. // to mix and match them anyway.
  230. //
  231. // begin_ntsecapi
  232. #ifndef _DOMAIN_PASSWORD_INFORMATION_DEFINED
  233. #define _DOMAIN_PASSWORD_INFORMATION_DEFINED
  234. typedef struct _DOMAIN_PASSWORD_INFORMATION {
  235. USHORT MinPasswordLength;
  236. USHORT PasswordHistoryLength;
  237. ULONG PasswordProperties;
  238. #if defined(MIDL_PASS)
  239. OLD_LARGE_INTEGER MaxPasswordAge;
  240. OLD_LARGE_INTEGER MinPasswordAge;
  241. #else
  242. LARGE_INTEGER MaxPasswordAge;
  243. LARGE_INTEGER MinPasswordAge;
  244. #endif
  245. } DOMAIN_PASSWORD_INFORMATION, *PDOMAIN_PASSWORD_INFORMATION;
  246. #endif
  247. //
  248. // PasswordProperties flags
  249. //
  250. #define DOMAIN_PASSWORD_COMPLEX 0x00000001L
  251. #define DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002L
  252. #define DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004L
  253. #define DOMAIN_LOCKOUT_ADMINS 0x00000008L
  254. #define DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010L
  255. #define DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020L
  256. // end_ntsecapi
  257. typedef enum _DOMAIN_PASSWORD_CONSTRUCTION {
  258. DomainPasswordSimple = 1,
  259. DomainPasswordComplex
  260. } DOMAIN_PASSWORD_CONSTRUCTION;
  261. typedef struct _DOMAIN_LOGOFF_INFORMATION {
  262. #if defined(MIDL_PASS)
  263. OLD_LARGE_INTEGER ForceLogoff;
  264. #else
  265. LARGE_INTEGER ForceLogoff;
  266. #endif
  267. } DOMAIN_LOGOFF_INFORMATION, *PDOMAIN_LOGOFF_INFORMATION;
  268. typedef struct _DOMAIN_OEM_INFORMATION {
  269. UNICODE_STRING OemInformation;
  270. } DOMAIN_OEM_INFORMATION, *PDOMAIN_OEM_INFORMATION;
  271. typedef struct _DOMAIN_NAME_INFORMATION {
  272. UNICODE_STRING DomainName;
  273. } DOMAIN_NAME_INFORMATION, *PDOMAIN_NAME_INFORMATION;
  274. typedef struct _DOMAIN_SERVER_ROLE_INFORMATION {
  275. DOMAIN_SERVER_ROLE DomainServerRole;
  276. } DOMAIN_SERVER_ROLE_INFORMATION, *PDOMAIN_SERVER_ROLE_INFORMATION;
  277. typedef struct _DOMAIN_REPLICATION_INFORMATION {
  278. UNICODE_STRING ReplicaSourceNodeName;
  279. } DOMAIN_REPLICATION_INFORMATION, *PDOMAIN_REPLICATION_INFORMATION;
  280. typedef struct _DOMAIN_MODIFIED_INFORMATION {
  281. #if defined(MIDL_PASS)
  282. OLD_LARGE_INTEGER DomainModifiedCount;
  283. OLD_LARGE_INTEGER CreationTime;
  284. #else
  285. LARGE_INTEGER DomainModifiedCount;
  286. LARGE_INTEGER CreationTime;
  287. #endif
  288. } DOMAIN_MODIFIED_INFORMATION, *PDOMAIN_MODIFIED_INFORMATION;
  289. typedef struct _DOMAIN_MODIFIED_INFORMATION2 {
  290. #if defined(MIDL_PASS)
  291. OLD_LARGE_INTEGER DomainModifiedCount;
  292. OLD_LARGE_INTEGER CreationTime;
  293. OLD_LARGE_INTEGER ModifiedCountAtLastPromotion;
  294. #else
  295. LARGE_INTEGER DomainModifiedCount;
  296. LARGE_INTEGER CreationTime;
  297. LARGE_INTEGER ModifiedCountAtLastPromotion;
  298. #endif
  299. } DOMAIN_MODIFIED_INFORMATION2, *PDOMAIN_MODIFIED_INFORMATION2;
  300. typedef struct _DOMAIN_STATE_INFORMATION {
  301. DOMAIN_SERVER_ENABLE_STATE DomainServerState;
  302. } DOMAIN_STATE_INFORMATION, *PDOMAIN_STATE_INFORMATION;
  303. typedef struct _DOMAIN_LOCKOUT_INFORMATION {
  304. #if defined(MIDL_PASS)
  305. OLD_LARGE_INTEGER LockoutDuration; //Must be a Delta time
  306. OLD_LARGE_INTEGER LockoutObservationWindow; //Must be a Delta time
  307. #else
  308. LARGE_INTEGER LockoutDuration; //Must be a Delta time
  309. LARGE_INTEGER LockoutObservationWindow; //Must be a Delta time
  310. #endif
  311. USHORT LockoutThreshold; //Zero means no lockout
  312. } DOMAIN_LOCKOUT_INFORMATION, *PDOMAIN_LOCKOUT_INFORMATION;
  313. //
  314. // Types used by the SamQueryDisplayInformation API
  315. //
  316. typedef enum _DOMAIN_DISPLAY_INFORMATION {
  317. DomainDisplayUser = 1,
  318. DomainDisplayMachine,
  319. DomainDisplayGroup, // Added in NT1.0A
  320. DomainDisplayOemUser, // Added in NT1.0A
  321. DomainDisplayOemGroup, // Added in NT1.0A
  322. DomainDisplayServer // Added in NT5 to support query of servers
  323. } DOMAIN_DISPLAY_INFORMATION, *PDOMAIN_DISPLAY_INFORMATION;
  324. typedef struct _DOMAIN_DISPLAY_USER {
  325. ULONG Index;
  326. ULONG Rid;
  327. ULONG AccountControl;
  328. UNICODE_STRING LogonName;
  329. UNICODE_STRING AdminComment;
  330. UNICODE_STRING FullName;
  331. } DOMAIN_DISPLAY_USER, *PDOMAIN_DISPLAY_USER;
  332. typedef struct _DOMAIN_DISPLAY_MACHINE {
  333. ULONG Index;
  334. ULONG Rid;
  335. ULONG AccountControl;
  336. UNICODE_STRING Machine;
  337. UNICODE_STRING Comment;
  338. } DOMAIN_DISPLAY_MACHINE, *PDOMAIN_DISPLAY_MACHINE;
  339. typedef struct _DOMAIN_DISPLAY_GROUP { // Added in NT1.0A
  340. ULONG Index;
  341. ULONG Rid;
  342. ULONG Attributes;
  343. UNICODE_STRING Group;
  344. UNICODE_STRING Comment;
  345. } DOMAIN_DISPLAY_GROUP, *PDOMAIN_DISPLAY_GROUP;
  346. typedef struct _DOMAIN_DISPLAY_OEM_USER { // Added in NT1.0A
  347. ULONG Index;
  348. OEM_STRING User;
  349. } DOMAIN_DISPLAY_OEM_USER, *PDOMAIN_DISPLAY_OEM_USER;
  350. typedef struct _DOMAIN_DISPLAY_OEM_GROUP { // Added in NT1.0A
  351. ULONG Index;
  352. OEM_STRING Group;
  353. } DOMAIN_DISPLAY_OEM_GROUP, *PDOMAIN_DISPLAY_OEM_GROUP;
  354. ///////////////////////////////////////////////////////////////////////////////
  355. // //
  356. // Group Object Related Definitions //
  357. // //
  358. ///////////////////////////////////////////////////////////////////////////////
  359. //
  360. // Access rights for group object
  361. //
  362. #define GROUP_READ_INFORMATION 0x0001
  363. #define GROUP_WRITE_ACCOUNT 0x0002
  364. #define GROUP_ADD_MEMBER 0x0004
  365. #define GROUP_REMOVE_MEMBER 0x0008
  366. #define GROUP_LIST_MEMBERS 0x0010
  367. #define GROUP_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  368. GROUP_LIST_MEMBERS |\
  369. GROUP_WRITE_ACCOUNT |\
  370. GROUP_ADD_MEMBER |\
  371. GROUP_REMOVE_MEMBER |\
  372. GROUP_READ_INFORMATION)
  373. #define GROUP_READ (STANDARD_RIGHTS_READ |\
  374. GROUP_LIST_MEMBERS)
  375. #define GROUP_WRITE (STANDARD_RIGHTS_WRITE |\
  376. GROUP_WRITE_ACCOUNT |\
  377. GROUP_ADD_MEMBER |\
  378. GROUP_REMOVE_MEMBER)
  379. #define GROUP_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  380. GROUP_READ_INFORMATION)
  381. //
  382. // Group object types
  383. //
  384. typedef struct _GROUP_MEMBERSHIP {
  385. ULONG RelativeId;
  386. ULONG Attributes;
  387. } GROUP_MEMBERSHIP, *PGROUP_MEMBERSHIP;
  388. typedef enum _GROUP_INFORMATION_CLASS {
  389. GroupGeneralInformation = 1,
  390. GroupNameInformation,
  391. GroupAttributeInformation,
  392. GroupAdminCommentInformation,
  393. GroupReplicationInformation
  394. } GROUP_INFORMATION_CLASS;
  395. typedef struct _GROUP_GENERAL_INFORMATION {
  396. UNICODE_STRING Name;
  397. ULONG Attributes;
  398. ULONG MemberCount;
  399. UNICODE_STRING AdminComment;
  400. } GROUP_GENERAL_INFORMATION, *PGROUP_GENERAL_INFORMATION;
  401. typedef struct _GROUP_NAME_INFORMATION {
  402. UNICODE_STRING Name;
  403. } GROUP_NAME_INFORMATION, *PGROUP_NAME_INFORMATION;
  404. typedef struct _GROUP_ATTRIBUTE_INFORMATION {
  405. ULONG Attributes;
  406. } GROUP_ATTRIBUTE_INFORMATION, *PGROUP_ATTRIBUTE_INFORMATION;
  407. typedef struct _GROUP_ADM_COMMENT_INFORMATION {
  408. UNICODE_STRING AdminComment;
  409. } GROUP_ADM_COMMENT_INFORMATION, *PGROUP_ADM_COMMENT_INFORMATION;
  410. ///////////////////////////////////////////////////////////////////////////////
  411. // //
  412. // Alias Object Related Definitions //
  413. // //
  414. ///////////////////////////////////////////////////////////////////////////////
  415. //
  416. // Access rights for alias object
  417. //
  418. #define ALIAS_ADD_MEMBER 0x0001
  419. #define ALIAS_REMOVE_MEMBER 0x0002
  420. #define ALIAS_LIST_MEMBERS 0x0004
  421. #define ALIAS_READ_INFORMATION 0x0008
  422. #define ALIAS_WRITE_ACCOUNT 0x0010
  423. #define ALIAS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  424. ALIAS_READ_INFORMATION |\
  425. ALIAS_WRITE_ACCOUNT |\
  426. ALIAS_LIST_MEMBERS |\
  427. ALIAS_ADD_MEMBER |\
  428. ALIAS_REMOVE_MEMBER)
  429. #define ALIAS_READ (STANDARD_RIGHTS_READ |\
  430. ALIAS_LIST_MEMBERS)
  431. #define ALIAS_WRITE (STANDARD_RIGHTS_WRITE |\
  432. ALIAS_WRITE_ACCOUNT |\
  433. ALIAS_ADD_MEMBER |\
  434. ALIAS_REMOVE_MEMBER)
  435. #define ALIAS_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  436. ALIAS_READ_INFORMATION)
  437. //
  438. // Alias object types
  439. //
  440. typedef enum _ALIAS_INFORMATION_CLASS {
  441. AliasGeneralInformation = 1,
  442. AliasNameInformation,
  443. AliasAdminCommentInformation,
  444. AliasReplicationInformation
  445. } ALIAS_INFORMATION_CLASS;
  446. typedef struct _ALIAS_GENERAL_INFORMATION {
  447. UNICODE_STRING Name;
  448. ULONG MemberCount;
  449. UNICODE_STRING AdminComment;
  450. } ALIAS_GENERAL_INFORMATION, *PALIAS_GENERAL_INFORMATION;
  451. typedef struct _ALIAS_NAME_INFORMATION {
  452. UNICODE_STRING Name;
  453. } ALIAS_NAME_INFORMATION, *PALIAS_NAME_INFORMATION;
  454. typedef struct _ALIAS_ADM_COMMENT_INFORMATION {
  455. UNICODE_STRING AdminComment;
  456. } ALIAS_ADM_COMMENT_INFORMATION, *PALIAS_ADM_COMMENT_INFORMATION;
  457. //////////////////////////////////////////////////////////////////////////////
  458. // //
  459. // NT5+ Limited Groups Related Definitions //
  460. // //
  461. //////////////////////////////////////////////////////////////////////////////
  462. //
  463. // Group Flag Definitions to determine Type of Group
  464. //
  465. #define GROUP_TYPE_BUILTIN_LOCAL_GROUP 0x00000001
  466. #define GROUP_TYPE_ACCOUNT_GROUP 0x00000002
  467. #define GROUP_TYPE_RESOURCE_GROUP 0x00000004
  468. #define GROUP_TYPE_UNIVERSAL_GROUP 0x00000008
  469. #define GROUP_TYPE_APP_BASIC_GROUP 0x00000010
  470. #define GROUP_TYPE_APP_QUERY_GROUP 0x00000020
  471. #define GROUP_TYPE_SECURITY_ENABLED 0x80000000
  472. #define GROUP_TYPE_RESOURCE_BEHAVOIR (GROUP_TYPE_RESOURCE_GROUP | \
  473. GROUP_TYPE_APP_BASIC_GROUP | \
  474. GROUP_TYPE_APP_QUERY_GROUP)
  475. ///////////////////////////////////////////////////////////////////////////////
  476. // //
  477. // User Object Related Definitions //
  478. // //
  479. ///////////////////////////////////////////////////////////////////////////////
  480. //
  481. // Access rights for user object
  482. //
  483. #define USER_READ_GENERAL 0x0001
  484. #define USER_READ_PREFERENCES 0x0002
  485. #define USER_WRITE_PREFERENCES 0x0004
  486. #define USER_READ_LOGON 0x0008
  487. #define USER_READ_ACCOUNT 0x0010
  488. #define USER_WRITE_ACCOUNT 0x0020
  489. #define USER_CHANGE_PASSWORD 0x0040
  490. #define USER_FORCE_PASSWORD_CHANGE 0x0080
  491. #define USER_LIST_GROUPS 0x0100
  492. #define USER_READ_GROUP_INFORMATION 0x0200
  493. #define USER_WRITE_GROUP_INFORMATION 0x0400
  494. #define USER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\
  495. USER_READ_PREFERENCES |\
  496. USER_READ_LOGON |\
  497. USER_LIST_GROUPS |\
  498. USER_READ_GROUP_INFORMATION |\
  499. USER_WRITE_PREFERENCES |\
  500. USER_CHANGE_PASSWORD |\
  501. USER_FORCE_PASSWORD_CHANGE |\
  502. USER_READ_GENERAL |\
  503. USER_READ_ACCOUNT |\
  504. USER_WRITE_ACCOUNT |\
  505. USER_WRITE_GROUP_INFORMATION)
  506. #define USER_READ (STANDARD_RIGHTS_READ |\
  507. USER_READ_PREFERENCES |\
  508. USER_READ_LOGON |\
  509. USER_READ_ACCOUNT |\
  510. USER_LIST_GROUPS |\
  511. USER_READ_GROUP_INFORMATION)
  512. #define USER_WRITE (STANDARD_RIGHTS_WRITE |\
  513. USER_WRITE_PREFERENCES |\
  514. USER_CHANGE_PASSWORD)
  515. #define USER_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  516. USER_READ_GENERAL |\
  517. USER_CHANGE_PASSWORD)
  518. //
  519. // User object types
  520. //
  521. // begin_ntsubauth
  522. #ifndef _NTSAM_USER_ACCOUNT_FLAGS_
  523. //
  524. // User account control flags...
  525. //
  526. #define USER_ACCOUNT_DISABLED (0x00000001)
  527. #define USER_HOME_DIRECTORY_REQUIRED (0x00000002)
  528. #define USER_PASSWORD_NOT_REQUIRED (0x00000004)
  529. #define USER_TEMP_DUPLICATE_ACCOUNT (0x00000008)
  530. #define USER_NORMAL_ACCOUNT (0x00000010)
  531. #define USER_MNS_LOGON_ACCOUNT (0x00000020)
  532. #define USER_INTERDOMAIN_TRUST_ACCOUNT (0x00000040)
  533. #define USER_WORKSTATION_TRUST_ACCOUNT (0x00000080)
  534. #define USER_SERVER_TRUST_ACCOUNT (0x00000100)
  535. #define USER_DONT_EXPIRE_PASSWORD (0x00000200)
  536. #define USER_ACCOUNT_AUTO_LOCKED (0x00000400)
  537. #define USER_ENCRYPTED_TEXT_PASSWORD_ALLOWED (0x00000800)
  538. #define USER_SMARTCARD_REQUIRED (0x00001000)
  539. #define USER_TRUSTED_FOR_DELEGATION (0x00002000)
  540. #define USER_NOT_DELEGATED (0x00004000)
  541. #define USER_USE_DES_KEY_ONLY (0x00008000)
  542. #define USER_DONT_REQUIRE_PREAUTH (0x00010000)
  543. #define USER_PASSWORD_EXPIRED (0x00020000)
  544. #define USER_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION (0x00040000)
  545. #define NEXT_FREE_ACCOUNT_CONTROL_BIT (USER_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION << 1)
  546. #define USER_MACHINE_ACCOUNT_MASK \
  547. ( USER_INTERDOMAIN_TRUST_ACCOUNT |\
  548. USER_WORKSTATION_TRUST_ACCOUNT |\
  549. USER_SERVER_TRUST_ACCOUNT)
  550. #define USER_ACCOUNT_TYPE_MASK \
  551. ( USER_TEMP_DUPLICATE_ACCOUNT |\
  552. USER_NORMAL_ACCOUNT |\
  553. USER_MACHINE_ACCOUNT_MASK )
  554. #define USER_COMPUTED_ACCOUNT_CONTROL_BITS \
  555. (USER_ACCOUNT_AUTO_LOCKED | \
  556. USER_PASSWORD_EXPIRED )
  557. //
  558. // Logon times may be expressed in day, hour, or minute granularity.
  559. //
  560. // Days per week = 7
  561. // Hours per week = 168
  562. // Minutes per week = 10080
  563. //
  564. #define SAM_DAYS_PER_WEEK (7)
  565. #define SAM_HOURS_PER_WEEK (24 * SAM_DAYS_PER_WEEK)
  566. #define SAM_MINUTES_PER_WEEK (60 * SAM_HOURS_PER_WEEK)
  567. typedef struct _LOGON_HOURS {
  568. USHORT UnitsPerWeek;
  569. //
  570. // UnitsPerWeek is the number of equal length time units the week is
  571. // divided into. This value is used to compute the length of the bit
  572. // string in logon_hours. Must be less than or equal to
  573. // SAM_UNITS_PER_WEEK (10080) for this release.
  574. //
  575. // LogonHours is a bit map of valid logon times. Each bit represents
  576. // a unique division in a week. The largest bit map supported is 1260
  577. // bytes (10080 bits), which represents minutes per week. In this case
  578. // the first bit (bit 0, byte 0) is Sunday, 00:00:00 - 00-00:59; bit 1,
  579. // byte 0 is Sunday, 00:01:00 - 00:01:59, etc. A NULL pointer means
  580. // DONT_CHANGE for SamSetInformationUser() calls.
  581. //
  582. PUCHAR LogonHours;
  583. } LOGON_HOURS, *PLOGON_HOURS;
  584. typedef struct _SR_SECURITY_DESCRIPTOR {
  585. ULONG Length;
  586. PUCHAR SecurityDescriptor;
  587. } SR_SECURITY_DESCRIPTOR, *PSR_SECURITY_DESCRIPTOR;
  588. #define _NTSAM_USER_ACCOUNT_FLAG_
  589. #endif
  590. // end_ntsubauth
  591. typedef enum _USER_INFORMATION_CLASS {
  592. UserGeneralInformation = 1,
  593. UserPreferencesInformation,
  594. UserLogonInformation,
  595. UserLogonHoursInformation,
  596. UserAccountInformation,
  597. UserNameInformation,
  598. UserAccountNameInformation,
  599. UserFullNameInformation,
  600. UserPrimaryGroupInformation,
  601. UserHomeInformation,
  602. UserScriptInformation,
  603. UserProfileInformation,
  604. UserAdminCommentInformation,
  605. UserWorkStationsInformation,
  606. UserSetPasswordInformation,
  607. UserControlInformation,
  608. UserExpiresInformation,
  609. UserInternal1Information,
  610. UserInternal2Information,
  611. UserParametersInformation,
  612. UserAllInformation,
  613. UserInternal3Information,
  614. UserInternal4Information,
  615. UserInternal5Information,
  616. UserInternal4InformationNew,
  617. UserInternal5InformationNew,
  618. UserInternal6Information
  619. } USER_INFORMATION_CLASS, *PUSER_INFORMATION_CLASS;
  620. // begin_ntsubauth
  621. #ifndef _NTSAM_USER_ALL_INFO_
  622. #include "pshpack4.h"
  623. typedef struct _USER_ALL_INFORMATION {
  624. LARGE_INTEGER LastLogon;
  625. LARGE_INTEGER LastLogoff;
  626. LARGE_INTEGER PasswordLastSet;
  627. LARGE_INTEGER AccountExpires;
  628. LARGE_INTEGER PasswordCanChange;
  629. LARGE_INTEGER PasswordMustChange;
  630. UNICODE_STRING UserName;
  631. UNICODE_STRING FullName;
  632. UNICODE_STRING HomeDirectory;
  633. UNICODE_STRING HomeDirectoryDrive;
  634. UNICODE_STRING ScriptPath;
  635. UNICODE_STRING ProfilePath;
  636. UNICODE_STRING AdminComment;
  637. UNICODE_STRING WorkStations;
  638. UNICODE_STRING UserComment;
  639. UNICODE_STRING Parameters;
  640. UNICODE_STRING LmPassword;
  641. UNICODE_STRING NtPassword;
  642. UNICODE_STRING PrivateData;
  643. SR_SECURITY_DESCRIPTOR SecurityDescriptor;
  644. ULONG UserId;
  645. ULONG PrimaryGroupId;
  646. ULONG UserAccountControl;
  647. ULONG WhichFields;
  648. LOGON_HOURS LogonHours;
  649. USHORT BadPasswordCount;
  650. USHORT LogonCount;
  651. USHORT CountryCode;
  652. USHORT CodePage;
  653. BOOLEAN LmPasswordPresent;
  654. BOOLEAN NtPasswordPresent;
  655. BOOLEAN PasswordExpired;
  656. BOOLEAN PrivateDataSensitive;
  657. } USER_ALL_INFORMATION, *PUSER_ALL_INFORMATION;
  658. #include "poppack.h"
  659. #define _NTSAM_USER_ALL_INFO_
  660. #endif
  661. // end_ntsubauth
  662. //
  663. // Bits to be used in UserAllInformation's WhichFields field (to indicate
  664. // which items were queried or set).
  665. //
  666. #define USER_ALL_USERNAME 0x00000001
  667. #define USER_ALL_FULLNAME 0x00000002
  668. #define USER_ALL_USERID 0x00000004
  669. #define USER_ALL_PRIMARYGROUPID 0x00000008
  670. #define USER_ALL_ADMINCOMMENT 0x00000010
  671. #define USER_ALL_USERCOMMENT 0x00000020
  672. #define USER_ALL_HOMEDIRECTORY 0x00000040
  673. #define USER_ALL_HOMEDIRECTORYDRIVE 0x00000080
  674. #define USER_ALL_SCRIPTPATH 0x00000100
  675. #define USER_ALL_PROFILEPATH 0x00000200
  676. #define USER_ALL_WORKSTATIONS 0x00000400
  677. #define USER_ALL_LASTLOGON 0x00000800
  678. #define USER_ALL_LASTLOGOFF 0x00001000
  679. #define USER_ALL_LOGONHOURS 0x00002000
  680. #define USER_ALL_BADPASSWORDCOUNT 0x00004000
  681. #define USER_ALL_LOGONCOUNT 0x00008000
  682. #define USER_ALL_PASSWORDCANCHANGE 0x00010000
  683. #define USER_ALL_PASSWORDMUSTCHANGE 0x00020000
  684. #define USER_ALL_PASSWORDLASTSET 0x00040000
  685. #define USER_ALL_ACCOUNTEXPIRES 0x00080000
  686. #define USER_ALL_USERACCOUNTCONTROL 0x00100000
  687. #ifndef _NTSAM_SAM_USER_PARMS_ // ntsubauth
  688. #define USER_ALL_PARAMETERS 0x00200000 // ntsubauth
  689. #define _NTSAM_SAM_USER_PARMS_ // ntsubauth
  690. #endif // ntsubauth
  691. #define USER_ALL_COUNTRYCODE 0x00400000
  692. #define USER_ALL_CODEPAGE 0x00800000
  693. #define USER_ALL_NTPASSWORDPRESENT 0x01000000 // field AND boolean
  694. #define USER_ALL_LMPASSWORDPRESENT 0x02000000 // field AND boolean
  695. #define USER_ALL_PRIVATEDATA 0x04000000 // field AND boolean
  696. #define USER_ALL_PASSWORDEXPIRED 0x08000000
  697. #define USER_ALL_SECURITYDESCRIPTOR 0x10000000
  698. #define USER_ALL_OWFPASSWORD 0x20000000 // boolean
  699. #define USER_ALL_UNDEFINED_MASK 0xC0000000
  700. //
  701. // Now define masks for fields that are accessed for read by the same
  702. // access type.
  703. //
  704. // Fields that require READ_GENERAL access to read.
  705. //
  706. #define USER_ALL_READ_GENERAL_MASK (USER_ALL_USERNAME | \
  707. USER_ALL_FULLNAME | \
  708. USER_ALL_USERID | \
  709. USER_ALL_PRIMARYGROUPID | \
  710. USER_ALL_ADMINCOMMENT | \
  711. USER_ALL_USERCOMMENT)
  712. //
  713. // Fields that require READ_LOGON access to read.
  714. //
  715. #define USER_ALL_READ_LOGON_MASK (USER_ALL_HOMEDIRECTORY | \
  716. USER_ALL_HOMEDIRECTORYDRIVE | \
  717. USER_ALL_SCRIPTPATH | \
  718. USER_ALL_PROFILEPATH | \
  719. USER_ALL_WORKSTATIONS | \
  720. USER_ALL_LASTLOGON | \
  721. USER_ALL_LASTLOGOFF | \
  722. USER_ALL_LOGONHOURS | \
  723. USER_ALL_BADPASSWORDCOUNT | \
  724. USER_ALL_LOGONCOUNT | \
  725. USER_ALL_PASSWORDCANCHANGE | \
  726. USER_ALL_PASSWORDMUSTCHANGE)
  727. //
  728. // Fields that require READ_ACCOUNT access to read.
  729. //
  730. #define USER_ALL_READ_ACCOUNT_MASK (USER_ALL_PASSWORDLASTSET | \
  731. USER_ALL_ACCOUNTEXPIRES | \
  732. USER_ALL_USERACCOUNTCONTROL | \
  733. USER_ALL_PARAMETERS)
  734. //
  735. // Fields that require READ_PREFERENCES access to read.
  736. //
  737. #define USER_ALL_READ_PREFERENCES_MASK (USER_ALL_COUNTRYCODE | \
  738. USER_ALL_CODEPAGE)
  739. //
  740. // Fields that can only be read by trusted clients.
  741. //
  742. #define USER_ALL_READ_TRUSTED_MASK (USER_ALL_NTPASSWORDPRESENT | \
  743. USER_ALL_LMPASSWORDPRESENT | \
  744. USER_ALL_PASSWORDEXPIRED | \
  745. USER_ALL_SECURITYDESCRIPTOR | \
  746. USER_ALL_PRIVATEDATA)
  747. //
  748. // Fields that can't be read.
  749. //
  750. #define USER_ALL_READ_CANT_MASK USER_ALL_UNDEFINED_MASK
  751. //
  752. // Now define masks for fields that are accessed for write by the same
  753. // access type.
  754. //
  755. // Fields that require WRITE_ACCOUNT access to write.
  756. //
  757. #define USER_ALL_WRITE_ACCOUNT_MASK (USER_ALL_USERNAME | \
  758. USER_ALL_FULLNAME | \
  759. USER_ALL_PRIMARYGROUPID | \
  760. USER_ALL_HOMEDIRECTORY | \
  761. USER_ALL_HOMEDIRECTORYDRIVE | \
  762. USER_ALL_SCRIPTPATH | \
  763. USER_ALL_PROFILEPATH | \
  764. USER_ALL_ADMINCOMMENT | \
  765. USER_ALL_WORKSTATIONS | \
  766. USER_ALL_LOGONHOURS | \
  767. USER_ALL_ACCOUNTEXPIRES | \
  768. USER_ALL_USERACCOUNTCONTROL | \
  769. USER_ALL_PARAMETERS)
  770. //
  771. // Fields that require WRITE_PREFERENCES access to write.
  772. //
  773. #define USER_ALL_WRITE_PREFERENCES_MASK (USER_ALL_USERCOMMENT | \
  774. USER_ALL_COUNTRYCODE | \
  775. USER_ALL_CODEPAGE)
  776. //
  777. // Fields that require FORCE_PASSWORD_CHANGE access to write.
  778. //
  779. // Note that non-trusted clients only set the NT password as a
  780. // UNICODE string. The wrapper will convert it to an LM password,
  781. // OWF and encrypt both versions. Trusted clients can pass in OWF
  782. // versions of either or both.
  783. //
  784. #define USER_ALL_WRITE_FORCE_PASSWORD_CHANGE_MASK \
  785. (USER_ALL_NTPASSWORDPRESENT | \
  786. USER_ALL_LMPASSWORDPRESENT | \
  787. USER_ALL_PASSWORDEXPIRED)
  788. //
  789. // Fields that can only be written by trusted clients.
  790. //
  791. #define USER_ALL_WRITE_TRUSTED_MASK (USER_ALL_LASTLOGON | \
  792. USER_ALL_LASTLOGOFF | \
  793. USER_ALL_BADPASSWORDCOUNT | \
  794. USER_ALL_LOGONCOUNT | \
  795. USER_ALL_PASSWORDLASTSET | \
  796. USER_ALL_SECURITYDESCRIPTOR | \
  797. USER_ALL_PRIVATEDATA)
  798. //
  799. // Fields that can't be written.
  800. //
  801. #define USER_ALL_WRITE_CANT_MASK (USER_ALL_USERID | \
  802. USER_ALL_PASSWORDCANCHANGE | \
  803. USER_ALL_PASSWORDMUSTCHANGE | \
  804. USER_ALL_UNDEFINED_MASK)
  805. typedef struct _USER_GENERAL_INFORMATION {
  806. UNICODE_STRING UserName;
  807. UNICODE_STRING FullName;
  808. ULONG PrimaryGroupId;
  809. UNICODE_STRING AdminComment;
  810. UNICODE_STRING UserComment;
  811. } USER_GENERAL_INFORMATION, *PUSER_GENERAL_INFORMATION;
  812. typedef struct _USER_PREFERENCES_INFORMATION {
  813. UNICODE_STRING UserComment;
  814. UNICODE_STRING Reserved1;
  815. USHORT CountryCode;
  816. USHORT CodePage;
  817. } USER_PREFERENCES_INFORMATION, *PUSER_PREFERENCES_INFORMATION;
  818. typedef struct _USER_PARAMETERS_INFORMATION {
  819. UNICODE_STRING Parameters;
  820. } USER_PARAMETERS_INFORMATION, *PUSER_PARAMETERS_INFORMATION;
  821. #include "pshpack4.h"
  822. typedef struct _USER_LOGON_INFORMATION {
  823. UNICODE_STRING UserName;
  824. UNICODE_STRING FullName;
  825. ULONG UserId;
  826. ULONG PrimaryGroupId;
  827. UNICODE_STRING HomeDirectory;
  828. UNICODE_STRING HomeDirectoryDrive;
  829. UNICODE_STRING ScriptPath;
  830. UNICODE_STRING ProfilePath;
  831. UNICODE_STRING WorkStations;
  832. LARGE_INTEGER LastLogon;
  833. LARGE_INTEGER LastLogoff;
  834. LARGE_INTEGER PasswordLastSet;
  835. LARGE_INTEGER PasswordCanChange;
  836. LARGE_INTEGER PasswordMustChange;
  837. LOGON_HOURS LogonHours;
  838. USHORT BadPasswordCount;
  839. USHORT LogonCount;
  840. ULONG UserAccountControl;
  841. } USER_LOGON_INFORMATION, *PUSER_LOGON_INFORMATION;
  842. #include "poppack.h"
  843. #include "pshpack4.h"
  844. typedef struct _USER_ACCOUNT_INFORMATION {
  845. UNICODE_STRING UserName;
  846. UNICODE_STRING FullName;
  847. ULONG UserId;
  848. ULONG PrimaryGroupId;
  849. UNICODE_STRING HomeDirectory;
  850. UNICODE_STRING HomeDirectoryDrive;
  851. UNICODE_STRING ScriptPath;
  852. UNICODE_STRING ProfilePath;
  853. UNICODE_STRING AdminComment;
  854. UNICODE_STRING WorkStations;
  855. LARGE_INTEGER LastLogon;
  856. LARGE_INTEGER LastLogoff;
  857. LOGON_HOURS LogonHours;
  858. USHORT BadPasswordCount;
  859. USHORT LogonCount;
  860. LARGE_INTEGER PasswordLastSet;
  861. LARGE_INTEGER AccountExpires;
  862. ULONG UserAccountControl;
  863. } USER_ACCOUNT_INFORMATION, *PUSER_ACCOUNT_INFORMATION;
  864. #include "poppack.h"
  865. typedef struct _USER_ACCOUNT_NAME_INFORMATION {
  866. UNICODE_STRING UserName;
  867. } USER_ACCOUNT_NAME_INFORMATION, *PUSER_ACCOUNT_NAME_INFORMATION;
  868. typedef struct _USER_FULL_NAME_INFORMATION {
  869. UNICODE_STRING FullName;
  870. } USER_FULL_NAME_INFORMATION, *PUSER_FULL_NAME_INFORMATION;
  871. typedef struct _USER_NAME_INFORMATION {
  872. UNICODE_STRING UserName;
  873. UNICODE_STRING FullName;
  874. } USER_NAME_INFORMATION, *PUSER_NAME_INFORMATION;
  875. typedef struct _USER_PRIMARY_GROUP_INFORMATION {
  876. ULONG PrimaryGroupId;
  877. } USER_PRIMARY_GROUP_INFORMATION, *PUSER_PRIMARY_GROUP_INFORMATION;
  878. typedef struct _USER_HOME_INFORMATION {
  879. UNICODE_STRING HomeDirectory;
  880. UNICODE_STRING HomeDirectoryDrive;
  881. } USER_HOME_INFORMATION, *PUSER_HOME_INFORMATION;
  882. typedef struct _USER_SCRIPT_INFORMATION {
  883. UNICODE_STRING ScriptPath;
  884. } USER_SCRIPT_INFORMATION, *PUSER_SCRIPT_INFORMATION;
  885. typedef struct _USER_PROFILE_INFORMATION {
  886. UNICODE_STRING ProfilePath;
  887. } USER_PROFILE_INFORMATION, *PUSER_PROFILE_INFORMATION;
  888. typedef struct _USER_ADMIN_COMMENT_INFORMATION {
  889. UNICODE_STRING AdminComment;
  890. } USER_ADMIN_COMMENT_INFORMATION, *PUSER_ADMIN_COMMENT_INFORMATION;
  891. typedef struct _USER_WORKSTATIONS_INFORMATION {
  892. UNICODE_STRING WorkStations;
  893. } USER_WORKSTATIONS_INFORMATION, *PUSER_WORKSTATIONS_INFORMATION;
  894. typedef struct _USER_SET_PASSWORD_INFORMATION {
  895. UNICODE_STRING Password;
  896. BOOLEAN PasswordExpired;
  897. } USER_SET_PASSWORD_INFORMATION, *PUSER_SET_PASSWORD_INFORMATION;
  898. typedef struct _USER_CONTROL_INFORMATION {
  899. ULONG UserAccountControl;
  900. } USER_CONTROL_INFORMATION, *PUSER_CONTROL_INFORMATION;
  901. typedef struct _USER_EXPIRES_INFORMATION {
  902. #if defined(MIDL_PASS)
  903. OLD_LARGE_INTEGER AccountExpires;
  904. #else
  905. LARGE_INTEGER AccountExpires;
  906. #endif
  907. } USER_EXPIRES_INFORMATION, *PUSER_EXPIRES_INFORMATION;
  908. typedef struct _USER_LOGON_HOURS_INFORMATION {
  909. LOGON_HOURS LogonHours;
  910. } USER_LOGON_HOURS_INFORMATION, *PUSER_LOGON_HOURS_INFORMATION;
  911. ///////////////////////////////////////////////////////////////////////////
  912. // //
  913. // Data type used by SamChangePasswordUser3 for better error //
  914. // reporting of password change change failures //
  915. // //
  916. // The field definitions are as follows: //
  917. // //
  918. // ExtendedFailureReason -- Indicates the reason //
  919. // why the new password was not //
  920. // accepted //
  921. // //
  922. // FilterModuleName -- If the password change was failed //
  923. // by a password filter , the name of //
  924. // of the filter DLL is returned in //
  925. // here //
  926. // //
  927. // The following error codes are defined //
  928. // //
  929. // SAM_PWD_CHANGE_NO_ERROR //
  930. // No error, cannot be returned alongwith a failure code for //
  931. // password change //
  932. // //
  933. // SAM_PWD_CHANGE_PASSWORD_TOO_SHORT //
  934. // //
  935. // Supplied password did not meet password length policy //
  936. // //
  937. // SAM_PWD_CHANGE_PWD_IN_HISTORY //
  938. // //
  939. // History restrictions were not met //
  940. // //
  941. // SAM_PWD_CHANGE_USERNAME_IN_PASSWORD //
  942. // Complexity check could not be met because the user //
  943. // name was part of the password //
  944. // //
  945. // SAM_PWD_CHANGE_FULLNAME_IN_PASSWORD //
  946. // //
  947. // Complexity check could not be met because the user's //
  948. // full name was part of the password //
  949. // //
  950. // SAM_PWD_CHANGE_MACHINE_PASSWORD_NOT_DEFAULT //
  951. // //
  952. // The domain has the refuse password change setting //
  953. // enabled. This disallows machine accounts from having //
  954. // anything other than the default password //
  955. // //
  956. // SAM_PWD_CHANGE_FAILED_BY_FILTER //
  957. // //
  958. // The supplied new password failed by a password filter //
  959. // the name of the filter DLL is indicated //
  960. // //
  961. // //
  962. ///////////////////////////////////////////////////////////////////////////
  963. typedef struct _USER_PWD_CHANGE_FAILURE_INFORMATION {
  964. ULONG ExtendedFailureReason;
  965. UNICODE_STRING FilterModuleName;
  966. } USER_PWD_CHANGE_FAILURE_INFORMATION,*PUSER_PWD_CHANGE_FAILURE_INFORMATION;
  967. //
  968. // Currently defined values for ExtendedFailureReason are as follows
  969. //
  970. #define SAM_PWD_CHANGE_NO_ERROR 0
  971. #define SAM_PWD_CHANGE_PASSWORD_TOO_SHORT 1
  972. #define SAM_PWD_CHANGE_PWD_IN_HISTORY 2
  973. #define SAM_PWD_CHANGE_USERNAME_IN_PASSWORD 3
  974. #define SAM_PWD_CHANGE_FULLNAME_IN_PASSWORD 4
  975. #define SAM_PWD_CHANGE_NOT_COMPLEX 5
  976. #define SAM_PWD_CHANGE_MACHINE_PASSWORD_NOT_DEFAULT 6
  977. #define SAM_PWD_CHANGE_FAILED_BY_FILTER 7
  978. #define SAM_PWD_CHANGE_PASSWORD_TOO_LONG 8
  979. #define SAM_PWD_CHANGE_FAILURE_REASON_MAX 8
  980. /////////////////////////////////////////////////////////////////////////////
  981. // //
  982. // Data types used by SAM and Netlogon for database replication //
  983. // //
  984. /////////////////////////////////////////////////////////////////////////////
  985. typedef enum _SECURITY_DB_DELTA_TYPE {
  986. SecurityDbNew = 1,
  987. SecurityDbRename,
  988. SecurityDbDelete,
  989. SecurityDbChangeMemberAdd,
  990. SecurityDbChangeMemberSet,
  991. SecurityDbChangeMemberDel,
  992. SecurityDbChange,
  993. SecurityDbChangePassword
  994. } SECURITY_DB_DELTA_TYPE, *PSECURITY_DB_DELTA_TYPE;
  995. typedef enum _SECURITY_DB_OBJECT_TYPE {
  996. SecurityDbObjectSamDomain = 1,
  997. SecurityDbObjectSamUser,
  998. SecurityDbObjectSamGroup,
  999. SecurityDbObjectSamAlias,
  1000. SecurityDbObjectLsaPolicy,
  1001. SecurityDbObjectLsaTDomain,
  1002. SecurityDbObjectLsaAccount,
  1003. SecurityDbObjectLsaSecret
  1004. } SECURITY_DB_OBJECT_TYPE, *PSECURITY_DB_OBJECT_TYPE;
  1005. //
  1006. // Account types
  1007. //
  1008. // Both enumerated types and flag definitions are provided.
  1009. // The flag definitions are used in places where more than
  1010. // one type of account may be specified together.
  1011. //
  1012. typedef enum _SAM_ACCOUNT_TYPE {
  1013. SamObjectUser = 1,
  1014. SamObjectGroup ,
  1015. SamObjectAlias
  1016. } SAM_ACCOUNT_TYPE, *PSAM_ACCOUNT_TYPE;
  1017. #define SAM_USER_ACCOUNT (0x00000001)
  1018. #define SAM_GLOBAL_GROUP_ACCOUNT (0x00000002)
  1019. #define SAM_LOCAL_GROUP_ACCOUNT (0x00000004)
  1020. //
  1021. // Define the data type used to pass netlogon information on the account
  1022. // that was added or deleted from a group.
  1023. //
  1024. typedef struct _SAM_GROUP_MEMBER_ID {
  1025. ULONG MemberRid;
  1026. } SAM_GROUP_MEMBER_ID, *PSAM_GROUP_MEMBER_ID;
  1027. //
  1028. // Define the data type used to pass netlogon information on the account
  1029. // that was added or deleted from an alias.
  1030. //
  1031. typedef struct _SAM_ALIAS_MEMBER_ID {
  1032. PSID MemberSid;
  1033. } SAM_ALIAS_MEMBER_ID, *PSAM_ALIAS_MEMBER_ID;
  1034. //
  1035. // Define the data type used to pass netlogon information on a delta
  1036. //
  1037. typedef union _SAM_DELTA_DATA {
  1038. //
  1039. // Delta type ChangeMember{Add/Del/Set} and account type group
  1040. //
  1041. SAM_GROUP_MEMBER_ID GroupMemberId;
  1042. //
  1043. // Delta type ChangeMember{Add/Del/Set} and account type alias
  1044. //
  1045. SAM_ALIAS_MEMBER_ID AliasMemberId;
  1046. //
  1047. // Delta type AddOrChange and account type User
  1048. //
  1049. ULONG AccountControl;
  1050. } SAM_DELTA_DATA, *PSAM_DELTA_DATA;
  1051. //
  1052. // Prototype for delta notification routine.
  1053. //
  1054. typedef NTSTATUS (*PSAM_DELTA_NOTIFICATION_ROUTINE) (
  1055. IN PSID DomainSid,
  1056. IN SECURITY_DB_DELTA_TYPE DeltaType,
  1057. IN SECURITY_DB_OBJECT_TYPE ObjectType,
  1058. IN ULONG ObjectRid,
  1059. IN OPTIONAL PUNICODE_STRING ObjectName,
  1060. IN PLARGE_INTEGER ModifiedCount,
  1061. IN PSAM_DELTA_DATA DeltaData OPTIONAL
  1062. );
  1063. #define SAM_DELTA_NOTIFY_ROUTINE "DeltaNotify"
  1064. //////////////////////////////////////////////////////////////////
  1065. // //
  1066. // Structure and ProtoType for RAS User Parameters //
  1067. // //
  1068. //////////////////////////////////////////////////////////////////
  1069. // Flags used by SAM UserParms Migration
  1070. // indicate UserParmsConvert is called during upgrade.
  1071. #define SAM_USERPARMS_DURING_UPGRADE 0x00000001
  1072. typedef struct _SAM_USERPARMS_ATTRVALS {
  1073. ULONG length; // length of the attribute.
  1074. PVOID value; // pointer to the value.
  1075. } SAM_USERPARMS_ATTRVALS, *PSAM_USERPARMS_ATTRVALS; // describes one value of the attribute.
  1076. typedef enum _SAM_USERPARMS_ATTRSYNTAX {
  1077. Syntax_Attribute = 1,
  1078. Syntax_EncryptedAttribute
  1079. } SAM_USERPARMS_ATTRSYNTAX; // indicates whether attributes are encrypted or not.
  1080. typedef struct _SAM_USERPARMS_ATTR {
  1081. UNICODE_STRING AttributeIdentifier; // This will be the LDAP display name of the attribute.
  1082. // SAM will perform the translation to attribute ID.
  1083. // unless the specified syntax is type EncryptedAttribute,
  1084. // in which case it is packaged as part of supplemental
  1085. // credentials blob and the name identifes the package name.
  1086. // Encrypted attribute will be supplied in the clear ie decrypted.
  1087. SAM_USERPARMS_ATTRSYNTAX Syntax;
  1088. ULONG CountOfValues; // The count of values in the attribute.
  1089. SAM_USERPARMS_ATTRVALS * Values; // pointer to an array of values representing the data
  1090. // values of the attribute.
  1091. } SAM_USERPARMS_ATTR, *PSAM_USERPARMS_ATTR; // describes an attribute and the set of values associated with it.
  1092. typedef struct _SAM_USERPARMS_ATTRBLOCK {
  1093. ULONG attCount;
  1094. SAM_USERPARMS_ATTR * UserParmsAttr;
  1095. } SAM_USERPARMS_ATTRBLOCK, *PSAM_USERPARMS_ATTRBLOCK; // describes an array of attributes
  1096. typedef NTSTATUS (*PSAM_USERPARMS_CONVERT_NOTIFICATION_ROUTINE) (
  1097. IN ULONG Flags,
  1098. IN PSID DomainSid,
  1099. IN ULONG ObjectRid, // identifies the object
  1100. IN ULONG UserParmsLengthOrig,
  1101. IN PVOID UserParmsOrig,
  1102. IN ULONG UserParmsLengthNew,
  1103. IN PVOID UserParmsNew,
  1104. OUT PSAM_USERPARMS_ATTRBLOCK * UserParmsAttrBlock
  1105. );
  1106. #define SAM_USERPARMS_CONVERT_NOTIFICATION_ROUTINE "UserParmsConvert"
  1107. typedef VOID (*PSAM_USERPARMS_ATTRBLOCK_FREE_ROUTINE) (
  1108. IN PSAM_USERPARMS_ATTRBLOCK UserParmsAttrBlock
  1109. );
  1110. #define SAM_USERPARMS_ATTRBLOCK_FREE_ROUTINE "UserParmsFree"
  1111. //////////////////////////////////////////////////////////////////
  1112. // //
  1113. // Return Values for Compatiblity Mode //
  1114. // //
  1115. //////////////////////////////////////////////////////////////////
  1116. // All SAM attributes are accessible
  1117. #define SAM_SID_COMPATIBILITY_ALL 0
  1118. // Rid field can be returned to caller as 0
  1119. // No writes to PrimaryGroupId allowed
  1120. #define SAM_SID_COMPATIBILITY_LAX 1
  1121. // NET API Information levels that ask for RID are to failed
  1122. // No writes to PrimaryGroupId allowed
  1123. #define SAM_SID_COMPATIBILITY_STRICT 2
  1124. //
  1125. // *************************************
  1126. //
  1127. // Internal Password Checking API structures
  1128. //
  1129. // *************************************
  1130. //
  1131. //
  1132. // What kind of password checking is to be performed?
  1133. // SamValidateAuthentication : Check if the authentication can be done
  1134. // SamValidatePasswordChange: Check if the password can be changed
  1135. // SamValidatePasswordReset: Reset the password to the given value
  1136. //
  1137. typedef enum _PASSWORD_POLICY_VALIDATION_TYPE{
  1138. SamValidateAuthentication = 1,
  1139. SamValidatePasswordChange,
  1140. SamValidatePasswordReset
  1141. } PASSWORD_POLICY_VALIDATION_TYPE;
  1142. //
  1143. // Structure to keep the password hash
  1144. //
  1145. typedef struct _SAM_VALIDATE_PASSWORD_HASH{
  1146. ULONG Length;
  1147. #ifdef MIDL_PASS
  1148. [unique,size_is(Length)]
  1149. #endif
  1150. PUCHAR Hash;
  1151. } SAM_VALIDATE_PASSWORD_HASH, *PSAM_VALIDATE_PASSWORD_HASH;
  1152. // To be used with PresentFields member of SAM_VALIDATE_PERSISTED_FIELDS
  1153. #define SAM_VALIDATE_PASSWORD_LAST_SET 0x00000001
  1154. #define SAM_VALIDATE_BAD_PASSWORD_TIME 0x00000002
  1155. #define SAM_VALIDATE_LOCKOUT_TIME 0x00000004
  1156. #define SAM_VALIDATE_BAD_PASSWORD_COUNT 0x00000008
  1157. #define SAM_VALIDATE_PASSWORD_HISTORY_LENGTH 0x00000010
  1158. #define SAM_VALIDATE_PASSWORD_HISTORY 0x00000020
  1159. //
  1160. // Structure to keep information about the password and related things.
  1161. // Present Fields: (used only in output args) which fields are changed.
  1162. // See the constants above.
  1163. // PasswordLastSet: When the password is last set.
  1164. // BadPasswordTime: When the password was incorrect for the last time.
  1165. // LockoutTime: When the account is locked out. If the account is not locked out
  1166. // it is 0.
  1167. // BadPasswordCount: How many times the password has given incorrectly in the
  1168. // Observation Window.
  1169. // PasswordHistoryLength: How many passwords are kept in the history
  1170. // PasswordHistory: Password hashes that are in the history
  1171. //
  1172. typedef struct _SAM_VALIDATE_PERSISTED_FIELDS{
  1173. ULONG PresentFields;
  1174. LARGE_INTEGER PasswordLastSet;
  1175. LARGE_INTEGER BadPasswordTime;
  1176. LARGE_INTEGER LockoutTime;
  1177. ULONG BadPasswordCount;
  1178. ULONG PasswordHistoryLength;
  1179. #ifdef MIDL_PASS
  1180. [unique,size_is(PasswordHistoryLength)]
  1181. #endif
  1182. PSAM_VALIDATE_PASSWORD_HASH PasswordHistory;
  1183. } SAM_VALIDATE_PERSISTED_FIELDS, *PSAM_VALIDATE_PERSISTED_FIELDS;
  1184. //
  1185. // Validation Status of the password check:
  1186. // Names are self-explaining so I think there is no need to explain them here.
  1187. //
  1188. typedef enum _SAM_VALIDATE_VALIDATION_STATUS{
  1189. SamValidateSuccess = 0,
  1190. SamValidatePasswordMustChange,
  1191. SamValidateAccountLockedOut,
  1192. SamValidatePasswordExpired,
  1193. SamValidatePasswordIncorrect,
  1194. SamValidatePasswordIsInHistory,
  1195. SamValidatePasswordTooShort,
  1196. SamValidatePasswordTooLong,
  1197. SamValidatePasswordNotComplexEnough,
  1198. SamValidatePasswordTooRecent,
  1199. SamValidatePasswordFilterError
  1200. }SAM_VALIDATE_VALIDATION_STATUS, *PSAM_VALIDATE_VALIDATION_STATUS;
  1201. //
  1202. // Output Arg
  1203. // ChangedPersistedFields: Any changes to the password related info
  1204. // ValidationStatus: Shows the result of the request
  1205. //
  1206. typedef struct _SAM_VALIDATE_STANDARD_OUTPUT_ARG{
  1207. SAM_VALIDATE_PERSISTED_FIELDS ChangedPersistedFields;
  1208. SAM_VALIDATE_VALIDATION_STATUS ValidationStatus;
  1209. } SAM_VALIDATE_STANDARD_OUTPUT_ARG, *PSAM_VALIDATE_STANDARD_OUTPUT_ARG;
  1210. //
  1211. // If authentication type of password check is to be made,
  1212. // this kind of input must be used
  1213. //
  1214. // InputPersistedFields: Information about the account to be logged into
  1215. // PasswordMatched: Indicates the result of the application's authentication of the supplied password
  1216. typedef struct _SAM_VALIDATE_AUTHENTICATION_INPUT_ARG{
  1217. SAM_VALIDATE_PERSISTED_FIELDS InputPersistedFields;
  1218. BOOLEAN PasswordMatched; // indicates the result of the application's authentication of the supplied password
  1219. } SAM_VALIDATE_AUTHENTICATION_INPUT_ARG, *PSAM_VALIDATE_AUTHENTICATION_INPUT_ARG;
  1220. //
  1221. // If password change type of check is to be made,
  1222. // this kind of input must be used
  1223. //
  1224. // InputPersistedFields: Information about the account to be logged into
  1225. // ClearPassword: The string which password is going to be
  1226. // UserAccountName: Name of the user account
  1227. // HashedPassword: Hash of the string that the password is going to be
  1228. // PasswordMatch: denotes if the old password supplied by user matched or not
  1229. //
  1230. typedef struct _SAM_VALIDATE_PASSWORD_CHANGE_INPUT_ARG{
  1231. SAM_VALIDATE_PERSISTED_FIELDS InputPersistedFields;
  1232. UNICODE_STRING ClearPassword;
  1233. UNICODE_STRING UserAccountName;
  1234. SAM_VALIDATE_PASSWORD_HASH HashedPassword;
  1235. BOOLEAN PasswordMatch; // denotes if the old password supplied by user matched or not.
  1236. } SAM_VALIDATE_PASSWORD_CHANGE_INPUT_ARG, *PSAM_VALIDATE_PASSWORD_CHANGE_INPUT_ARG;
  1237. //
  1238. // If password reset type of check is to be made,
  1239. // this kind of input must be used
  1240. //
  1241. // InputPersistedFields: Information about the account to be logged into
  1242. // ClearPassword: The string which password is going to be
  1243. // UserAccountName: Name of the user account
  1244. // HashedPassword: Hash of the string that the password is going to be
  1245. // PasswordMustChangeAtNextLogon: Password must change for the user to be logged in
  1246. // ClearLockout: If the account was locked out, this field can be used to clear lockout
  1247. //
  1248. typedef struct _SAM_VALIDATE_PASSWORD_RESET_INPUT_ARG{
  1249. SAM_VALIDATE_PERSISTED_FIELDS InputPersistedFields;
  1250. UNICODE_STRING ClearPassword;
  1251. UNICODE_STRING UserAccountName;
  1252. SAM_VALIDATE_PASSWORD_HASH HashedPassword;
  1253. BOOLEAN PasswordMustChangeAtNextLogon; // looked at only for password reset
  1254. BOOLEAN ClearLockout; // can be used clear user account lockout --
  1255. }SAM_VALIDATE_PASSWORD_RESET_INPUT_ARG, *PSAM_VALIDATE_PASSWORD_RESET_INPUT_ARG;
  1256. //
  1257. // A union to encapsulate all kinds of inputs
  1258. //
  1259. typedef
  1260. #ifdef MIDL_PASS
  1261. [switch_type(PASSWORD_POLICY_VALIDATION_TYPE)]
  1262. #endif
  1263. union _SAM_VALIDATE_INPUT_ARG{
  1264. #ifdef MIDL_PASS
  1265. [case(SamValidateAuthentication)]
  1266. #endif
  1267. SAM_VALIDATE_AUTHENTICATION_INPUT_ARG ValidateAuthenticationInput;
  1268. #ifdef MIDL_PASS
  1269. [case(SamValidatePasswordChange)]
  1270. #endif
  1271. SAM_VALIDATE_PASSWORD_CHANGE_INPUT_ARG ValidatePasswordChangeInput;
  1272. #ifdef MIDL_PASS
  1273. [case(SamValidatePasswordReset)]
  1274. #endif
  1275. SAM_VALIDATE_PASSWORD_RESET_INPUT_ARG ValidatePasswordResetInput;
  1276. } SAM_VALIDATE_INPUT_ARG, *PSAM_VALIDATE_INPUT_ARG;
  1277. //
  1278. // A union to encapsulate all kinds of outputs
  1279. // Actually, currently there is only one type of output,
  1280. // but this can be used when there is a need for another
  1281. // type of output.
  1282. //
  1283. typedef
  1284. #ifdef MIDL_PASS
  1285. [switch_type(PASSWORD_POLICY_VALIDATION_TYPE)]
  1286. #endif
  1287. union _SAM_VALIDATE_OUTPUT_ARG{
  1288. #ifdef MIDL_PASS
  1289. [case(SamValidateAuthentication)]
  1290. #endif
  1291. SAM_VALIDATE_STANDARD_OUTPUT_ARG ValidateAuthenticationOutput;
  1292. #ifdef MIDL_PASS
  1293. [case(SamValidatePasswordChange)]
  1294. #endif
  1295. SAM_VALIDATE_STANDARD_OUTPUT_ARG ValidatePasswordChangeOutput;
  1296. #ifdef MIDL_PASS
  1297. [case(SamValidatePasswordReset)]
  1298. #endif
  1299. SAM_VALIDATE_STANDARD_OUTPUT_ARG ValidatePasswordResetOutput;
  1300. } SAM_VALIDATE_OUTPUT_ARG, *PSAM_VALIDATE_OUTPUT_ARG;
  1301. //
  1302. // Internal Password Checking API structures end here!
  1303. //
  1304. ///////////////////////////////////////////////////////////////////////////////
  1305. // //
  1306. // APIs Exported By SAM //
  1307. // //
  1308. ///////////////////////////////////////////////////////////////////////////////
  1309. NTSTATUS
  1310. SamFreeMemory(
  1311. IN PVOID Buffer
  1312. );
  1313. NTSTATUS
  1314. SamSetSecurityObject(
  1315. IN SAM_HANDLE ObjectHandle,
  1316. IN SECURITY_INFORMATION SecurityInformation,
  1317. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  1318. );
  1319. NTSTATUS
  1320. SamQuerySecurityObject(
  1321. IN SAM_HANDLE ObjectHandle,
  1322. IN SECURITY_INFORMATION SecurityInformation,
  1323. OUT PSECURITY_DESCRIPTOR *SecurityDescriptor
  1324. );
  1325. NTSTATUS
  1326. SamCloseHandle(
  1327. IN SAM_HANDLE SamHandle
  1328. );
  1329. NTSTATUS
  1330. SamConnect(
  1331. IN PUNICODE_STRING ServerName,
  1332. OUT PSAM_HANDLE ServerHandle,
  1333. IN ACCESS_MASK DesiredAccess,
  1334. IN POBJECT_ATTRIBUTES ObjectAttributes
  1335. );
  1336. NTSTATUS
  1337. SamShutdownSamServer(
  1338. IN SAM_HANDLE ServerHandle
  1339. );
  1340. NTSTATUS
  1341. SamLookupDomainInSamServer(
  1342. IN SAM_HANDLE ServerHandle,
  1343. IN PUNICODE_STRING Name,
  1344. OUT PSID * DomainId
  1345. );
  1346. NTSTATUS
  1347. SamEnumerateDomainsInSamServer(
  1348. IN SAM_HANDLE ServerHandle,
  1349. IN OUT PSAM_ENUMERATE_HANDLE EnumerationContext,
  1350. OUT PVOID *Buffer,
  1351. IN ULONG PreferedMaximumLength,
  1352. OUT PULONG CountReturned
  1353. );
  1354. NTSTATUS
  1355. SamOpenDomain(
  1356. IN SAM_HANDLE ServerHandle,
  1357. IN ACCESS_MASK DesiredAccess,
  1358. IN PSID DomainId,
  1359. OUT PSAM_HANDLE DomainHandle
  1360. );
  1361. NTSTATUS
  1362. SamQueryInformationDomain(
  1363. IN SAM_HANDLE DomainHandle,
  1364. IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
  1365. OUT PVOID *Buffer
  1366. );
  1367. NTSTATUS
  1368. SamSetInformationDomain(
  1369. IN SAM_HANDLE DomainHandle,
  1370. IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
  1371. IN PVOID DomainInformation
  1372. );
  1373. NTSTATUS
  1374. SamCreateGroupInDomain(
  1375. IN SAM_HANDLE DomainHandle,
  1376. IN PUNICODE_STRING AccountName,
  1377. IN ACCESS_MASK DesiredAccess,
  1378. OUT PSAM_HANDLE GroupHandle,
  1379. OUT PULONG RelativeId
  1380. );
  1381. NTSTATUS
  1382. SamEnumerateGroupsInDomain(
  1383. IN SAM_HANDLE DomainHandle,
  1384. IN OUT PSAM_ENUMERATE_HANDLE EnumerationContext,
  1385. OUT PVOID *Buffer,
  1386. IN ULONG PreferedMaximumLength,
  1387. OUT PULONG CountReturned
  1388. );
  1389. NTSTATUS
  1390. SamCreateUser2InDomain(
  1391. IN SAM_HANDLE DomainHandle,
  1392. IN PUNICODE_STRING AccountName,
  1393. IN ULONG AccountType,
  1394. IN ACCESS_MASK DesiredAccess,
  1395. OUT PSAM_HANDLE UserHandle,
  1396. OUT PULONG GrantedAccess,
  1397. OUT PULONG RelativeId
  1398. );
  1399. NTSTATUS
  1400. SamCreateUserInDomain(
  1401. IN SAM_HANDLE DomainHandle,
  1402. IN PUNICODE_STRING AccountName,
  1403. IN ACCESS_MASK DesiredAccess,
  1404. OUT PSAM_HANDLE UserHandle,
  1405. OUT PULONG RelativeId
  1406. );
  1407. NTSTATUS
  1408. SamEnumerateUsersInDomain(
  1409. IN SAM_HANDLE DomainHandle,
  1410. IN OUT PSAM_ENUMERATE_HANDLE EnumerationContext,
  1411. IN ULONG UserAccountControl,
  1412. OUT PVOID *Buffer,
  1413. IN ULONG PreferedMaximumLength,
  1414. OUT PULONG CountReturned
  1415. );
  1416. NTSTATUS
  1417. SamCreateAliasInDomain(
  1418. IN SAM_HANDLE DomainHandle,
  1419. IN PUNICODE_STRING AccountName,
  1420. IN ACCESS_MASK DesiredAccess,
  1421. OUT PSAM_HANDLE AliasHandle,
  1422. OUT PULONG RelativeId
  1423. );
  1424. NTSTATUS
  1425. SamEnumerateAliasesInDomain(
  1426. IN SAM_HANDLE DomainHandle,
  1427. IN OUT PSAM_ENUMERATE_HANDLE EnumerationContext,
  1428. IN PVOID *Buffer,
  1429. IN ULONG PreferedMaximumLength,
  1430. OUT PULONG CountReturned
  1431. );
  1432. NTSTATUS
  1433. SamGetAliasMembership(
  1434. IN SAM_HANDLE DomainHandle,
  1435. IN ULONG PassedCount,
  1436. IN PSID *Sids,
  1437. OUT PULONG MembershipCount,
  1438. OUT PULONG *Aliases
  1439. );
  1440. NTSTATUS
  1441. SamLookupNamesInDomain(
  1442. IN SAM_HANDLE DomainHandle,
  1443. IN ULONG Count,
  1444. IN PUNICODE_STRING Names,
  1445. OUT PULONG *RelativeIds,
  1446. OUT PSID_NAME_USE *Use
  1447. );
  1448. NTSTATUS
  1449. SamLookupIdsInDomain(
  1450. IN SAM_HANDLE DomainHandle,
  1451. IN ULONG Count,
  1452. IN PULONG RelativeIds,
  1453. OUT PUNICODE_STRING *Names,
  1454. OUT PSID_NAME_USE *Use
  1455. );
  1456. NTSTATUS
  1457. SamOpenGroup(
  1458. IN SAM_HANDLE DomainHandle,
  1459. IN ACCESS_MASK DesiredAccess,
  1460. IN ULONG GroupId,
  1461. OUT PSAM_HANDLE GroupHandle
  1462. );
  1463. NTSTATUS
  1464. SamQueryInformationGroup(
  1465. IN SAM_HANDLE GroupHandle,
  1466. IN GROUP_INFORMATION_CLASS GroupInformationClass,
  1467. OUT PVOID *Buffer
  1468. );
  1469. NTSTATUS
  1470. SamSetInformationGroup(
  1471. IN SAM_HANDLE GroupHandle,
  1472. IN GROUP_INFORMATION_CLASS GroupInformationClass,
  1473. IN PVOID Buffer
  1474. );
  1475. NTSTATUS
  1476. SamAddMemberToGroup(
  1477. IN SAM_HANDLE GroupHandle,
  1478. IN ULONG MemberId,
  1479. IN ULONG Attributes
  1480. );
  1481. NTSTATUS
  1482. SamDeleteGroup(
  1483. IN SAM_HANDLE GroupHandle
  1484. );
  1485. NTSTATUS
  1486. SamRemoveMemberFromGroup(
  1487. IN SAM_HANDLE GroupHandle,
  1488. IN ULONG MemberId
  1489. );
  1490. NTSTATUS
  1491. SamGetMembersInGroup(
  1492. IN SAM_HANDLE GroupHandle,
  1493. OUT PULONG * MemberIds,
  1494. OUT PULONG * Attributes,
  1495. OUT PULONG MemberCount
  1496. );
  1497. NTSTATUS
  1498. SamSetMemberAttributesOfGroup(
  1499. IN SAM_HANDLE GroupHandle,
  1500. IN ULONG MemberId,
  1501. IN ULONG Attributes
  1502. );
  1503. NTSTATUS
  1504. SamOpenAlias(
  1505. IN SAM_HANDLE DomainHandle,
  1506. IN ACCESS_MASK DesiredAccess,
  1507. IN ULONG AliasId,
  1508. OUT PSAM_HANDLE AliasHandle
  1509. );
  1510. NTSTATUS
  1511. SamQueryInformationAlias(
  1512. IN SAM_HANDLE AliasHandle,
  1513. IN ALIAS_INFORMATION_CLASS AliasInformationClass,
  1514. OUT PVOID *Buffer
  1515. );
  1516. NTSTATUS
  1517. SamSetInformationAlias(
  1518. IN SAM_HANDLE AliasHandle,
  1519. IN ALIAS_INFORMATION_CLASS AliasInformationClass,
  1520. IN PVOID Buffer
  1521. );
  1522. NTSTATUS
  1523. SamDeleteAlias(
  1524. IN SAM_HANDLE AliasHandle
  1525. );
  1526. NTSTATUS
  1527. SamAddMemberToAlias(
  1528. IN SAM_HANDLE AliasHandle,
  1529. IN PSID MemberId
  1530. );
  1531. NTSTATUS
  1532. SamAddMultipleMembersToAlias(
  1533. IN SAM_HANDLE AliasHandle,
  1534. IN PSID *MemberIds,
  1535. IN ULONG MemberCount
  1536. );
  1537. NTSTATUS
  1538. SamRemoveMemberFromAlias(
  1539. IN SAM_HANDLE AliasHandle,
  1540. IN PSID MemberId
  1541. );
  1542. NTSTATUS
  1543. SamRemoveMultipleMembersFromAlias(
  1544. IN SAM_HANDLE AliasHandle,
  1545. IN PSID *MemberIds,
  1546. IN ULONG MemberCount
  1547. );
  1548. NTSTATUS
  1549. SamRemoveMemberFromForeignDomain(
  1550. IN SAM_HANDLE DomainHandle,
  1551. IN PSID MemberId
  1552. );
  1553. NTSTATUS
  1554. SamGetMembersInAlias(
  1555. IN SAM_HANDLE AliasHandle,
  1556. OUT PSID **MemberIds,
  1557. OUT PULONG MemberCount
  1558. );
  1559. NTSTATUS
  1560. SamOpenUser(
  1561. IN SAM_HANDLE DomainHandle,
  1562. IN ACCESS_MASK DesiredAccess,
  1563. IN ULONG UserId,
  1564. OUT PSAM_HANDLE UserHandle
  1565. );
  1566. NTSTATUS
  1567. SamDeleteUser(
  1568. IN SAM_HANDLE UserHandle
  1569. );
  1570. NTSTATUS
  1571. SamQueryInformationUser(
  1572. IN SAM_HANDLE UserHandle,
  1573. IN USER_INFORMATION_CLASS UserInformationClass,
  1574. OUT PVOID * Buffer
  1575. );
  1576. NTSTATUS
  1577. SamSetInformationUser(
  1578. IN SAM_HANDLE UserHandle,
  1579. IN USER_INFORMATION_CLASS UserInformationClass,
  1580. IN PVOID Buffer
  1581. );
  1582. NTSTATUS
  1583. SamChangePasswordUser(
  1584. IN SAM_HANDLE UserHandle,
  1585. IN PUNICODE_STRING OldPassword,
  1586. IN PUNICODE_STRING NewPassword
  1587. );
  1588. NTSTATUS
  1589. SamChangePasswordUser2(
  1590. IN PUNICODE_STRING ServerName,
  1591. IN PUNICODE_STRING UserName,
  1592. IN PUNICODE_STRING OldPassword,
  1593. IN PUNICODE_STRING NewPassword
  1594. );
  1595. NTSTATUS
  1596. SamChangePasswordUser3(
  1597. IN PUNICODE_STRING ServerName,
  1598. IN PUNICODE_STRING UserName,
  1599. IN PUNICODE_STRING OldPassword,
  1600. IN PUNICODE_STRING NewPassword,
  1601. OUT PDOMAIN_PASSWORD_INFORMATION * EffectivePasswordPolicy,
  1602. OUT PUSER_PWD_CHANGE_FAILURE_INFORMATION *PasswordChangeFailureInfo
  1603. );
  1604. NTSTATUS
  1605. SamGetGroupsForUser(
  1606. IN SAM_HANDLE UserHandle,
  1607. OUT PGROUP_MEMBERSHIP * Groups,
  1608. OUT PULONG MembershipCount
  1609. );
  1610. NTSTATUS
  1611. SamQueryDisplayInformation (
  1612. IN SAM_HANDLE DomainHandle,
  1613. IN DOMAIN_DISPLAY_INFORMATION DisplayInformation,
  1614. IN ULONG Index,
  1615. IN ULONG EntryCount,
  1616. IN ULONG PreferredMaximumLength,
  1617. OUT PULONG TotalAvailable,
  1618. OUT PULONG TotalReturned,
  1619. OUT PULONG ReturnedEntryCount,
  1620. OUT PVOID *SortedBuffer
  1621. );
  1622. NTSTATUS
  1623. SamGetDisplayEnumerationIndex (
  1624. IN SAM_HANDLE DomainHandle,
  1625. IN DOMAIN_DISPLAY_INFORMATION DisplayInformation,
  1626. IN PUNICODE_STRING Prefix,
  1627. OUT PULONG Index
  1628. );
  1629. NTSTATUS
  1630. SamRidToSid(
  1631. IN SAM_HANDLE ObjectHandle,
  1632. IN ULONG Rid,
  1633. OUT PSID* Sid
  1634. );
  1635. NTSTATUS
  1636. SamGetCompatibilityMode(
  1637. IN SAM_HANDLE ObjectHandle,
  1638. OUT ULONG* Mode
  1639. );
  1640. NTSTATUS
  1641. SamValidatePassword(
  1642. IN PUNICODE_STRING ServerName,
  1643. IN PASSWORD_POLICY_VALIDATION_TYPE ValidationType,
  1644. IN PSAM_VALIDATE_INPUT_ARG InputArg,
  1645. OUT PSAM_VALIDATE_OUTPUT_ARG *OutputArg
  1646. );
  1647. ////////////////////////////////////////////////////////////////////////////
  1648. // //
  1649. // Interface definitions of services provided by a password filter DLL //
  1650. // //
  1651. ////////////////////////////////////////////////////////////////////////////
  1652. //
  1653. // Routine names
  1654. //
  1655. // The routines provided by the DLL must be assigned the following names
  1656. // so that their addresses can be retrieved when the DLL is loaded.
  1657. //
  1658. //
  1659. // routine templates
  1660. //
  1661. //
  1662. // These guards are in place to allow ntsam.h and ntsecapi.h
  1663. // to be included in the same file.
  1664. //
  1665. // begin_ntsecapi
  1666. #ifndef _PASSWORD_NOTIFICATION_DEFINED
  1667. #define _PASSWORD_NOTIFICATION_DEFINED
  1668. typedef NTSTATUS (*PSAM_PASSWORD_NOTIFICATION_ROUTINE) (
  1669. PUNICODE_STRING UserName,
  1670. ULONG RelativeId,
  1671. PUNICODE_STRING NewPassword
  1672. );
  1673. #define SAM_PASSWORD_CHANGE_NOTIFY_ROUTINE "PasswordChangeNotify"
  1674. typedef BOOLEAN (*PSAM_INIT_NOTIFICATION_ROUTINE) (
  1675. );
  1676. #define SAM_INIT_NOTIFICATION_ROUTINE "InitializeChangeNotify"
  1677. #define SAM_PASSWORD_FILTER_ROUTINE "PasswordFilter"
  1678. typedef BOOLEAN (*PSAM_PASSWORD_FILTER_ROUTINE) (
  1679. IN PUNICODE_STRING AccountName,
  1680. IN PUNICODE_STRING FullName,
  1681. IN PUNICODE_STRING Password,
  1682. IN BOOLEAN SetOperation
  1683. );
  1684. #endif // _PASSWORD_NOTIFICATION_DEFINED
  1685. // end_ntsecapi
  1686. // begin_ntsecpkg
  1687. #ifndef _SAM_CREDENTIAL_UPDATE_DEFINED
  1688. #define _SAM_CREDENTIAL_UPDATE_DEFINED
  1689. typedef NTSTATUS (*PSAM_CREDENTIAL_UPDATE_NOTIFY_ROUTINE) (
  1690. IN PUNICODE_STRING ClearPassword,
  1691. IN PVOID OldCredentials,
  1692. IN ULONG OldCredentialSize,
  1693. IN ULONG UserAccountControl,
  1694. IN PUNICODE_STRING UPN, OPTIONAL
  1695. IN PUNICODE_STRING UserName,
  1696. IN PUNICODE_STRING NetbiosDomainName,
  1697. IN PUNICODE_STRING DnsDomainName,
  1698. OUT PVOID * NewCredentials,
  1699. OUT ULONG * NewCredentialSize
  1700. );
  1701. #define SAM_CREDENTIAL_UPDATE_NOTIFY_ROUTINE "CredentialUpdateNotify"
  1702. typedef BOOLEAN (*PSAM_CREDENTIAL_UPDATE_REGISTER_ROUTINE) (
  1703. OUT PUNICODE_STRING CredentialName
  1704. );
  1705. #define SAM_CREDENTIAL_UPDATE_REGISTER_ROUTINE "CredentialUpdateRegister"
  1706. typedef VOID (*PSAM_CREDENTIAL_UPDATE_FREE_ROUTINE) (
  1707. IN PVOID p
  1708. );
  1709. #define SAM_CREDENTIAL_UPDATE_FREE_ROUTINE "CredentialUpdateFree"
  1710. #endif // _SAM_CREDENTIAL_UPDATE_DEFINED
  1711. // end_ntsecpkg
  1712. #ifdef __cplusplus
  1713. }
  1714. #endif
  1715. #endif // _NTSAM_