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.

1266 lines
40 KiB

  1. /*
  2. +-------------------------------------------------------------------------+
  3. | User Options Dialog |
  4. +-------------------------------------------------------------------------+
  5. | (c) Copyright 1993-1994 |
  6. | Microsoft Corp. |
  7. | All rights reserved |
  8. | |
  9. | Program : [UserDlg.c] |
  10. | Programmer : Arthur Hanson |
  11. | Original Program Date : [Feb 15, 1993] |
  12. | Last Update : [Jun 16, 1994] |
  13. | |
  14. | Version: 1.00 |
  15. | |
  16. | Description: |
  17. | |
  18. | History: |
  19. | arth Jun 16, 1994 1.00 Original Version. |
  20. | |
  21. +-------------------------------------------------------------------------+
  22. */
  23. #include "globals.h"
  24. #include <limits.h>
  25. #include "nwconv.h"
  26. #include "convapi.h"
  27. #include "userdlg.h"
  28. #include "transfer.h"
  29. #include "ntnetapi.h"
  30. #include "map.h"
  31. #define togmap 1
  32. // Utility Macros for Advanced >> button
  33. #define SetStyleOn(hWnd, Style) SetWindowLong(hWnd, GWL_STYLE, Style | GetWindowLong(hWnd, GWL_STYLE));
  34. #define SetStyleOff(hWnd, Style) SetWindowLong(hWnd, GWL_STYLE, ~Style & GetWindowLong(hWnd, GWL_STYLE));
  35. static CONVERT_OPTIONS cvoDefault;
  36. static CONVERT_OPTIONS *CurrentConvertOptions;
  37. static LPTSTR SourceServ;
  38. static LPTSTR DestServ;
  39. static SOURCE_SERVER_BUFFER *SServ;
  40. static DEST_SERVER_BUFFER *DServ;
  41. static BOOL FPNWChk;
  42. static short TabSelection;
  43. /*+-------------------------------------------------------------------------+
  44. | UserOptionsDefaultsSet()
  45. |
  46. +-------------------------------------------------------------------------+*/
  47. void UserOptionsDefaultsSet(void *cvto) {
  48. memcpy((void *) &cvoDefault, cvto, sizeof(CONVERT_OPTIONS));
  49. } // UserOptionsDefaultsSet
  50. /*+-------------------------------------------------------------------------+
  51. | UserOptionsDefaultsReset()
  52. |
  53. +-------------------------------------------------------------------------+*/
  54. void UserOptionsDefaultsReset() {
  55. memset(&cvoDefault, 0, sizeof(CONVERT_OPTIONS));
  56. cvoDefault.TransferUserInfo = TRUE;
  57. cvoDefault.ForcePasswordChange = TRUE;
  58. cvoDefault.SupervisorDefaults = TRUE;
  59. cvoDefault.AdminAccounts = FALSE;
  60. cvoDefault.NetWareInfo = FALSE;
  61. cvoDefault.GroupNameOption = 1;
  62. } // UserOptionsDefaultsReset
  63. /*+-------------------------------------------------------------------------+
  64. | UserOptionsInit()
  65. |
  66. +-------------------------------------------------------------------------+*/
  67. void UserOptionsInit(void **lpcvto) {
  68. CONVERT_OPTIONS *cvto;
  69. cvto = (CONVERT_OPTIONS *) *lpcvto;
  70. // if we need to allocate space, do so
  71. if (cvto == NULL)
  72. cvto = AllocMemory(sizeof(CONVERT_OPTIONS));
  73. // make sure it was allocated
  74. if (cvto == NULL)
  75. return;
  76. memcpy(cvto, (void *) &cvoDefault, sizeof(CONVERT_OPTIONS));
  77. *lpcvto = (void *) cvto;
  78. } // UserOptionsInit
  79. /*+-------------------------------------------------------------------------+
  80. | UserOptionsLoad()
  81. |
  82. +-------------------------------------------------------------------------+*/
  83. void UserOptionsLoad(HANDLE hFile, void **lpcvto) {
  84. CONVERT_OPTIONS *cvto;
  85. DWORD wrote;
  86. cvto = (CONVERT_OPTIONS *) *lpcvto;
  87. // if we need to allocate space, do so
  88. if (cvto == NULL)
  89. cvto = AllocMemory(sizeof(CONVERT_OPTIONS));
  90. // make sure it was allocated
  91. if (cvto == NULL)
  92. return;
  93. ReadFile(hFile, cvto, sizeof(CONVERT_OPTIONS), &wrote, NULL);
  94. *lpcvto = (void *) cvto;
  95. } // UserOptionsLoad
  96. /*+-------------------------------------------------------------------------+
  97. | UserOptionsSave()
  98. |
  99. +-------------------------------------------------------------------------+*/
  100. void UserOptionsSave(HANDLE hFile, void *pcvto) {
  101. CONVERT_OPTIONS *cvto;
  102. DWORD wrote;
  103. DOMAIN_BUFFER *Trusted;
  104. cvto = (CONVERT_OPTIONS *) pcvto;
  105. // if trusted domain then index the domain list and save off the old
  106. // domain pointer so that we save the index instead.
  107. if (cvto->UseTrustedDomain && (cvto->TrustedDomain != NULL)) {
  108. DomainListIndex();
  109. Trusted = cvto->TrustedDomain;
  110. cvto->TrustedDomain = (DOMAIN_BUFFER *) cvto->TrustedDomain->Index;
  111. } else
  112. cvto->UseTrustedDomain = FALSE;
  113. WriteFile(hFile, pcvto, sizeof(CONVERT_OPTIONS), &wrote, NULL);
  114. // if we replaced the domain pointer, then restore it
  115. if (cvto->UseTrustedDomain)
  116. cvto->TrustedDomain = Trusted;
  117. } // UserOptionsSave
  118. /*+-------------------------------------------------------------------------+
  119. | Passwords_Toggle()
  120. |
  121. +-------------------------------------------------------------------------+*/
  122. void Passwords_Toggle(HWND hDlg, BOOL Toggle) {
  123. HWND hCtrl;
  124. BOOL MainToggle = Toggle;
  125. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  126. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 0)
  127. MainToggle = FALSE;
  128. hCtrl = GetDlgItem(hDlg, IDC_CHKPWFORCE);
  129. ShowWindow(hCtrl, Toggle);
  130. EnableWindow(hCtrl, MainToggle);
  131. #ifdef togmap
  132. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  133. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  134. MainToggle = FALSE;
  135. #endif
  136. hCtrl = GetDlgItem(hDlg, IDC_RADIO1);
  137. ShowWindow(hCtrl, Toggle);
  138. EnableWindow(hCtrl, MainToggle);
  139. hCtrl = GetDlgItem(hDlg, IDC_RADIO2);
  140. ShowWindow(hCtrl, Toggle);
  141. EnableWindow(hCtrl, MainToggle);
  142. hCtrl = GetDlgItem(hDlg, IDC_RADIO3);
  143. ShowWindow(hCtrl, Toggle);
  144. EnableWindow(hCtrl, MainToggle);
  145. hCtrl = GetDlgItem(hDlg, IDC_PWCONST);
  146. ShowWindow(hCtrl, Toggle);
  147. EnableWindow(hCtrl, MainToggle);
  148. } // Passwords_Toggle
  149. /*+-------------------------------------------------------------------------+
  150. | DuplicateUsers_Toggle()
  151. |
  152. +-------------------------------------------------------------------------+*/
  153. void DuplicateUsers_Toggle(HWND hDlg, BOOL Toggle) {
  154. HWND hCtrl;
  155. BOOL MainToggle = Toggle;
  156. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  157. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 0)
  158. MainToggle = FALSE;
  159. #ifdef togmap
  160. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  161. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  162. MainToggle = FALSE;
  163. #endif
  164. hCtrl = GetDlgItem(hDlg, IDC_STATDUP);
  165. ShowWindow(hCtrl, Toggle);
  166. hCtrl = GetDlgItem(hDlg, IDC_RADIO4);
  167. ShowWindow(hCtrl, Toggle);
  168. EnableWindow(hCtrl, MainToggle);
  169. hCtrl = GetDlgItem(hDlg, IDC_RADIO5);
  170. ShowWindow(hCtrl, Toggle);
  171. EnableWindow(hCtrl, MainToggle);
  172. hCtrl = GetDlgItem(hDlg, IDC_RADIO6);
  173. ShowWindow(hCtrl, Toggle);
  174. EnableWindow(hCtrl, MainToggle);
  175. hCtrl = GetDlgItem(hDlg, IDC_RADIO7);
  176. ShowWindow(hCtrl, Toggle);
  177. EnableWindow(hCtrl, MainToggle);
  178. hCtrl = GetDlgItem(hDlg, IDC_USERCONST);
  179. ShowWindow(hCtrl, Toggle);
  180. EnableWindow(hCtrl, MainToggle);
  181. } // DuplicateUsers_Toggle
  182. /*+-------------------------------------------------------------------------+
  183. | DuplicateGroups_Toggle()
  184. |
  185. +-------------------------------------------------------------------------+*/
  186. void DuplicateGroups_Toggle(HWND hDlg, BOOL Toggle) {
  187. HWND hCtrl;
  188. BOOL MainToggle = Toggle;
  189. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  190. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 0)
  191. MainToggle = FALSE;
  192. #ifdef togmap
  193. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  194. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  195. MainToggle = FALSE;
  196. #endif
  197. hCtrl = GetDlgItem(hDlg, IDC_STATDUP);
  198. ShowWindow(hCtrl, Toggle);
  199. hCtrl = GetDlgItem(hDlg, IDC_RADIO8);
  200. ShowWindow(hCtrl, Toggle);
  201. EnableWindow(hCtrl, MainToggle);
  202. hCtrl = GetDlgItem(hDlg, IDC_RADIO9);
  203. ShowWindow(hCtrl, Toggle);
  204. EnableWindow(hCtrl, MainToggle);
  205. hCtrl = GetDlgItem(hDlg, IDC_RADIO10);
  206. ShowWindow(hCtrl, Toggle);
  207. EnableWindow(hCtrl, MainToggle);
  208. hCtrl = GetDlgItem(hDlg, IDC_GROUPCONST);
  209. ShowWindow(hCtrl, Toggle);
  210. EnableWindow(hCtrl, MainToggle);
  211. } // DuplicateGroups_Toggle
  212. /*+-------------------------------------------------------------------------+
  213. | Defaults_Toggle()
  214. |
  215. +-------------------------------------------------------------------------+*/
  216. void Defaults_Toggle(HWND hDlg, BOOL Toggle) {
  217. HWND hCtrl;
  218. BOOL MainToggle = Toggle;
  219. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  220. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 0)
  221. MainToggle = FALSE;
  222. hCtrl = GetDlgItem(hDlg, IDC_CHKSUPER);
  223. EnableWindow(hCtrl, MainToggle);
  224. ShowWindow(hCtrl, Toggle);
  225. hCtrl = GetDlgItem(hDlg, IDC_CHKADMIN);
  226. EnableWindow(hCtrl, MainToggle);
  227. ShowWindow(hCtrl, Toggle);
  228. hCtrl = GetDlgItem(hDlg, IDC_CHKFPNW);
  229. if (FPNWChk)
  230. EnableWindow(hCtrl, MainToggle);
  231. else
  232. EnableWindow(hCtrl, FALSE);
  233. ShowWindow(hCtrl, Toggle);
  234. } // Defaults_Toggle
  235. /*+-------------------------------------------------------------------------+
  236. | Mapping_Toggle()
  237. |
  238. +-------------------------------------------------------------------------+*/
  239. void Mapping_Toggle(HWND hDlg, BOOL Toggle) {
  240. HWND hCtrl;
  241. // These two are the reverse of the others...
  242. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  243. EnableWindow(hCtrl, !Toggle);
  244. hCtrl = GetDlgItem(hDlg, IDC_BTNMAPPINGFILE);
  245. EnableWindow(hCtrl, !Toggle);
  246. hCtrl = GetDlgItem(hDlg, IDC_BTNMAPPINGEDIT);
  247. EnableWindow(hCtrl, !Toggle);
  248. #ifdef togmap
  249. hCtrl = GetDlgItem(hDlg, IDC_RADIO1);
  250. EnableWindow(hCtrl, Toggle);
  251. hCtrl = GetDlgItem(hDlg, IDC_RADIO2);
  252. EnableWindow(hCtrl, Toggle);
  253. hCtrl = GetDlgItem(hDlg, IDC_RADIO3);
  254. EnableWindow(hCtrl, Toggle);
  255. hCtrl = GetDlgItem(hDlg, IDC_RADIO4);
  256. EnableWindow(hCtrl, Toggle);
  257. hCtrl = GetDlgItem(hDlg, IDC_RADIO5);
  258. EnableWindow(hCtrl, Toggle);
  259. hCtrl = GetDlgItem(hDlg, IDC_RADIO6);
  260. EnableWindow(hCtrl, Toggle);
  261. hCtrl = GetDlgItem(hDlg, IDC_RADIO7);
  262. EnableWindow(hCtrl, Toggle);
  263. hCtrl = GetDlgItem(hDlg, IDC_RADIO8);
  264. EnableWindow(hCtrl, Toggle);
  265. hCtrl = GetDlgItem(hDlg, IDC_RADIO9);
  266. EnableWindow(hCtrl, Toggle);
  267. hCtrl = GetDlgItem(hDlg, IDC_RADIO10);
  268. EnableWindow(hCtrl, Toggle);
  269. hCtrl = GetDlgItem(hDlg, IDC_CHKPWFORCE);
  270. EnableWindow(hCtrl, Toggle);
  271. hCtrl = GetDlgItem(hDlg, IDC_PWCONST);
  272. EnableWindow(hCtrl, Toggle);
  273. hCtrl = GetDlgItem(hDlg, IDC_USERCONST);
  274. EnableWindow(hCtrl, Toggle);
  275. hCtrl = GetDlgItem(hDlg, IDC_GROUPCONST);
  276. EnableWindow(hCtrl, Toggle);
  277. #endif
  278. } // Mapping_Toggle
  279. /*+-------------------------------------------------------------------------+
  280. | UserDialogToggle()
  281. |
  282. +-------------------------------------------------------------------------+*/
  283. void UserDialogToggle(HWND hDlg, BOOL Toggle) {
  284. HWND hCtrl;
  285. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  286. EnableWindow(hCtrl, Toggle);
  287. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  288. Mapping_Toggle(hDlg, FALSE);
  289. else
  290. Mapping_Toggle(hDlg, Toggle);
  291. if (!Toggle) {
  292. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  293. EnableWindow(hCtrl, Toggle);
  294. hCtrl = GetDlgItem(hDlg, IDC_BTNMAPPINGFILE);
  295. EnableWindow(hCtrl, Toggle);
  296. hCtrl = GetDlgItem(hDlg, IDC_BTNMAPPINGEDIT);
  297. EnableWindow(hCtrl, Toggle);
  298. }
  299. hCtrl = GetDlgItem(hDlg, IDC_CHKSUPER);
  300. EnableWindow(hCtrl, Toggle);
  301. hCtrl = GetDlgItem(hDlg, IDC_CHKADMIN);
  302. EnableWindow(hCtrl, Toggle);
  303. hCtrl = GetDlgItem(hDlg, IDC_CHKFPNW);
  304. if (FPNWChk)
  305. EnableWindow(hCtrl, Toggle);
  306. else
  307. EnableWindow(hCtrl, FALSE);
  308. // Check the Advanced Trusted domain check and toggle controls appropriatly
  309. hCtrl = GetDlgItem(hDlg, IDC_CHKTRUSTED);
  310. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1) {
  311. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  312. EnableWindow(hCtrl, Toggle);
  313. } else {
  314. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  315. EnableWindow(hCtrl, FALSE);
  316. }
  317. // Now toggle the checkbox itself
  318. hCtrl = GetDlgItem(hDlg, IDC_CHKTRUSTED);
  319. EnableWindow(hCtrl, Toggle);
  320. } // UserDialogToggle
  321. /*+-------------------------------------------------------------------------+
  322. | UserDialogSave()
  323. |
  324. +-------------------------------------------------------------------------+*/
  325. void UserDialogSave(HWND hDlg) {
  326. HWND hCtrl;
  327. DWORD_PTR dwIndex;
  328. TCHAR TrustedDomain[MAX_PATH + 1];
  329. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  330. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  331. CurrentConvertOptions->TransferUserInfo = TRUE;
  332. else
  333. CurrentConvertOptions->TransferUserInfo = FALSE;
  334. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  335. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  336. CurrentConvertOptions->UseMappingFile = TRUE;
  337. else
  338. CurrentConvertOptions->UseMappingFile = FALSE;
  339. // Mapping file is handled in Verify
  340. // Password stuff--------------------------------------------------------
  341. hCtrl = GetDlgItem(hDlg, IDC_RADIO1);
  342. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  343. CurrentConvertOptions->PasswordOption = 0;
  344. hCtrl = GetDlgItem(hDlg, IDC_RADIO2);
  345. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  346. CurrentConvertOptions->PasswordOption = 1;
  347. hCtrl = GetDlgItem(hDlg, IDC_RADIO3);
  348. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  349. CurrentConvertOptions->PasswordOption = 2;
  350. hCtrl = GetDlgItem(hDlg, IDC_PWCONST);
  351. * (WORD *)CurrentConvertOptions->PasswordConstant = sizeof(CurrentConvertOptions->PasswordConstant);
  352. SendMessage(hCtrl, EM_GETLINE, 0, (LPARAM) CurrentConvertOptions->PasswordConstant);
  353. hCtrl = GetDlgItem(hDlg, IDC_CHKPWFORCE);
  354. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  355. CurrentConvertOptions->ForcePasswordChange = TRUE;
  356. else
  357. CurrentConvertOptions->ForcePasswordChange = FALSE;
  358. // Username stuff--------------------------------------------------------
  359. hCtrl = GetDlgItem(hDlg, IDC_RADIO4);
  360. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  361. CurrentConvertOptions->UserNameOption = 0;
  362. hCtrl = GetDlgItem(hDlg, IDC_RADIO5);
  363. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  364. CurrentConvertOptions->UserNameOption = 1;
  365. hCtrl = GetDlgItem(hDlg, IDC_RADIO6);
  366. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  367. CurrentConvertOptions->UserNameOption = 2;
  368. hCtrl = GetDlgItem(hDlg, IDC_RADIO7);
  369. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  370. CurrentConvertOptions->UserNameOption = 3;
  371. hCtrl = GetDlgItem(hDlg, IDC_USERCONST);
  372. * (WORD *)CurrentConvertOptions->UserConstant = sizeof(CurrentConvertOptions->UserConstant);
  373. SendMessage(hCtrl, EM_GETLINE, 0, (LPARAM) CurrentConvertOptions->UserConstant);
  374. // Group-name stuff--------------------------------------------------------
  375. hCtrl = GetDlgItem(hDlg, IDC_RADIO8);
  376. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  377. CurrentConvertOptions->GroupNameOption = 0;
  378. hCtrl = GetDlgItem(hDlg, IDC_RADIO9);
  379. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  380. CurrentConvertOptions->GroupNameOption = 1;
  381. hCtrl = GetDlgItem(hDlg, IDC_RADIO10);
  382. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  383. CurrentConvertOptions->GroupNameOption = 2;
  384. hCtrl = GetDlgItem(hDlg, IDC_GROUPCONST);
  385. * (WORD *)CurrentConvertOptions->GroupConstant = sizeof(CurrentConvertOptions->GroupConstant);
  386. SendMessage(hCtrl, EM_GETLINE, 0, (LPARAM) CurrentConvertOptions->GroupConstant);
  387. // Defaults page stuff------------------------------------------------------
  388. hCtrl = GetDlgItem(hDlg, IDC_CHKSUPER);
  389. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  390. CurrentConvertOptions->SupervisorDefaults = TRUE;
  391. else
  392. CurrentConvertOptions->SupervisorDefaults = FALSE;
  393. hCtrl = GetDlgItem(hDlg, IDC_CHKADMIN);
  394. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  395. CurrentConvertOptions->AdminAccounts = TRUE;
  396. else
  397. CurrentConvertOptions->AdminAccounts = FALSE;
  398. if (FPNWChk) {
  399. hCtrl = GetDlgItem(hDlg, IDC_CHKFPNW);
  400. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  401. CurrentConvertOptions->NetWareInfo = TRUE;
  402. else
  403. CurrentConvertOptions->NetWareInfo = FALSE;
  404. } else
  405. CurrentConvertOptions->NetWareInfo = FALSE;
  406. // Advanced >> button stuff-------------------------------------------------
  407. hCtrl = GetDlgItem(hDlg, IDC_CHKTRUSTED);
  408. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1) {
  409. CurrentConvertOptions->UseTrustedDomain = TRUE;
  410. // if there is already a trusted domain selected - clear it out
  411. if (CurrentConvertOptions->TrustedDomain != NULL) {
  412. DomainListDelete(CurrentConvertOptions->TrustedDomain);
  413. CurrentConvertOptions->TrustedDomain = NULL;
  414. }
  415. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  416. dwIndex = SendMessage(hCtrl, CB_GETCURSEL, 0, 0);
  417. if (dwIndex != CB_ERR) {
  418. // Get the domain name and then try to add it to our lists
  419. SendMessage(hCtrl, CB_GETLBTEXT, (WPARAM) dwIndex, (LPARAM) TrustedDomain);
  420. CurrentConvertOptions->TrustedDomain = NTTrustedDomainSet(hDlg, DestServ, TrustedDomain);
  421. }
  422. } else
  423. CurrentConvertOptions->UseTrustedDomain = FALSE;
  424. // Set default values to new selections
  425. UserOptionsDefaultsSet(CurrentConvertOptions);
  426. } // UserDialogSave
  427. /*+-------------------------------------------------------------------------+
  428. | UserDialogVerify()
  429. |
  430. +-------------------------------------------------------------------------+*/
  431. BOOL UserDialogVerify(HWND hDlg) {
  432. HWND hCtrl;
  433. static TCHAR MappingFile[MAX_PATH + 1];
  434. static char FileNameA[MAX_PATH + 1];
  435. static char CmdLine[MAX_PATH + 1 + 12]; // Editor + file
  436. TCHAR drive[MAX_DRIVE + 1];
  437. TCHAR dir[MAX_PATH + 1];
  438. TCHAR fname[MAX_PATH + 1];
  439. TCHAR ext[_MAX_EXT + 1];
  440. HANDLE hFile;
  441. // Check trusted domain...
  442. // Check mapping file
  443. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  444. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1) {
  445. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  446. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1) {
  447. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  448. * (WORD *)MappingFile = sizeof(MappingFile);
  449. SendMessage(hCtrl, EM_GETLINE, 0, (LPARAM) MappingFile);
  450. lsplitpath(MappingFile, drive, dir, fname, ext);
  451. // Make sure a file name is specified
  452. if (lstrlen(fname) == 0) {
  453. MessageBox(hDlg, Lids(IDS_NOREADMAP), Lids(IDS_TXTWARNING), MB_OK | MB_ICONEXCLAMATION);
  454. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  455. SetFocus(hCtrl);
  456. return FALSE;
  457. }
  458. if ((drive[0] == TEXT('\0')) && (dir[0] == TEXT('\0')))
  459. lstrcpy(dir, ProgPath);
  460. if (ext[0] == TEXT('\0'))
  461. lstrcpy(ext, Lids(IDS_S_36));
  462. lmakepath(MappingFile, drive, dir, fname, ext);
  463. lstrcpy(CurrentConvertOptions->MappingFile, MappingFile);
  464. WideCharToMultiByte(CP_ACP, 0, MappingFile, -1, FileNameA, sizeof(FileNameA), NULL, NULL);
  465. hFile = CreateFileA( FileNameA, GENERIC_READ, 0,
  466. NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  467. if (hFile == INVALID_HANDLE_VALUE) {
  468. MessageBox(hDlg, Lids(IDS_NOREADMAP), Lids(IDS_TXTWARNING), MB_OK | MB_ICONEXCLAMATION);
  469. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  470. SetFocus(hCtrl);
  471. return FALSE;
  472. } else
  473. CloseHandle(hFile);
  474. }
  475. } // mapping file
  476. return TRUE;
  477. } // UserDialogVerify
  478. /*+-------------------------------------------------------------------------+
  479. | UserDialogSetup()
  480. |
  481. +-------------------------------------------------------------------------+*/
  482. void UserDialogSetup(HWND hDlg) {
  483. HWND hCtrl;
  484. // Main TransferUserCheckbox
  485. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  486. if (CurrentConvertOptions->TransferUserInfo)
  487. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  488. else
  489. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  490. // Mapping file checkbox
  491. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  492. if (CurrentConvertOptions->UseMappingFile)
  493. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  494. else
  495. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  496. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  497. PostMessage(hCtrl, EM_LIMITTEXT, (WPARAM) MAX_PATH, 0);
  498. SendMessage(hCtrl, WM_SETTEXT, 0, (LPARAM) CurrentConvertOptions->MappingFile);
  499. // Force Password checkbox
  500. hCtrl = GetDlgItem(hDlg, IDC_CHKPWFORCE);
  501. if (CurrentConvertOptions->ForcePasswordChange)
  502. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  503. else
  504. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  505. // Set the text and limit the lengths of the edit fields...
  506. hCtrl = GetDlgItem(hDlg, IDC_PWCONST);
  507. PostMessage(hCtrl, EM_LIMITTEXT, (WPARAM) MAX_PW_LEN, 0);
  508. SendMessage(hCtrl, WM_SETTEXT, 0, (LPARAM) CurrentConvertOptions->PasswordConstant);
  509. hCtrl = GetDlgItem(hDlg, IDC_USERCONST);
  510. PostMessage(hCtrl, EM_LIMITTEXT, (WPARAM) MAX_UCONST_LEN, 0);
  511. SendMessage(hCtrl, WM_SETTEXT, 0, (LPARAM) CurrentConvertOptions->UserConstant);
  512. hCtrl = GetDlgItem(hDlg, IDC_GROUPCONST);
  513. PostMessage(hCtrl, EM_LIMITTEXT, (WPARAM) MAX_UCONST_LEN, 0);
  514. SendMessage(hCtrl, WM_SETTEXT, 0, (LPARAM) CurrentConvertOptions->GroupConstant);
  515. // Now init the radio buttons correctly
  516. CheckRadioButton(hDlg, IDC_RADIO1, IDC_RADIO3, IDC_RADIO1 + CurrentConvertOptions->PasswordOption);
  517. CheckRadioButton(hDlg, IDC_RADIO4, IDC_RADIO7, IDC_RADIO4 + CurrentConvertOptions->UserNameOption);
  518. CheckRadioButton(hDlg, IDC_RADIO8, IDC_RADIO10, IDC_RADIO8 + CurrentConvertOptions->GroupNameOption);
  519. // Do the controls in the defaults section
  520. hCtrl = GetDlgItem(hDlg, IDC_CHKSUPER);
  521. if (CurrentConvertOptions->SupervisorDefaults)
  522. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  523. else
  524. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  525. hCtrl = GetDlgItem(hDlg, IDC_CHKADMIN);
  526. if (CurrentConvertOptions->AdminAccounts)
  527. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  528. else
  529. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  530. if (FPNWChk) {
  531. hCtrl = GetDlgItem(hDlg, IDC_CHKFPNW);
  532. if (CurrentConvertOptions->NetWareInfo)
  533. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  534. else
  535. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  536. } else
  537. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  538. // Now for the Advanced >> area..
  539. hCtrl = GetDlgItem(hDlg, IDC_CHKTRUSTED);
  540. if (CurrentConvertOptions->UseTrustedDomain)
  541. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  542. else
  543. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  544. } // UserDialogSetup
  545. /*+-------------------------------------------------------------------------+
  546. | ShowArea()
  547. |
  548. +-------------------------------------------------------------------------+*/
  549. void ShowArea(BOOL fShowDefAreaOnly, HWND hDlg, HWND hWndDefArea) {
  550. RECT rcDlg, rcDefArea;
  551. TCHAR szDlgDims[25];
  552. char szaDlgDims[25];
  553. HWND hWndChild;
  554. RECT rc;
  555. // Save original width and height of dialog box
  556. GetWindowRect(hDlg, &rcDlg);
  557. // Retrieve coordinates for default area window.
  558. GetWindowRect(hWndDefArea, &rcDefArea);
  559. hWndChild = GetFirstChild(hDlg);
  560. for (; hWndChild != NULL; hWndChild = GetNextSibling(hWndChild)) {
  561. // Calculate rectangle occupied by child window in sreen coordinates
  562. GetWindowRect(hWndChild, &rc);
  563. // Enable/Disable child if its:
  564. // right edge is >= the right edge of hWndDefArea.
  565. // bottom edge is >= the bottom edge of hWndDefArea.
  566. if ((rc.right >= rcDefArea.right) || (rc.bottom >= rcDefArea.bottom))
  567. EnableWindow(hWndChild, !fShowDefAreaOnly);
  568. }
  569. if (fShowDefAreaOnly) {
  570. wsprintf(szDlgDims, TEXT("%05u %05u"), rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top);
  571. SetStyleOff(hWndDefArea, SS_BLACKRECT);
  572. SetStyleOn(hWndDefArea, SS_LEFT);
  573. SetWindowText(hWndDefArea, szDlgDims);
  574. // Resize dialog box to fit only default area.
  575. SetWindowPos(hDlg, NULL, 0, 0, rcDefArea.right - rcDlg.left,
  576. rcDefArea.bottom - rcDlg.top, SWP_NOZORDER | SWP_NOMOVE);
  577. // Make sure that the Default area box is hidden.
  578. ShowWindow(hWndDefArea, SW_HIDE);
  579. } else {
  580. GetWindowText(hWndDefArea, szDlgDims, sizeof(szDlgDims));
  581. WideCharToMultiByte( CP_ACP, 0, szDlgDims, -1, szaDlgDims, sizeof(szDlgDims), NULL, NULL );
  582. // Restore dialog box to its original size.
  583. SetWindowPos(hDlg, NULL, 0, 0, atoi(szaDlgDims), atoi(szaDlgDims + 6),
  584. SWP_NOZORDER | SWP_NOMOVE);
  585. }
  586. } // ShowArea
  587. /*+-------------------------------------------------------------------------+
  588. | UserFileGet()
  589. |
  590. +-------------------------------------------------------------------------+*/
  591. DWORD UserFileGet(HWND hwnd, LPTSTR FilePath) {
  592. OPENFILENAME ofn;
  593. TCHAR szDirName[MAX_PATH + 1];
  594. TCHAR szFile[MAX_PATH + 1], szFileTitle[MAX_PATH + 1];
  595. UINT i, cbString;
  596. TCHAR chReplace;
  597. TCHAR szFilter[256];
  598. BOOL Found = FALSE;
  599. LPTSTR szExt;
  600. szExt = Lids(IDS_S_37);
  601. lstrcpy(szDirName, ProgPath);
  602. lstrcpy(szFile, TEXT(""));
  603. if ((cbString = LoadString(hInst, IDS_USERFILTERSTRING, szFilter, sizeof(szFilter))) == 0) {
  604. // Error occured
  605. return 1L;
  606. }
  607. chReplace = szFilter[cbString - 1]; // Retrieve wild character
  608. for (i = 0; szFilter[i] != TEXT('\0'); i++) {
  609. if (szFilter[i] == chReplace)
  610. szFilter[i] = TEXT('\0');
  611. }
  612. // Set all structure members to zero
  613. memset(&ofn, 0, sizeof(OPENFILENAME));
  614. ofn.lStructSize = sizeof(OPENFILENAME);
  615. ofn.hwndOwner = hwnd;
  616. ofn.lpstrFilter = szFilter;
  617. ofn.nFilterIndex = 1;
  618. ofn.lpstrFile = szFile;
  619. ofn.nMaxFile = sizeof(szFile);
  620. ofn.lpstrFileTitle = szFileTitle;
  621. ofn.nMaxFileTitle = sizeof(szFileTitle);
  622. ofn.lpstrInitialDir = szDirName;
  623. ofn.lpstrDefExt = szExt;
  624. ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
  625. if (GetOpenFileName(&ofn)) {
  626. // Don't really need to open it yet - just copy the data
  627. // If no path then append .
  628. i = 0;
  629. while (!Found && (ofn.lpstrFile[i] != TEXT('\0'))) {
  630. if ((ofn.lpstrFile[i] == TEXT(':')) || (ofn.lpstrFile[i] == TEXT('\\')))
  631. Found = TRUE;
  632. i++;
  633. }
  634. lstrcpy(FilePath, TEXT(""));
  635. if (!Found)
  636. lstrcpy(FilePath, TEXT(".\\"));
  637. lstrcat(FilePath, ofn.lpstrFile);
  638. return 0L;
  639. } else {
  640. // Couldn't open the dang file
  641. return 1L;
  642. }
  643. } // UserFileGet
  644. /*+-------------------------------------------------------------------------+
  645. | DlgUsers_TrustedSetup()
  646. |
  647. +-------------------------------------------------------------------------+*/
  648. void DlgUsers_TrustedSetup(HWND hDlg) {
  649. HWND hCtrl;
  650. ULONG i;
  651. static TRUSTED_DOMAIN_LIST *TList = NULL;
  652. NTTrustedDomainsEnum(DestServ, &TList);
  653. if (TList != NULL) {
  654. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  655. for (i = 0; i < TList->Count; i++)
  656. SendMessage(hCtrl, CB_ADDSTRING, (WPARAM) 0, (LPARAM) TList->Name[i]);
  657. }
  658. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED), FALSE);
  659. ShowArea(FALSE, hDlg, GetDlgItem(hDlg, IDC_DEFAULTBOX));
  660. // Toggle the advanced controls based on the main user toggle
  661. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  662. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1) {
  663. hCtrl = GetDlgItem(hDlg, IDC_CHKTRUSTED);
  664. EnableWindow(hCtrl, TRUE);
  665. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  666. EnableWindow(hCtrl, TRUE);
  667. SetFocus(GetDlgItem(hDlg, IDC_CHKTRUSTED));
  668. } else {
  669. hCtrl = GetDlgItem(hDlg, IDC_CHKTRUSTED);
  670. EnableWindow(hCtrl, FALSE);
  671. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  672. EnableWindow(hCtrl, FALSE);
  673. SetFocus(GetDlgItem(hDlg, IDHELP));
  674. }
  675. if ((TList == NULL) || (TList->Count = 0)) {
  676. EnableWindow(GetDlgItem(hDlg, IDC_CHKTRUSTED), FALSE);
  677. EnableWindow(GetDlgItem(hDlg, IDC_TRUSTED), FALSE);
  678. SetFocus(GetDlgItem(hDlg, IDHELP));
  679. } else {
  680. // Select the trusted domain (or first one if none currently selected)
  681. if (CurrentConvertOptions->TrustedDomain != NULL)
  682. SendMessage(GetDlgItem(hDlg, IDC_TRUSTED), CB_SELECTSTRING, (WPARAM) -1, (LPARAM) CurrentConvertOptions->TrustedDomain->Name);
  683. else
  684. SendMessage(GetDlgItem(hDlg, IDC_TRUSTED), CB_SETCURSEL, 0, 0);
  685. // if the checkbox is set then enable the edit field
  686. if (!CurrentConvertOptions->UseTrustedDomain)
  687. EnableWindow(GetDlgItem(hDlg, IDC_TRUSTED), FALSE);
  688. }
  689. // Free up the list as we don't need it anymore (it is in the combo-box)
  690. if (TList) {
  691. FreeMemory(TList);
  692. TList = NULL;
  693. }
  694. } // DlgUsers_TrustedSetup
  695. /*+-------------------------------------------------------------------------+
  696. | MappingFileEdit()
  697. |
  698. +-------------------------------------------------------------------------+*/
  699. BOOL MappingFileEdit(HWND hDlg) {
  700. HWND hCtrl;
  701. static TCHAR MappingFile[MAX_PATH + 1];
  702. static char FileNameA[MAX_PATH + 1];
  703. static char CmdLine[MAX_PATH + 1 + 12]; // Editor + file
  704. TCHAR drive[MAX_DRIVE + 1];
  705. TCHAR dir[MAX_PATH + 1];
  706. TCHAR fname[MAX_PATH + 1];
  707. TCHAR ext[_MAX_EXT + 1];
  708. HANDLE hFile;
  709. UINT uReturn;
  710. BOOL ret = TRUE;
  711. BOOL Browse = FALSE;
  712. do {
  713. // First check filename
  714. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  715. * (WORD *)MappingFile = sizeof(MappingFile);
  716. SendMessage(hCtrl, EM_GETLINE, 0, (LPARAM) MappingFile);
  717. lsplitpath(MappingFile, drive, dir, fname, ext);
  718. // Make sure a file name is specified
  719. if (Browse || (lstrlen(fname) == 0)) {
  720. // No name was specified, so let the user browse for a file
  721. if (!UserFileGet(hDlg, MappingFile)) {
  722. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  723. SendMessage(hCtrl, WM_SETTEXT, 0, (LPARAM) MappingFile);
  724. SetFocus(hCtrl);
  725. lsplitpath(MappingFile, drive, dir, fname, ext);
  726. } else
  727. return FALSE;
  728. }
  729. Browse = FALSE;
  730. // remake path so it is fully qualified
  731. if ((drive[0] == TEXT('\0')) && (dir[0] == TEXT('\0')))
  732. lstrcpy(dir, ProgPath);
  733. if (ext[0] == TEXT('\0'))
  734. lstrcpy(ext, Lids(IDS_S_36));
  735. lmakepath(MappingFile, drive, dir, fname, ext);
  736. // Now make sure the file exists and is accessible
  737. WideCharToMultiByte(CP_ACP, 0, MappingFile, -1, FileNameA, sizeof(FileNameA), NULL, NULL);
  738. hFile = CreateFileA( FileNameA, GENERIC_READ, 0,
  739. NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  740. if (hFile == INVALID_HANDLE_VALUE) {
  741. // Couldn't open the file, report to user
  742. if (MessageBox(hDlg, Lids(IDS_NOEDITMAP), Lids(IDS_TXTWARNING), MB_YESNO | MB_ICONQUESTION) == IDYES)
  743. Browse = TRUE;
  744. else {
  745. // get out of loop as nothing more to do
  746. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  747. SetFocus(hCtrl);
  748. ret = FALSE;
  749. }
  750. } else {
  751. // Could create a new file so make the mapping file...
  752. CloseHandle(hFile);
  753. CursorHourGlass();
  754. wsprintfA(CmdLine, "Notepad %s", FileNameA);
  755. uReturn = WinExec(CmdLine, SW_SHOW);
  756. CursorNormal();
  757. }
  758. } while (Browse);
  759. // Check mapping file check-box, if it's not check'd then do so
  760. if (ret) {
  761. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  762. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) != 1)
  763. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  764. }
  765. return ret;
  766. } // MappingFileEdit
  767. /*+-------------------------------------------------------------------------+
  768. | DlgUsers()
  769. |
  770. +-------------------------------------------------------------------------+*/
  771. LRESULT CALLBACK DlgUsers(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
  772. HWND hCtrl;
  773. int wmId, wmEvent;
  774. static short UserNameTab, GroupNameTab, PasswordsTab, DefaultsTab;
  775. static BOOL TrustedEnabled;
  776. TCHAR TrustedDomain[MAX_PATH + 1];
  777. static TCHAR MappingFile[MAX_PATH + 1];
  778. DWORD_PTR dwIndex;
  779. switch (message) {
  780. case WM_INITDIALOG:
  781. // Center the dialog over the application window
  782. CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
  783. // Setup for Advanced >> button
  784. ShowArea(TRUE, hDlg, GetDlgItem(hDlg, IDC_DEFAULTBOX));
  785. TrustedEnabled = FALSE;
  786. // Need to set the check and radio buttons to correct state...
  787. UserDialogSetup(hDlg);
  788. hCtrl = GetDlgItem( hDlg, IDC_TABUSERS );
  789. PasswordsTab = BookTab_AddItem( hCtrl, Lids(IDS_S_38) );
  790. BookTab_SetItemData( hCtrl, PasswordsTab, 1001 );
  791. UserNameTab = BookTab_AddItem( hCtrl, Lids(IDS_S_39) );
  792. BookTab_SetItemData( hCtrl, UserNameTab, 1002 );
  793. GroupNameTab = BookTab_AddItem( hCtrl, Lids(IDS_S_40) );
  794. BookTab_SetItemData( hCtrl, GroupNameTab, 1003 );
  795. DefaultsTab = BookTab_AddItem( hCtrl, Lids(IDS_S_41) );
  796. BookTab_SetItemData( hCtrl, DefaultsTab, 1004 );
  797. BookTab_SetCurSel(hCtrl, PasswordsTab);
  798. // now need to reset the Advanced button to the correct state and also the
  799. // Advanced display area...
  800. if (CurrentConvertOptions->UseTrustedDomain) {
  801. TrustedEnabled = TRUE;
  802. DlgUsers_TrustedSetup(hDlg);
  803. }
  804. // Weirdness to initially enable controls on the tab control -
  805. // looks like a bug in the tab control.
  806. SetFocus(hCtrl);
  807. hCtrl = GetDlgItem( hDlg, IDOK );
  808. SetFocus(hCtrl);
  809. PostMessage(hDlg, BTN_SELCHANGE, 0, 0);
  810. return (TRUE);
  811. case BTN_SELCHANGE:
  812. hCtrl = GetDlgItem( hDlg, IDC_TABUSERS );
  813. TabSelection = BookTab_GetCurSel(hCtrl);
  814. if (TabSelection == UserNameTab) {
  815. Passwords_Toggle(hDlg, FALSE);
  816. Defaults_Toggle(hDlg, FALSE);
  817. DuplicateGroups_Toggle(hDlg, FALSE);
  818. DuplicateUsers_Toggle(hDlg, TRUE);
  819. }
  820. if (TabSelection == GroupNameTab) {
  821. Passwords_Toggle(hDlg, FALSE);
  822. Defaults_Toggle(hDlg, FALSE);
  823. DuplicateUsers_Toggle(hDlg, FALSE);
  824. DuplicateGroups_Toggle(hDlg, TRUE);
  825. }
  826. if (TabSelection == PasswordsTab) {
  827. DuplicateUsers_Toggle(hDlg, FALSE);
  828. Defaults_Toggle(hDlg, FALSE);
  829. DuplicateGroups_Toggle(hDlg, FALSE);
  830. Passwords_Toggle(hDlg, TRUE);
  831. }
  832. if (TabSelection == DefaultsTab) {
  833. Passwords_Toggle(hDlg, FALSE);
  834. DuplicateUsers_Toggle(hDlg, FALSE);
  835. DuplicateGroups_Toggle(hDlg, FALSE);
  836. Defaults_Toggle(hDlg, TRUE);
  837. }
  838. return (TRUE);
  839. case WM_COMMAND:
  840. wmId = LOWORD(wParam);
  841. wmEvent = HIWORD(wParam);
  842. switch (wmId) {
  843. case IDOK:
  844. if (UserDialogVerify(hDlg)) {
  845. UserDialogSave(hDlg);
  846. EndDialog(hDlg, 0);
  847. }
  848. return (TRUE);
  849. break;
  850. case IDCANCEL:
  851. EndDialog(hDlg, 0);
  852. return (TRUE);
  853. break;
  854. case IDHELP:
  855. if (TrustedEnabled)
  856. WinHelp(hDlg, HELP_FILE, HELP_CONTEXT, (DWORD) IDC_HELP_USERADV);
  857. else
  858. WinHelp(hDlg, HELP_FILE, HELP_CONTEXT, (DWORD) IDC_HELP_USER);
  859. return (TRUE);
  860. break;
  861. case IDC_ADVANCED:
  862. TrustedEnabled = TRUE;
  863. DlgUsers_TrustedSetup(hDlg);
  864. return (TRUE);
  865. break;
  866. case IDC_CHKUSERS:
  867. hCtrl = GetDlgItem(hDlg, IDC_CHKUSERS);
  868. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  869. UserDialogToggle(hDlg, TRUE);
  870. else
  871. UserDialogToggle(hDlg, FALSE);
  872. PostMessage(hDlg, BTN_SELCHANGE, 0, 0);
  873. return (TRUE);
  874. break;
  875. case IDC_CHKMAPPING:
  876. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  877. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1)
  878. Mapping_Toggle(hDlg, FALSE);
  879. else
  880. Mapping_Toggle(hDlg, TRUE);
  881. return (TRUE);
  882. break;
  883. case IDC_CHKTRUSTED:
  884. hCtrl = GetDlgItem(hDlg, IDC_CHKTRUSTED);
  885. if (SendMessage(hCtrl, BM_GETCHECK, 0, 0) == 1) {
  886. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  887. EnableWindow(hCtrl, TRUE);
  888. // Get trusted domain
  889. dwIndex = SendMessage(hCtrl, CB_GETCURSEL, 0, 0);
  890. if (dwIndex != CB_ERR) {
  891. // Get the domain name and then try to add it to our lists
  892. SendMessage(hCtrl, CB_GETLBTEXT, (WPARAM) dwIndex, (LPARAM) TrustedDomain);
  893. CurrentConvertOptions->TrustedDomain = NTTrustedDomainSet(hDlg, DestServ, TrustedDomain);
  894. CurrentConvertOptions->UseTrustedDomain = TRUE;
  895. } else
  896. CurrentConvertOptions->UseTrustedDomain = FALSE;
  897. } else {
  898. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  899. EnableWindow(hCtrl, FALSE);
  900. CurrentConvertOptions->UseTrustedDomain = FALSE;
  901. }
  902. // Toggled trust relationship so setup FPNW info accordingly
  903. FPNWChk = IsFPNW(UserServerNameGet(DServ, CurrentConvertOptions));
  904. if (TabSelection == DefaultsTab)
  905. Defaults_Toggle(hDlg, TRUE);
  906. return (TRUE);
  907. break;
  908. case IDC_TRUSTED:
  909. if (wmEvent == CBN_SELCHANGE) {
  910. // A new trusted domain was selected, update FPNW flag
  911. hCtrl = GetDlgItem(hDlg, IDC_TRUSTED);
  912. EnableWindow(hCtrl, TRUE);
  913. // Get trusted domain
  914. dwIndex = SendMessage(hCtrl, CB_GETCURSEL, 0, 0);
  915. if (dwIndex != CB_ERR) {
  916. // Get the domain name and then try to add it to our lists
  917. SendMessage(hCtrl, CB_GETLBTEXT, (WPARAM) dwIndex, (LPARAM) TrustedDomain);
  918. CurrentConvertOptions->TrustedDomain = NTTrustedDomainSet(hDlg, DestServ, TrustedDomain);
  919. CurrentConvertOptions->UseTrustedDomain = TRUE;
  920. } else
  921. CurrentConvertOptions->UseTrustedDomain = FALSE;
  922. FPNWChk = IsFPNW(UserServerNameGet(DServ, CurrentConvertOptions));
  923. CurrentConvertOptions->NetWareInfo = FPNWChk;
  924. if (TabSelection == DefaultsTab)
  925. Defaults_Toggle(hDlg, TRUE);
  926. }
  927. break;
  928. case IDC_BTNMAPPINGFILE:
  929. // Get anything in the text box
  930. hCtrl = GetDlgItem(hDlg, IDC_MAPPINGFILE);
  931. * (WORD *)MappingFile = sizeof(MappingFile);
  932. SendMessage(hCtrl, EM_GETLINE, 0, (LPARAM) MappingFile);
  933. // invoke the creation routine
  934. MapFileCreate(hDlg, MappingFile, SourceServ);
  935. // reset edit-box to whatever the returned filename is
  936. SendMessage(hCtrl, WM_SETTEXT, 0, (LPARAM) MappingFile);
  937. if (SendMessage(hCtrl, EM_LINELENGTH, 0, 0)) {
  938. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  939. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  940. } else {
  941. hCtrl = GetDlgItem(hDlg, IDC_CHKMAPPING);
  942. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  943. }
  944. return (TRUE);
  945. break;
  946. case IDC_BTNMAPPINGEDIT:
  947. MappingFileEdit(hDlg);
  948. return (TRUE);
  949. break;
  950. case IDC_PWCONST:
  951. if (wmEvent == EN_CHANGE)
  952. CheckRadioButton(hDlg, IDC_RADIO1, IDC_RADIO3, IDC_RADIO3);
  953. break;
  954. case IDC_USERCONST:
  955. if (wmEvent == EN_CHANGE)
  956. CheckRadioButton(hDlg, IDC_RADIO4, IDC_RADIO7, IDC_RADIO7);
  957. break;
  958. case IDC_GROUPCONST:
  959. if (wmEvent == EN_CHANGE)
  960. CheckRadioButton(hDlg, IDC_RADIO8, IDC_RADIO10, IDC_RADIO10);
  961. break;
  962. }
  963. break;
  964. }
  965. return (FALSE); // Didn't process the message
  966. lParam;
  967. } // DlgUsers
  968. /*+-------------------------------------------------------------------------+
  969. | UserOptions_Do()
  970. |
  971. +-------------------------------------------------------------------------+*/
  972. void UserOptions_Do(HWND hDlg, void *ConvOptions, SOURCE_SERVER_BUFFER *SourceServer, DEST_SERVER_BUFFER *DestServer) {
  973. DLGPROC lpfnDlg;
  974. SServ = SourceServer;
  975. DServ = DestServer;
  976. SourceServ = SourceServer->Name;
  977. DestServ = DestServer->Name;
  978. FPNWChk = DServ->IsFPNW;
  979. CurrentConvertOptions = (CONVERT_OPTIONS *) ConvOptions;
  980. lpfnDlg = MakeProcInstance((DLGPROC)DlgUsers, hInst);
  981. DialogBox(hInst, TEXT("DlgNewUsers"), hDlg, lpfnDlg) ;
  982. FreeProcInstance(lpfnDlg);
  983. } // UserOptions_Do