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.

1455 lines
38 KiB

  1. ///**************************************************************
  2. /// Microsoft LAN Manager *
  3. /// Copyright(c) Microsoft Corp., 1990-92 *
  4. ///**************************************************************
  5. //
  6. // This program is designed to do functional testing on the following
  7. // APIs:
  8. // NetUserAdd
  9. // NetUserDel
  10. // NetUserGetInfo
  11. // NetUserSetInfo
  12. // NetUserEnum
  13. // NetUserValidate
  14. //
  15. // Note: This leaves two users, User1 & User2, defined on the NET.ACC
  16. // file which are to be used in uastest2, group testing. It also assumes
  17. // a NET.ACC which is just initialized by makeacc.
  18. //
  19. #include <nt.h> // TIME definition
  20. #include <ntrtl.h> // TIME definition
  21. #include <nturtl.h> // TIME definition
  22. #define NOMINMAX // Avoid redefinition of min and max in stdlib.h
  23. #include <windef.h>
  24. #include <winbase.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include <lmcons.h>
  29. #include <lmapibuf.h>
  30. #include <netdebug.h>
  31. #include <netlib.h>
  32. #include <lmaccess.h>
  33. #include <lmerr.h>
  34. #include <ntsam.h>
  35. #include "uastest.h"
  36. #include "accessp.h"
  37. #include "netlogon.h"
  38. #include "logonp.h"
  39. #define HOMEDIR L"C:\\HOMDIR"
  40. #define COMMENT L"COMMENT"
  41. #define SCRIPT L"SCRIPT"
  42. #define SCRIPT_PATH L"SCRIPT_PATH"
  43. #define FULL_NAME L"FULL_NAME"
  44. #define COMMENT2 L"COMMENT2"
  45. #define PARMS L"PARMS"
  46. #define WORK L"WORK"
  47. #define EXPIRES 0xdddddddd
  48. #define STORAGE USER_MAXSTORAGE_UNLIMITED
  49. #define STORAGE2 USER_MAXSTORAGE_UNLIMITED
  50. #define SCRIPT_PATH2 L"SCRIPT_PATH"
  51. #define FULL_NAME2 L"FULL_NAME2"
  52. #define COMMENT22 L"COMMENT2"
  53. #define PARMS2 L"PARMS"
  54. #define WORK2 L"WORK2"
  55. #define EXPIRES2 0xdddddddd
  56. #define SCRIPT2 L"SCRIPT2"
  57. #define HOMEDIR2 L"C:\\HOMEDIR2"
  58. #define PROFILE L"PROFILE"
  59. #define PROFILE2 L"PROFILE2"
  60. #define HOMEDIRDRIVE L"E:";
  61. #define HOMEDIRDRIVE2 L"G:";
  62. #define PASSWORD L"Password"
  63. #define TST_PASSWD L"PARMNUM"
  64. #define TST_FULL_NAME L"PARMNUM_FULL_NAME"
  65. #define TST_ACCT_EXPIRES 0xCCCCCCCC
  66. #define FINAL_PASSWORD L"FINAL_PASSWORD"
  67. #define ADD_PASSWORD L"ADD_PASSWORD"
  68. unsigned char default_logon_hours[] =
  69. {
  70. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  71. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  72. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  73. unsigned char logon_hours1[] =
  74. {
  75. 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
  76. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  77. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  78. unsigned char logon_hours2[] =
  79. {
  80. 0xee, 0xee, 0xee, 0xee, 0xff, 0xff, 0xff,
  81. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  82. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  83. void
  84. CompareString(
  85. LPWSTR TestString,
  86. LPWSTR GoodString,
  87. LPSTR Comment1,
  88. LPWSTR Comment2 )
  89. {
  90. CHAR Buffer[512];
  91. strcpy( Buffer, Comment1 );
  92. if (_wcsicmp(TestString, GoodString) != 0) {
  93. strcat( Buffer, " mismatch" );
  94. error_exit(FAIL, Buffer, Comment2 );
  95. printf(" \"");
  96. PrintUnicode( TestString );
  97. printf( "\" s.b. \"" );
  98. PrintUnicode( GoodString );
  99. printf( "\"\n" );
  100. } else {
  101. strcat( Buffer, " matched correctly" );
  102. error_exit(PASS, Buffer, Comment2 );
  103. }
  104. }
  105. void
  106. set_level1(
  107. USER_INFO_1 *u1p,
  108. LPWSTR namep
  109. )
  110. {
  111. u1p->usri1_name = namep;
  112. u1p->usri1_password = ADD_PASSWORD;
  113. u1p->usri1_password_age = 0;
  114. u1p->usri1_priv = USER_PRIV_USER;
  115. u1p->usri1_home_dir = HOMEDIR;
  116. u1p->usri1_comment = COMMENT;
  117. u1p->usri1_flags = UF_NORMAL_ACCOUNT | UF_SCRIPT;
  118. u1p->usri1_script_path = SCRIPT;
  119. }
  120. void
  121. set_level12(u1p)
  122. USER_INFO_1 *u1p;
  123. {
  124. u1p->usri1_password = NULL;
  125. u1p->usri1_priv = USER_PRIV_USER;
  126. u1p->usri1_home_dir = HOMEDIR2;
  127. u1p->usri1_comment = COMMENT2;
  128. u1p->usri1_flags = UF_NORMAL_ACCOUNT | UF_SCRIPT;
  129. u1p->usri1_script_path = SCRIPT2;
  130. }
  131. void
  132. set_level2(u2p)
  133. USER_INFO_2 *u2p;
  134. {
  135. u2p->usri2_full_name = FULL_NAME;
  136. u2p->usri2_usr_comment = COMMENT2;
  137. u2p->usri2_parms = PARMS;
  138. u2p->usri2_workstations = WORK;
  139. u2p->usri2_acct_expires = EXPIRES;
  140. u2p->usri2_max_storage = STORAGE;
  141. u2p->usri2_units_per_week = UNITS_PER_WEEK;
  142. u2p->usri2_logon_hours = logon_hours1;
  143. u2p->usri2_country_code = 0;
  144. u2p->usri2_code_page = 0;
  145. u2p->usri2_auth_flags = 0;
  146. u2p->usri2_logon_server = NULL;
  147. }
  148. void
  149. set_level22(u2p)
  150. USER_INFO_2 *u2p;
  151. {
  152. u2p->usri2_full_name = FULL_NAME2;
  153. u2p->usri2_usr_comment = COMMENT22;
  154. u2p->usri2_parms = PARMS2;
  155. u2p->usri2_workstations = WORK2;
  156. u2p->usri2_acct_expires = EXPIRES2;
  157. u2p->usri2_max_storage = STORAGE2;
  158. u2p->usri2_logon_hours = logon_hours2;
  159. u2p->usri2_auth_flags = 0;
  160. u2p->usri2_logon_server = NULL;
  161. }
  162. void
  163. set_level3(u3p)
  164. USER_INFO_3 *u3p;
  165. {
  166. u3p->usri3_primary_group_id = DOMAIN_GROUP_RID_USERS;
  167. u3p->usri3_profile = PROFILE;
  168. u3p->usri3_home_dir_drive = HOMEDIRDRIVE;
  169. }
  170. void
  171. set_level32(u3p)
  172. USER_INFO_3 *u3p;
  173. {
  174. u3p->usri3_profile = PROFILE2;
  175. u3p->usri3_home_dir_drive = HOMEDIRDRIVE2;
  176. }
  177. void
  178. compare_level1(
  179. USER_INFO_1 *ui1p,
  180. USER_INFO_1 *uo1p,
  181. LPWSTR test
  182. )
  183. {
  184. //
  185. // validate information
  186. //
  187. error_exit(ACTION, "Validate Level 1 Information", test);
  188. CompareString( ui1p->usri1_name,
  189. uo1p->usri1_name,
  190. "NetUserGetInfo(1) name",
  191. NULL);
  192. if (ui1p->usri1_priv != uo1p->usri1_priv)
  193. error_exit(FAIL, "NetUserGetInfo(1) priv mismatch", NULL);
  194. else
  195. error_exit(PASS, "NetUserGetInfo(1) priv matched correctly", NULL);
  196. CompareString( ui1p->usri1_home_dir,
  197. uo1p->usri1_home_dir,
  198. "NetUserGetInfo(1) home_dir",
  199. NULL);
  200. CompareString( ui1p->usri1_comment,
  201. uo1p->usri1_comment,
  202. "NetUserGetInfo(1) comment",
  203. NULL);
  204. if (ui1p->usri1_flags != uo1p->usri1_flags)
  205. error_exit(FAIL, "NetUserGetInfo(1) flags mismatch", NULL);
  206. else
  207. error_exit(PASS, "NetUserGetInfo(1) flags matched correctly", NULL);
  208. CompareString( ui1p->usri1_script_path,
  209. uo1p->usri1_script_path,
  210. "NetUserGetInfo(1) script_path",
  211. NULL);
  212. }
  213. void
  214. compare_level2(
  215. USER_INFO_2 *ui2p,
  216. USER_INFO_2 *uo2p,
  217. LPWSTR test
  218. )
  219. {
  220. error_exit(ACTION, "Validate Level 2 Information", test);
  221. CompareString( ui2p->usri2_script_path,
  222. uo2p->usri2_script_path,
  223. "NetUserGetInfo(2) script_path",
  224. NULL);
  225. CompareString( ui2p->usri2_full_name,
  226. uo2p->usri2_full_name,
  227. "NetUserGetInfo(2) full_name",
  228. NULL);
  229. CompareString( ui2p->usri2_usr_comment,
  230. uo2p->usri2_usr_comment,
  231. "NetUserGetInfo(2) usr_comment",
  232. NULL);
  233. CompareString( ui2p->usri2_parms,
  234. uo2p->usri2_parms,
  235. "NetUserGetInfo(2) parms",
  236. NULL);
  237. CompareString( ui2p->usri2_workstations,
  238. uo2p->usri2_workstations,
  239. "NetUserGetInfo(2) workstations",
  240. NULL);
  241. if (ui2p->usri2_acct_expires != uo2p->usri2_acct_expires)
  242. error_exit(FAIL, "ACCOUNT_EXPIRES incorrect", NULL);
  243. else
  244. error_exit(PASS, "ACCOUNT_EXPIRES matched correctly", NULL);
  245. if (ui2p->usri2_max_storage != uo2p->usri2_max_storage)
  246. error_exit(FAIL, "MAX_STORAGE incorrect", NULL);
  247. else
  248. error_exit(PASS, "MAX_STORAGE matched correctly", NULL);
  249. if (memcmp (ui2p->usri2_logon_hours, uo2p->usri2_logon_hours, 21) != 0)
  250. error_exit(FAIL, "logon_hours1 incorrect", NULL);
  251. else
  252. error_exit(PASS, "logon_hours1 matched correctly", NULL );
  253. }
  254. void
  255. compare_level3(
  256. USER_INFO_3 *ui3p,
  257. USER_INFO_3 *uo3p,
  258. LPWSTR test
  259. )
  260. {
  261. error_exit(ACTION, "Validate Level 3 Information", test);
  262. CompareString( ui3p->usri3_profile,
  263. uo3p->usri3_profile,
  264. "NetUserGetInfo(3) profile",
  265. NULL);
  266. CompareString( ui3p->usri3_home_dir_drive,
  267. uo3p->usri3_home_dir_drive,
  268. "NetUserGetInfo(3) home_dir_drive",
  269. NULL);
  270. }
  271. void
  272. test_getinfo_10_11_20()
  273. {
  274. USER_INFO_10 *u10p;
  275. USER_INFO_11 *u11p;
  276. USER_INFO_20 *u20p;
  277. //
  278. // GetInfo level 10
  279. //
  280. if (err = NetUserGetInfo(server, USER2, 10, (LPBYTE *)&u10p)) {
  281. error_exit(FAIL, "NetUserGetInfo(10) failed", USER2);
  282. } else {
  283. CompareString( u10p->usri10_name,
  284. USER2,
  285. "NetUserGetInfo(10) name",
  286. USER2);
  287. CompareString( u10p->usri10_usr_comment,
  288. COMMENT2,
  289. "NetUserGetInfo(10) usr_comment",
  290. USER2);
  291. CompareString( u10p->usri10_full_name,
  292. FULL_NAME,
  293. "NetUserGetInfo(10) full_name",
  294. USER2);
  295. (VOID) NetApiBufferFree( u10p );
  296. }
  297. //
  298. // GetInfo level 11
  299. //
  300. if (err = NetUserGetInfo(server, USER2, 11, (LPBYTE *)&u11p )) {
  301. error_exit(FAIL, "NetUserGetInfo(11) failed", USER2);
  302. } else {
  303. CompareString( u11p->usri11_name,
  304. USER2,
  305. "NetUserGetInfo(11) name",
  306. USER2);
  307. CompareString( u11p->usri11_usr_comment,
  308. COMMENT2,
  309. "NetUserGetInfo(11) usr_comment",
  310. USER2);
  311. CompareString( u11p->usri11_full_name,
  312. FULL_NAME,
  313. "NetUserGetInfo(11) full_name",
  314. USER2);
  315. if (u11p->usri11_priv != USER_PRIV_USER)
  316. error_exit(FAIL, "GetInfo(11) prive mismatch", USER2);
  317. CompareString( u11p->usri11_home_dir,
  318. HOMEDIR,
  319. "NetUserGetInfo(11) home_dir",
  320. USER2);
  321. CompareString( u11p->usri11_parms,
  322. PARMS,
  323. "NetUserGetInfo(11) parms",
  324. USER2);
  325. (VOID) NetApiBufferFree( u11p );
  326. }
  327. //
  328. // GetInfo level 20
  329. //
  330. if (err = NetUserGetInfo(server, USER2, 20, (LPBYTE *)&u20p )) {
  331. error_exit(FAIL, "NetUserGetInfo(20) failed", USER2);
  332. } else {
  333. CompareString( u20p->usri20_name,
  334. USER2,
  335. "NetUserGetInfo(20) name",
  336. USER2);
  337. CompareString( u20p->usri20_full_name,
  338. FULL_NAME,
  339. "NetUserGetInfo(20) full_name",
  340. USER2);
  341. (VOID) NetApiBufferFree( u20p );
  342. }
  343. }
  344. void
  345. test_setinfo_l2_parmnum()
  346. {
  347. USER_INFO_2 *ui2p ;
  348. USER_INFO_1011 User1011;
  349. USER_INFO_1017 User1017;
  350. #ifdef NOPASSWORD_SUPPORT
  351. USER_INFO_1003 User1003;
  352. //
  353. // test 1003
  354. // password cant be changed before min_pw_age modal
  355. //
  356. User1003.usri1003_password = TST_PASSWD;
  357. error_exit(ACTION, "Password cant be changed before min_pw_age", USER1);
  358. if (err = NetUserSetInfo(server, USER1, 1003, (LPBYTE)&User1003, NULL )) {
  359. if ( err != ERROR_ACCESS_DENIED )
  360. error_exit(FAIL, "SetInfo of 1003 Incorrect", USER1);
  361. else
  362. error_exit(PASS, "SetInfo of 1003 Denied", USER1);
  363. }
  364. if (err = NetUserPasswordSet(server, USER1,
  365. TST_PASSWD, FINAL_PASSWORD)) {
  366. if ( err != ERROR_NETWORK_ACCESS_DENIED)
  367. error_exit(FAIL, "PasswordSet FINAL_PASSWORD Incorrect", USER1);
  368. else
  369. err("uastest1: Test Passed (PasswordSet of FINAL_PASSWORD Denied)");
  370. }
  371. #endif // NOPASSWORD_SUPPORT
  372. //
  373. // test 1011
  374. //
  375. User1011.usri1011_full_name = TST_FULL_NAME;
  376. if (err = NetUserSetInfo(server, USER1, 1011, (LPBYTE) &User1011, NULL )) {
  377. error_exit(FAIL, "SetInfo 1011 failed", USER1);
  378. }
  379. //
  380. // GetInfo on user using level 2
  381. //
  382. if (err = NetUserGetInfo(server, USER1, 2, (LPBYTE * ) &ui2p)) {
  383. error_exit(FAIL, "GetInfo after SetInfo 1011", USER1);
  384. } else {
  385. CompareString( ui2p->usri2_full_name,
  386. TST_FULL_NAME,
  387. "NetUserSetInfo(1011) full_name",
  388. USER1);
  389. (VOID) NetApiBufferFree( ui2p );
  390. }
  391. //
  392. // test 1017
  393. //
  394. User1017.usri1017_acct_expires = TST_ACCT_EXPIRES;
  395. if (err = NetUserSetInfo(server, USER1, 1017, (LPBYTE)&User1017, NULL )) {
  396. error_exit(FAIL, "SetInfo 1017 failed", USER1);
  397. }
  398. //
  399. // GetInfo on user using level 2
  400. //
  401. if (err = NetUserGetInfo(server, USER1, 2, (LPBYTE *) &ui2p ) ) {
  402. error_exit(FAIL, "GetInfo after SetInfo 1017", USER1);
  403. } else {
  404. if (ui2p->usri2_acct_expires != TST_ACCT_EXPIRES) {
  405. printf( " Got %lx wanted %lx\n",
  406. ui2p->usri2_acct_expires,
  407. TST_ACCT_EXPIRES );
  408. error_exit(FAIL, "SetInfo 1017 mismatch", USER1);
  409. } else
  410. error_exit(PASS, "SetInfo 1017 succeeded", USER1);
  411. (VOID) NetApiBufferFree( ui2p );
  412. }
  413. //
  414. // test PARMNUM_PRIV
  415. // test PARMNUM_FLAGS
  416. // test PARMNUM_PARMS
  417. //
  418. }
  419. #ifdef USER_VAL // ?? UserValidate not implemented
  420. void
  421. test_user_val()
  422. {
  423. unsigned short priv = 0;
  424. struct user_logon_req_1 *ulr0p;
  425. struct user_logon_info_1 *uli0p;
  426. //
  427. // validate of non-user
  428. //
  429. if (err = NetUserValidate(NULL, NOTTHERE, FINAL_PASSWORD, &priv)) {
  430. if (err != ERROR_ACCESS_DENIED)
  431. error_exit(FAIL, "UserValidate NOTTHERE wrong", NULL);
  432. else
  433. error_exit(PASS, "UserValidate ok for NOTTHERE", NULL);
  434. } else
  435. error_exit(FAIL, "UserValidate for NOTTHERE wrong", NULL);
  436. //
  437. // validate of user bad password
  438. //
  439. if (err = NetUserValidate(NULL, USER1, PASSWORD, &priv)) {
  440. if (err != ERROR_ACCESS_DENIED)
  441. error_exit(FAIL, "UserValidate USER1 bad password wrong", USER1);
  442. else
  443. error_exit(PASS, "UserValidate bad password", USER1);
  444. } else
  445. error_exit(FAIL, "UserValidate ok USER1 bad password", USER1);
  446. //
  447. // validate User1
  448. // Note that password can not change before min_pw_age modal
  449. //
  450. if (err = NetUserValidate(NULL, USER1, (char * )ADD_PASSWORD, &priv))
  451. error_exit(FAIL, "UserValidate USER1 wrong", USER1);
  452. else if (priv != USER_PRIV_USER)
  453. error_exit(FAIL, "UserValidate priviledge incorrect", USER1);
  454. else
  455. error_exit(FAIL, "UserValidate USER1 successful", USER1);
  456. //
  457. // validate2 of non-user
  458. //
  459. ulr0p->usrreq1_name = NOTTHERE;
  460. ulr0p->usrreq1_password = FINAL_PASSWORD;
  461. ulr0p->usrreq1_workstation = WORK2;
  462. if (err = NetUserValidate2(NULL, 1, ulr0p, sizeof(*ulr0p), 0, &total)) {
  463. if (err != ERROR_ACCESS_DENIED)
  464. error_exit(FAIL, "UserValidate2 NOTTHERE wrong", NULL );
  465. else
  466. error_exit(PASS, "UserValidate2 NOTTHERE denied", NULL );
  467. } else
  468. error_exit(FAIL, "UserValidate2 NOTTHERE succeeded", NULL );
  469. //
  470. // validate2 of bad password
  471. //
  472. ulr0p->usrreq1_name = USER1;
  473. ulr0p->usrreq1_password = PASSWORD;
  474. ulr0p->usrreq1_workstation = WORK2;
  475. if (err = NetUserValidate2(NULL, 1, ulr0p, sizeof(*ulr0p), 0, &total)) {
  476. if (err != ERROR_ACCESS_DENIED)
  477. error_exit(FAIL, "UserValidate2 USER1 bad password wrong", USER1);
  478. else
  479. error_exit(PASS, "UserValidate2 USER1 bad password denied", USER1);
  480. } else
  481. error_exit(FAIL, "UserValidate2 USER1 bad password succeeded", USER1);
  482. //
  483. // validate2 of User1
  484. //
  485. ulr0p->usrreq1_name = USER1;
  486. ulr0p->usrreq1_password = ADD_PASSWORD;
  487. ulr0p->usrreq1_workstation = WORK2;
  488. if (err = NetUserValidate2(NULL, 1, ulr0p, sizeof(*ulr0p), 0, &total))
  489. error_exit(FAIL, "UserValidate2 USER1 failed", USER1);
  490. else
  491. {
  492. error_exit(PASS, "UserValidate2 USER1 successful", USER1);
  493. if (strcmpf(uli0p->usrlog1_eff_name, USER1) != 0)
  494. error_exit(FAIL, "UserValidate2 effective name mismatch", USER1);
  495. if (uli0p->usrlog1_priv != USER_PRIV_USER)
  496. error_exit(FAIL, "UserValidate2 priviledge mismatch", USER1);
  497. }
  498. }
  499. #endif // USER_VAL // ?? UserValidate not implemented
  500. BOOL
  501. find_ptr( UserEnum, u1, u2, size, level)
  502. LPBYTE UserEnum;
  503. LPBYTE * u1;
  504. LPBYTE * u2;
  505. unsigned short size,
  506. level;
  507. {
  508. LPBYTE p1;
  509. LPWSTR p2;
  510. DWORD i;
  511. BOOL ExitStatus = TRUE;
  512. // users in the domain are GUEST, ADMIN, USER1 and USER2, so the
  513. // nread and total must be equal to 4.
  514. if ((nread != total) || (nread != 4)) {
  515. err = 0;
  516. error_exit(FAIL, "NetUserEnum nread incorect", NULL);
  517. printf("nread = %d, total = %d\n", nread, total);
  518. TEXIT;
  519. }
  520. *u1 = NULL;
  521. *u2 = NULL;
  522. p1 = UserEnum;
  523. for (i = 0; i < nread; i++, p1 += size) {
  524. p2 = *((WCHAR **)p1);
  525. if (_wcsicmp(p2, USER1) == 0) {
  526. *u1 = p1;
  527. } else if (_wcsicmp( p2, USER2) == 0) {
  528. *u2 = p1;
  529. } else {
  530. if ((_wcsicmp(p2, L"ADMIN") != 0) && (_wcsicmp(p2, L"GUEST") != 0)) {
  531. printf("UASTEST1: FAIL - Invalid user '%ws' in enum buffer level %d\n", p2, level);
  532. TEXIT;
  533. ExitStatus = FALSE;
  534. }
  535. }
  536. }
  537. if (*u1 == NULL) {
  538. printf("UASTEST1: FAIL - Did not find USER1 in level %d enum\n", level);
  539. TEXIT;
  540. ExitStatus = FALSE;
  541. }
  542. if (*u2 == NULL) {
  543. printf("UASTEST1: FAIL - Did not find USER2 in level %d enum\n", level);
  544. TEXIT;
  545. ExitStatus = FALSE;
  546. }
  547. return ExitStatus;
  548. }
  549. void
  550. validate_enum0(
  551. PUSER_INFO_2 User1Info,
  552. PUSER_INFO_2 User2Info
  553. )
  554. {
  555. NET_API_STATUS err;
  556. USER_INFO_0 *u1, *u2;
  557. PUSER_INFO_0 UserEnum;
  558. if (err = NetUserEnum( NULL,
  559. 0,
  560. ENUM_FILTER,
  561. (LPBYTE *)&UserEnum,
  562. (DWORD)0xffffffff,
  563. &nread,
  564. &total,
  565. NULL)) {
  566. error_exit(FAIL, "NetUserEnum(0) validate_enum0", NULL);
  567. return;
  568. }
  569. (VOID) find_ptr((LPBYTE) UserEnum, (LPBYTE * ) & u1, (LPBYTE * ) & u2,
  570. sizeof(USER_INFO_0 ), 0);
  571. (VOID) NetApiBufferFree( UserEnum );
  572. UNREFERENCED_PARAMETER( User1Info );
  573. UNREFERENCED_PARAMETER( User2Info );
  574. }
  575. void
  576. validate_enum1(
  577. PUSER_INFO_2 User1Info,
  578. PUSER_INFO_2 User2Info
  579. )
  580. {
  581. NET_API_STATUS err;
  582. USER_INFO_1 *u1, *u2;
  583. PUSER_INFO_1 UserEnum;
  584. //
  585. // check enum level 1
  586. //
  587. if (err = NetUserEnum(NULL,
  588. 1,
  589. ENUM_FILTER,
  590. (LPBYTE *)& UserEnum,
  591. (DWORD)0xffffffff,
  592. &nread,
  593. &total,
  594. NULL)) {
  595. error_exit(FAIL, "NetUserEnum(1) validate_enum1", NULL );
  596. return;
  597. }
  598. if ( find_ptr( (LPBYTE)UserEnum, (LPBYTE * ) & u1, (LPBYTE * ) & u2,
  599. sizeof(USER_INFO_1 ), 1) ) {
  600. compare_level1(u1, (USER_INFO_1 * ) User1Info, L"Enum level 1");
  601. compare_level1(u2, (USER_INFO_1 * ) User2Info, L"Enum level 1");
  602. }
  603. (VOID) NetApiBufferFree( UserEnum );
  604. }
  605. void
  606. validate_enum2(
  607. PUSER_INFO_2 User1Info,
  608. PUSER_INFO_2 User2Info
  609. )
  610. {
  611. NET_API_STATUS err;
  612. USER_INFO_2 *u1, *u2;
  613. PUSER_INFO_2 UserEnum;
  614. //
  615. // check enum level 2
  616. //
  617. if (err = NetUserEnum(NULL,
  618. 2,
  619. ENUM_FILTER,
  620. (LPBYTE *)&UserEnum,
  621. (DWORD)0xFFFFFFFF,
  622. &nread,
  623. &total,
  624. NULL)) {
  625. error_exit(FAIL, "NetUserEnum(2) validate_enum2", NULL);
  626. return;
  627. }
  628. if ( find_ptr( (LPBYTE)UserEnum, (LPBYTE * ) & u1, (LPBYTE * ) & u2,
  629. sizeof(USER_INFO_2 ), 2) ) {
  630. compare_level1((USER_INFO_1 * ) u1,
  631. (USER_INFO_1 * ) User1Info, L"Enum level 2");
  632. compare_level1((USER_INFO_1 * ) u2,
  633. (USER_INFO_1 * ) User2Info, L"Enum level 2");
  634. compare_level2(u1, User1Info, L"Enum level 2");
  635. compare_level2(u2, User2Info, L"Enum level 2");
  636. }
  637. (VOID) NetApiBufferFree( UserEnum );
  638. }
  639. void
  640. validate_enum3(
  641. PUSER_INFO_3 User1Info,
  642. PUSER_INFO_3 User2Info
  643. )
  644. {
  645. NET_API_STATUS err;
  646. USER_INFO_3 *u1, *u2;
  647. PUSER_INFO_3 UserEnum;
  648. //
  649. // check enum level 3
  650. //
  651. if (err = NetUserEnum(NULL, 3, ENUM_FILTER, (LPBYTE *)&UserEnum, (DWORD)0xFFFFFFFF, &nread, &total, NULL)) {
  652. error_exit(FAIL, "NetUserEnum(3) validate_enum3", NULL);
  653. return;
  654. }
  655. if ( find_ptr( (LPBYTE)UserEnum, (LPBYTE * ) & u1, (LPBYTE * ) & u2,
  656. sizeof(USER_INFO_3 ), 3) ) {
  657. compare_level1((USER_INFO_1 * ) u1,
  658. (USER_INFO_1 * ) User1Info, L"Enum level 3");
  659. compare_level1((USER_INFO_1 * ) u2,
  660. (USER_INFO_1 * ) User2Info, L"Enum level 3");
  661. compare_level2((USER_INFO_2 *)u1,
  662. (USER_INFO_2 *)User1Info, L"Enum level 3");
  663. compare_level2((USER_INFO_2 *)u2,
  664. (USER_INFO_2 *) User2Info, L"Enum level 3");
  665. compare_level3(u1, User1Info, L"Enum level 3");
  666. compare_level3(u2, User2Info, L"Enum level 3");
  667. }
  668. (VOID) NetApiBufferFree( UserEnum );
  669. }
  670. void
  671. enum_compare10(ep, gp)
  672. USER_INFO_10 *ep;
  673. USER_INFO_2 *gp;
  674. {
  675. CompareString( ep->usri10_usr_comment,
  676. gp->usri2_usr_comment,
  677. "NetUserEnum(10) usr_comment",
  678. NULL);
  679. CompareString( ep->usri10_full_name,
  680. gp->usri2_full_name,
  681. "NetUserEnum(10) full_name",
  682. NULL);
  683. }
  684. void
  685. validate_enum10(
  686. PUSER_INFO_2 User1Info,
  687. PUSER_INFO_2 User2Info
  688. )
  689. {
  690. NET_API_STATUS err;
  691. USER_INFO_10 *u1, *u2;
  692. PUSER_INFO_10 UserEnum;
  693. //
  694. // check enum level 10
  695. //
  696. if (err = NetUserEnum(NULL, 10, ENUM_FILTER, (LPBYTE *)&UserEnum, (DWORD)0xFFFFFFFF, &nread, &total, NULL)) {
  697. error_exit(FAIL, "NetUserEnum(10) validate_enum10", NULL);
  698. return;
  699. }
  700. if ( find_ptr((LPBYTE)UserEnum, (LPBYTE * ) & u1, (LPBYTE * ) & u2,
  701. sizeof(USER_INFO_10 ), 10) ) {
  702. enum_compare10(u1, User1Info);
  703. enum_compare10(u2, User2Info);
  704. }
  705. (VOID) NetApiBufferFree( UserEnum );
  706. }
  707. void
  708. enum_compare11(ep, gp)
  709. USER_INFO_11 *ep;
  710. USER_INFO_2 *gp;
  711. {
  712. if (ep->usri11_priv != gp->usri2_priv) {
  713. error_exit(FAIL, "NetUserEnum(11) priv mismatch enum", NULL);
  714. }
  715. if (ep->usri11_password_age == 0) {
  716. error_exit(FAIL, "NetUserEnum(11) password age is suspiciously zero",
  717. NULL);
  718. }
  719. if (ep->usri11_password_age < gp->usri2_password_age) {
  720. printf( "Curr: %lx Prev: %lx\n",
  721. ep->usri11_password_age, gp->usri2_password_age);
  722. error_exit(FAIL, "NetUserEnum(11) password age mismatch enum", NULL);
  723. }
  724. CompareString( ep->usri11_home_dir,
  725. gp->usri2_home_dir,
  726. "NetUserEnum(11) home_dir",
  727. NULL);
  728. CompareString( ep->usri11_parms,
  729. gp->usri2_parms,
  730. "NetUserEnum(11) parms",
  731. NULL);
  732. CompareString( ep->usri11_usr_comment,
  733. gp->usri2_usr_comment,
  734. "NetUserEnum(11) usr_comment",
  735. NULL);
  736. CompareString( ep->usri11_full_name,
  737. gp->usri2_full_name,
  738. "NetUserEnum(11) full_name",
  739. NULL);
  740. }
  741. void
  742. validate_enum11(
  743. PUSER_INFO_2 User1Info,
  744. PUSER_INFO_2 User2Info
  745. )
  746. {
  747. USER_INFO_11 *u1, *u2;
  748. PUSER_INFO_11 UserEnum;
  749. //
  750. // check enum level 11
  751. //
  752. if (err = NetUserEnum(NULL, 11, ENUM_FILTER, (LPBYTE *)&UserEnum, 0xFFFFFFFF, &nread, &total, NULL)) {
  753. error_exit(FAIL, "NetUserEnum(11) validate_enum11", NULL);
  754. return;
  755. }
  756. if ( find_ptr((LPBYTE)UserEnum, (LPBYTE * ) & u1, (LPBYTE * ) & u2,
  757. sizeof(USER_INFO_11 ), 11) ) {
  758. enum_compare11(u1, User1Info);
  759. enum_compare11(u2, User2Info);
  760. }
  761. (VOID) NetApiBufferFree( UserEnum );
  762. }
  763. void
  764. enum_compare20(ep, gp)
  765. USER_INFO_20 *ep;
  766. USER_INFO_3 *gp;
  767. {
  768. CompareString( ep->usri20_full_name,
  769. gp->usri3_full_name,
  770. "NetUserEnum(20) full_name",
  771. NULL);
  772. }
  773. void
  774. validate_enum20(
  775. PUSER_INFO_3 User1Info,
  776. PUSER_INFO_3 User2Info
  777. )
  778. {
  779. USER_INFO_20 *u1, *u2;
  780. PUSER_INFO_20 UserEnum;
  781. //
  782. // check enum level 20
  783. //
  784. if (err = NetUserEnum(NULL, 20, ENUM_FILTER, (LPBYTE *)&UserEnum, 0xFFFFFFFF, &nread, &total, NULL)) {
  785. error_exit(FAIL, "NetUserEnum(20) validate_enum20", NULL);
  786. return;
  787. }
  788. if ( find_ptr((LPBYTE)UserEnum, (LPBYTE * ) & u1, (LPBYTE * ) & u2,
  789. sizeof(USER_INFO_20 ), 20) ) {
  790. enum_compare20(u1, User1Info);
  791. enum_compare20(u2, User2Info);
  792. }
  793. (VOID) NetApiBufferFree( UserEnum );
  794. }
  795. void
  796. validate_enum()
  797. {
  798. NET_API_STATUS err;
  799. PUSER_INFO_3 User1Info;
  800. PUSER_INFO_3 User2Info;
  801. if (err = NetUserGetInfo(server, USER1, 3, (LPBYTE *)&User1Info)) {
  802. error_exit(FAIL, "NetUserGetInfo(3) USER1 validate_enum", USER1);
  803. exit(1);
  804. }
  805. if (err = NetUserGetInfo(server, USER2, 3, (LPBYTE *)&User2Info)) {
  806. error_exit(FAIL, "NetUserGetInfo(3) USER2 validate_enum", USER2);
  807. exit(1);
  808. }
  809. //
  810. // check enum level X
  811. //
  812. validate_enum0( (PUSER_INFO_2) User1Info, (PUSER_INFO_2) User2Info );
  813. validate_enum1( (PUSER_INFO_2) User1Info, (PUSER_INFO_2) User2Info );
  814. validate_enum2( (PUSER_INFO_2) User1Info, (PUSER_INFO_2) User2Info );
  815. validate_enum3( (PUSER_INFO_3) User1Info, (PUSER_INFO_3) User2Info );
  816. validate_enum10( (PUSER_INFO_2) User1Info, (PUSER_INFO_2) User2Info );
  817. validate_enum11( (PUSER_INFO_2) User1Info, (PUSER_INFO_2) User2Info );
  818. validate_enum20( (PUSER_INFO_3) User1Info, (PUSER_INFO_3) User2Info );
  819. (VOID) NetApiBufferFree( User1Info );
  820. (VOID) NetApiBufferFree( User2Info );
  821. }
  822. void __cdecl
  823. main(argc, argv)
  824. int argc;
  825. char **argv;
  826. {
  827. WCHAR * fred = L"fred";
  828. USER_INFO_1 ui1;
  829. PUSER_INFO_1 uo1p;
  830. USER_INFO_2 ui2;
  831. PUSER_INFO_2 uo2p;
  832. USER_INFO_3 ui3;
  833. PUSER_INFO_3 uo3p;
  834. testname = "UASTEST1";
  835. if (argv[1] != NULL)
  836. server = NetpLogonOemToUnicode(argv[1]);
  837. if (argc != 1)
  838. exit_flag = 1;
  839. #ifdef UASP_LIBRARY
  840. printf( "Calling UaspInitialize\n");
  841. if (err = UaspInitialize()) {
  842. error_exit(FAIL, "UaspInitiailize failed", NULL );
  843. }
  844. #endif // UASP_LIBRARY
  845. //
  846. // Delete user in add
  847. //
  848. error_exit(ACTION, "Clean up SAM database by deleting user", USER1 );
  849. if (err = NetUserDel(server, USER1)) {
  850. if (err != NERR_UserNotFound)
  851. error_exit(FAIL, "First cleanup user delete wrong", USER1);
  852. err = 0;
  853. }
  854. //
  855. // Delete user in add
  856. //
  857. error_exit(ACTION, "Clean up SAM database by deleting user", USER2 );
  858. if (err = NetUserDel(server, USER2)) {
  859. if (err != NERR_UserNotFound)
  860. error_exit(FAIL, "Second cleanup user delete wrong", USER2);
  861. err = 0;
  862. }
  863. //
  864. // Add a user using level 1
  865. //
  866. error_exit(ACTION, "Try NetUserAdd (level 1)", USER1 );
  867. set_level1(&ui1, USER1);
  868. if (err = NetUserAdd(server, 1, (LPBYTE) &ui1, NULL )) {
  869. exit_flag = 1;
  870. error_exit(FAIL, "NetUserAdd failed", USER1);
  871. } else
  872. error_exit(PASS, "NetUserAdd (level 1) successful", USER1);
  873. //
  874. // GetInfo on user who is not there
  875. //
  876. error_exit(ACTION,"Try NetUserGetInfo on non-existent user (level 1)",NULL);
  877. if (err = NetUserGetInfo(server, L"NotThere", 1, (LPBYTE *) &uo1p)) {
  878. if (err != NERR_UserNotFound)
  879. error_exit(FAIL, "NetUserGetInfo on NOTTHERE wrong", NULL);
  880. else
  881. error_exit(PASS, "GetInfo on Nonexistent User not found", NULL);
  882. err = 0;
  883. } else {
  884. error_exit(FAIL, "NetUserGetInfo succeeded on NOTTHERE", NULL);
  885. (VOID) NetApiBufferFree( uo1p );
  886. }
  887. //
  888. // GetInfo on user using level 1
  889. //
  890. error_exit(ACTION, "Try NetUserGetInfo (level 1) on created user", USER1 );
  891. if (err = NetUserGetInfo(server, USER1, 1, (LPBYTE *) &uo1p))
  892. error_exit(FAIL, "NetUserGetInfo(1) failed", USER1);
  893. else {
  894. error_exit(PASS, "NetUserGetInfo(1) successful", USER1);
  895. compare_level1(uo1p, &ui1, L"Test add level 1");
  896. (VOID) NetApiBufferFree( uo1p );
  897. }
  898. //
  899. // GetInfo on user using level 2
  900. //
  901. error_exit(ACTION, "Try NetUserGetInfo (level 2) on created user", USER1 );
  902. if (err = NetUserGetInfo(server, USER1, 2, (LPBYTE *) &uo2p))
  903. error_exit(FAIL, "NetUserGetInfo(2) failed", USER1);
  904. else {
  905. error_exit(PASS, "NetUserGetInfo(2) successful", USER1);
  906. //
  907. // Validate defaults
  908. //
  909. error_exit(ACTION, "Validate Defaults set at level 1 NetUserAdd", USER1);
  910. CompareString( uo2p->usri2_full_name,
  911. uo2p->usri2_name,
  912. "NetUserGetInfo(2) full_name default",
  913. USER1);
  914. CompareString( uo2p->usri2_usr_comment,
  915. L"",
  916. "NetUserGetInfo(2) usr_comment default",
  917. USER1);
  918. CompareString( uo2p->usri2_workstations,
  919. L"",
  920. "NetUserGetInfo(2) workstations default",
  921. USER1);
  922. if (uo2p->usri2_acct_expires != 0xFFFFFFFF)
  923. error_exit(FAIL, "default account expires is not ALWAYS", USER1);
  924. else
  925. error_exit(PASS, "default account expires is ALWAYS", USER1);
  926. if (uo2p->usri2_max_storage != 0xFFFFFFFF)
  927. error_exit(FAIL, "default max storage is not MAX_ALLOWED", USER1);
  928. else
  929. error_exit(PASS, "default max storage is MAX_ALLOWED", USER1);
  930. if (memcmp(uo2p->usri2_logon_hours, default_logon_hours, 21)) {
  931. printf( " Units_per_week: %ld\n", uo2p->usri2_units_per_week );
  932. printf( " Logon Hours ptr: %lx\n", uo2p->usri2_logon_hours);
  933. error_exit(FAIL, "default logon hours is wrong", USER1);
  934. } else
  935. error_exit(PASS, "default logon hours is correct", USER1);
  936. //
  937. // Validate level 1 results
  938. //
  939. compare_level1((USER_INFO_1 * ) uo2p,
  940. &ui1, L"Test of Level2 GetInfo");
  941. (VOID) NetApiBufferFree( uo2p );
  942. }
  943. //
  944. // GetInfo on user using level 3
  945. //
  946. error_exit(ACTION, "Try NetUserGetInfo (level 3) on created user", USER1 );
  947. if (err = NetUserGetInfo(server, USER1, 3, (LPBYTE *) &uo3p))
  948. error_exit(FAIL, "NetUserGetInfo(3) failed", USER1);
  949. else {
  950. error_exit(PASS, "NetUserGetInfo(3) successful", USER1);
  951. //
  952. // Validate defaults
  953. //
  954. error_exit(ACTION, "Validate Defaults set at level 1 NetUserAdd",
  955. USER1);
  956. CompareString( uo3p->usri3_profile,
  957. L"",
  958. "NetUserGetInfo(3) profile default",
  959. USER1);
  960. CompareString( uo3p->usri3_home_dir_drive,
  961. L"",
  962. "NetUserGetInfo(3) home_dir_drive default",
  963. USER1);
  964. }
  965. //
  966. // Delete user not there
  967. //
  968. error_exit(ACTION, "Try NetUserDel on non-existent user", USER1 );
  969. if (err = NetUserDel(server, NOTTHERE)) {
  970. if (err != NERR_UserNotFound)
  971. error_exit(FAIL, "NetUserDel of NOTTHERE failed", NULL);
  972. else
  973. error_exit(PASS, "NetUserDel of NOTTHERE not there", NULL);
  974. err = 0;
  975. } else
  976. error_exit(FAIL, "NetUserDel of NOTTHERE succeeded when should fail", NULL);
  977. //
  978. // Delete user in add
  979. //
  980. error_exit(ACTION, "Try NetUserDel on created user", USER1 );
  981. if (err = NetUserDel(server, USER1))
  982. error_exit(FAIL, "NetUserDel failed", USER1);
  983. else
  984. error_exit(PASS, "NetUserDel successful", USER1);
  985. //
  986. // Try again to Delete user in add
  987. //
  988. error_exit(ACTION, "Try NetUserDel again on newly deleted user", USER1 );
  989. if (err = NetUserDel(server, USER1)) {
  990. if (err != NERR_UserNotFound)
  991. error_exit(FAIL, "NetUserDel failed wrong", USER1);
  992. else
  993. error_exit(PASS, "NetUserDel of Deleted User, not there", USER1);
  994. err = 0;
  995. } else
  996. error_exit(PASS, "NetUserDel succeeded when already deleted", USER1);
  997. //
  998. // GetInfo on deleted user
  999. //
  1000. error_exit(ACTION, "Try NetUserGetInfo on newly deleted user", USER1 );
  1001. if (err = NetUserGetInfo(server, USER1, 2, (LPBYTE *) &uo2p)) {
  1002. if (err != NERR_UserNotFound)
  1003. error_exit(FAIL, "NetUserGetInfo(2) on deleted user", USER1);
  1004. else
  1005. error_exit(PASS, "GetInfo(2) on deleted user not there", USER1);
  1006. } else {
  1007. error_exit(FAIL, "NetUserGetInfo(1) of deleted user succeeded", USER1);
  1008. (VOID) NetApiBufferFree( uo2p );
  1009. }
  1010. //
  1011. // Add a user using level 2
  1012. //
  1013. error_exit(ACTION, "Try NetUserAdd (level 2)", USER1 );
  1014. set_level1((USER_INFO_1 * ) &ui2, USER1);
  1015. set_level2(&ui2);
  1016. if (err = NetUserAdd(server, 2, (LPBYTE) &ui2, NULL ))
  1017. error_exit(FAIL, "NetUserAdd (level 2) failed", USER1);
  1018. else
  1019. error_exit(PASS, "NetUserAdd (level 2) successful", USER1);
  1020. //
  1021. // Verify all data
  1022. //
  1023. error_exit(ACTION, "Try NetUserGetInfo (level 2)", USER1 );
  1024. if (err = NetUserGetInfo(server, USER1, 2, (LPBYTE *) &uo2p)) {
  1025. error_exit(FAIL, "NetUserGetInfo(2) failed", USER1);
  1026. } else {
  1027. compare_level1(
  1028. (USER_INFO_1 * ) uo2p,
  1029. (USER_INFO_1 * ) &ui2,
  1030. L"Add user level2");
  1031. compare_level2(uo2p, &ui2, L"Add user level2");
  1032. (VOID) NetApiBufferFree( uo2p );
  1033. }
  1034. //
  1035. // Delete user in add
  1036. //
  1037. error_exit(ACTION, "Try NetUserDel on created user", USER1 );
  1038. if (err = NetUserDel(server, USER1))
  1039. error_exit(FAIL, "NetUserDel failed", USER1);
  1040. else
  1041. error_exit(PASS, "NetUserDel successful", USER1);
  1042. //
  1043. // Add a user using level 3
  1044. //
  1045. error_exit(ACTION, "Try NetUserAdd (level 3)", USER1 );
  1046. set_level1((USER_INFO_1 * ) &ui3, USER1);
  1047. set_level2((USER_INFO_2 * ) &ui3);
  1048. set_level3(&ui3);
  1049. if (err = NetUserAdd(server, 3, (LPBYTE) &ui3, NULL ))
  1050. error_exit(FAIL, "NetUserAdd (level 3) failed", USER1);
  1051. else
  1052. error_exit(PASS, "NetUserAdd (level 3) successful", USER1);
  1053. //
  1054. // Verify all data
  1055. //
  1056. error_exit(ACTION, "Try NetUserGetInfo (level 3)", USER1 );
  1057. if (err = NetUserGetInfo(server, USER1, 3, (LPBYTE *) &uo3p)) {
  1058. error_exit(FAIL, "NetUserGetInfo(3) failed", USER1);
  1059. } else {
  1060. compare_level1(
  1061. (USER_INFO_1 * ) uo3p,
  1062. (USER_INFO_1 * ) &ui3,
  1063. L"Add user level3");
  1064. compare_level2(
  1065. (USER_INFO_2 *) uo3p,
  1066. (USER_INFO_2 *) &ui3,
  1067. L"Add user level3");
  1068. compare_level3(uo3p, &ui3, L"Add user level3");
  1069. (VOID) NetApiBufferFree( uo3p );
  1070. }
  1071. //
  1072. // SetInfo on user not there
  1073. //
  1074. error_exit(ACTION, "Try NetUserSetInfo on non-existent user", NOTTHERE );
  1075. set_level12((USER_INFO_1 * ) &ui2);
  1076. set_level22(&ui2);
  1077. if (err = NetUserSetInfo(server, NOTTHERE, 2, (LPBYTE)&ui2, NULL )) {
  1078. if (err != NERR_UserNotFound)
  1079. error_exit(FAIL, "SetInfo of NOTTHERE failed wrong", NULL);
  1080. else
  1081. error_exit(PASS, "SetInfo of NOTTHERE User, not there", NULL);
  1082. err = 0;
  1083. } else
  1084. error_exit(FAIL, "SetInfo of NOTTHERE succeeded: should've failed", NULL);
  1085. //
  1086. // SetInfo on level 2 fields
  1087. // This call will succeed only if password restrictions are
  1088. // satisfied or password supplied is Null_Password indicating
  1089. // no password change.
  1090. //
  1091. error_exit(ACTION, "Try NetUserSetInfo on created user", USER1 );
  1092. if (err = NetUserSetInfo(server, USER1, 2, (LPBYTE)&ui2, NULL)) {
  1093. error_exit(FAIL, "SetInfo (level 2, parmnum 0) failed", USER1);
  1094. } else {
  1095. error_exit(PASS, "SetInfo (level 2, parmnum 0) successful", USER1);
  1096. //
  1097. // Verify setinfo
  1098. //
  1099. if (err = NetUserGetInfo(server, USER1, 2, (LPBYTE *) &uo2p)) {
  1100. error_exit(FAIL, "GetInfo(1) to verify SetInfo failed", USER1);
  1101. } else {
  1102. error_exit(PASS, "GetInfo(1) to verify SetInfo successful", USER1);
  1103. compare_level1(
  1104. (USER_INFO_1 * ) uo2p,
  1105. (USER_INFO_1 * ) &ui2,
  1106. L"Verify set info level2 fields");
  1107. compare_level2(uo2p, &ui2, L"Verify set info level2 fields");
  1108. (VOID) NetApiBufferFree( uo2p );
  1109. }
  1110. }
  1111. //
  1112. // test setinfo level 2 parmnums
  1113. //
  1114. test_setinfo_l2_parmnum();
  1115. //
  1116. // test add of duplicate record
  1117. //
  1118. set_level1((USER_INFO_1 * ) &ui2, USER1);
  1119. set_level2(&ui2);
  1120. if (err = NetUserAdd(server, 2, (LPBYTE) &ui2, NULL )) {
  1121. if (err == NERR_UserExists) {
  1122. error_exit(PASS, "NetUserAdd of duplicate OK", USER1);
  1123. } else {
  1124. error_exit(FAIL, "NetUserAdd of duplicate failed", USER1);
  1125. }
  1126. err = 0;
  1127. } else
  1128. error_exit(FAIL, "NetUserAdd of duplicate succeeded", USER1);
  1129. //
  1130. // add another user for enum test
  1131. //
  1132. set_level1((USER_INFO_1 * ) &ui2, USER2);
  1133. set_level2(&ui2);
  1134. if (err = NetUserAdd(server, 2, (LPBYTE) &ui2, NULL ))
  1135. error_exit(FAIL, "NetUserAdd (level 2) failed", USER2);
  1136. else
  1137. error_exit(PASS, "NetUserAdd (level 2) successful", USER2);
  1138. //
  1139. // test NetUserGetInfo level 10, 11
  1140. //
  1141. test_getinfo_10_11_20();
  1142. if (server == NULL) {
  1143. #ifdef USER_VAL // ?? UserValidate not implemented
  1144. //
  1145. // check UserValidate
  1146. //
  1147. test_user_val();
  1148. #endif // USER_VAL // ?? UserValidate not implemented
  1149. //
  1150. // check NetUserEnum calls
  1151. //
  1152. validate_enum();
  1153. }
  1154. }