Windows NT 4.0 source code leak
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.

1255 lines
29 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. sysacc.c
  5. Abstract:
  6. This module performs APPLY and CHECK functions related to
  7. SYSTEM ACCESS.
  8. Author:
  9. Jim Kelly (JimK) 22-Sep-1994
  10. Revision History:
  11. --*/
  12. #include "secmgrp.h"
  13. ///////////////////////////////////////////////////////////////////////
  14. // //
  15. // Module-specific definitions //
  16. // //
  17. ///////////////////////////////////////////////////////////////////////
  18. #define SECMGRP_MAX_CAPTION_LENGTH 200
  19. #define SECMGRP_MAX_BODY_LENGTH 2048
  20. ///////////////////////////////////////////////////////////////////////
  21. // //
  22. // Module-Wide variables //
  23. // //
  24. ///////////////////////////////////////////////////////////////////////
  25. //
  26. // The following variables represent the current settings in the
  27. // SYSTEM ACCESS dialog. The values for each are:
  28. //
  29. // CurrentCacheSize - ULONG, 0 to SECMGRP_MAX_LOGON_CACHE_COUNT
  30. //
  31. // CurrentUnlock -
  32. // SECMGR_ID_RADIO_SYSACC_UNLOCK_ANYONE
  33. // SECMGR_ID_RADIO_SYSACC_UNLOCK_ADMIN
  34. //
  35. // CurrentShutdown -
  36. // SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ANYONE
  37. // SECMGR_ID_RADIO_SYSACC_SHUTDOWN_LOGGED_ON
  38. // SECMGR_ID_RADIO_SYSACC_SHUTDOWN_OPERS
  39. // SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ADMIN
  40. //
  41. // CurrentLegalNotice -
  42. // SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE_NONE
  43. // SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE
  44. //
  45. // LegalNoticeCaption -
  46. // Only valid when CurrentLegalNotice has the value
  47. // SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE. In that case,
  48. // points to a string containing the legal notice title
  49. // bar text.
  50. //
  51. // LegalNoticeBody -
  52. // Only valid when CurrentLegalNotice has the value
  53. // SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE. In that case,
  54. // points to a string containing the legal notice body
  55. // text.
  56. //
  57. ULONG
  58. SecMgrpCurrentCacheSize,
  59. SecMgrpCurrentUnlock,
  60. SecMgrpCurrentShutdown,
  61. SecMgrpCurrentLegalNotice;
  62. //
  63. // Because setting some values takes so long, it is worth
  64. // remembering the initial values so we can determine whether
  65. // or not they have changed.
  66. //
  67. ULONG
  68. SecMgrpOriginalCacheSize,
  69. SecMgrpOriginalUnlock,
  70. SecMgrpOriginalShutdown,
  71. SecMgrpOriginalLegalNotice;
  72. BOOLEAN
  73. SecMgrpOriginalLegalNoticeChanged;
  74. WCHAR
  75. SecMgrpLegalNoticeCaptionBuffer[SECMGRP_MAX_CAPTION_LENGTH],
  76. SecMgrpLegalNoticeBodyBuffer[SECMGRP_MAX_BODY_LENGTH];
  77. UNICODE_STRING
  78. SecMgrpCurrentLegalNoticeCaption =
  79. {0, SECMGRP_MAX_CAPTION_LENGTH, SecMgrpLegalNoticeCaptionBuffer },
  80. SecMgrpCurrentLegalNoticeBody =
  81. {0, SECMGRP_MAX_BODY_LENGTH, SecMgrpLegalNoticeBodyBuffer };
  82. ///////////////////////////////////////////////////////////////////////
  83. // //
  84. // Module-Private Prototypes //
  85. // //
  86. ///////////////////////////////////////////////////////////////////////
  87. BOOLEAN
  88. SecMgrpDisplayUnlock(
  89. HWND hwnd,
  90. BOOLEAN ChangesAllowed
  91. );
  92. BOOLEAN
  93. SecMgrpDisplayShutdown(
  94. HWND hwnd,
  95. BOOLEAN ChangesAllowed
  96. );
  97. BOOLEAN
  98. SecMgrpDisplayLogonCache(
  99. HWND hwnd,
  100. BOOLEAN ChangesAllowed
  101. );
  102. BOOLEAN
  103. SecMgrpDisplayLegalNotice(
  104. HWND hwnd,
  105. BOOLEAN ChangesAllowed
  106. );
  107. BOOLEAN
  108. SecMgrpSysAccInitDialog(
  109. HWND hwnd,
  110. BOOLEAN ChangesAllowed
  111. );
  112. VOID
  113. SecMgrpGreyLegalNotice(
  114. HWND hwnd,
  115. BOOLEAN Grey
  116. );
  117. BOOLEAN
  118. SecMgrpSysAccApplyCurrentSettings( HWND hwnd );
  119. VOID
  120. SecMgrpWarnOfAutologon( HWND hwnd );
  121. LONG
  122. SecMgrpDlgProcWarnOfAutologon(
  123. HWND hwnd,
  124. UINT wMsg,
  125. DWORD wParam,
  126. LONG lParam
  127. );
  128. ///////////////////////////////////////////////////////////////////////
  129. // //
  130. // Externally callable functions //
  131. // //
  132. ///////////////////////////////////////////////////////////////////////
  133. LONG
  134. SecMgrpDlgProcSysAccess(
  135. HWND hwnd,
  136. UINT wMsg,
  137. DWORD wParam,
  138. LONG lParam
  139. )
  140. /*++
  141. Routine Description:
  142. This function is the dialog process for the APPLY and CHECK
  143. [SYSTEM ACCESS...] dialog.
  144. Arguments
  145. lParam - If FALSE, changes are NOT allowed to any of the settings.
  146. If TRUE, changes ARE allowed.
  147. Return Values:
  148. TRUE - the message was handled.
  149. FALSE - the message was not handled.
  150. --*/
  151. {
  152. HWND
  153. Button;
  154. HCURSOR
  155. hCursor;
  156. int
  157. Index;
  158. BOOLEAN
  159. ChangesAllowed,
  160. Changed;
  161. ChangesAllowed = (BOOLEAN)(lParam);
  162. switch (wMsg) {
  163. case WM_INITDIALOG:
  164. if (!SecMgrpSysAccInitDialog( hwnd, ChangesAllowed ) ) {
  165. //
  166. // Couldn't init the dialog. It has been terminated.
  167. //
  168. return(TRUE);
  169. }
  170. //
  171. // If ChangesAllowed, Hide the [OK] button.
  172. // Otherwise, hide the [APPLY] and [CANCEL] buttons.
  173. // Also select the button for the cursor to start at.
  174. //
  175. if (ChangesAllowed) {
  176. Button = GetDlgItem(hwnd, IDOK);
  177. ShowWindow( Button, SW_HIDE );
  178. Button = GetDlgItem(hwnd, SECMGR_ID_BUTTON_SYSACC_APPLY);
  179. } else {
  180. Button = GetDlgItem(hwnd, SECMGR_ID_BUTTON_SYSACC_APPLY);
  181. ShowWindow( Button, SW_HIDE );
  182. Button = GetDlgItem(hwnd, IDCANCEL);
  183. ShowWindow( Button, SW_HIDE );
  184. Button = GetDlgItem(hwnd, IDOK);
  185. }
  186. //
  187. // Set the cursor
  188. //
  189. Index = (int)SendMessage(Button, CB_GETCURSEL, 0, 0);
  190. SetForegroundWindow(hwnd);
  191. ShowWindow(hwnd, SW_NORMAL);
  192. //
  193. // Now check a few things that this utility does not provide
  194. // a UI to change. Put up a warning if an unusual setting
  195. // is found...
  196. //
  197. SecMgrpWarnOfAutologon( hwnd );
  198. return(TRUE);
  199. case WM_SYSCOMMAND:
  200. switch (wParam & 0xfff0) {
  201. case SC_CLOSE:
  202. EndDialog(hwnd, 0);
  203. return(TRUE);
  204. }
  205. return(FALSE);
  206. case WM_COMMAND:
  207. switch(LOWORD(wParam)) {
  208. case SECMGR_ID_BUTTON_SYSACC_LOGON_CACHE:
  209. DialogBoxParam(SecMgrphInstance,
  210. MAKEINTRESOURCE(SECMGR_ID_DLG_LOGON_CACHE_DESCR),
  211. hwnd,
  212. (DLGPROC)SecMgrpDlgProcHelp,
  213. (LONG)0
  214. );
  215. return(TRUE);
  216. case SECMGR_ID_RADIO_SYSACC_UNLOCK_ANYONE:
  217. case SECMGR_ID_RADIO_SYSACC_UNLOCK_ADMIN:
  218. SecMgrpCurrentUnlock = LOWORD(wParam);
  219. return(TRUE);
  220. case SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ANYONE:
  221. case SECMGR_ID_RADIO_SYSACC_SHUTDOWN_LOGGED_ON:
  222. case SECMGR_ID_RADIO_SYSACC_SHUTDOWN_OPERS:
  223. case SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ADMIN:
  224. SecMgrpCurrentShutdown = LOWORD(wParam);
  225. return(TRUE);
  226. case SECMGR_ID_EDIT_SYSACC_LEGAL_NOTICE_CAPTION:
  227. case SECMGR_ID_EDIT_SYSACC_LEGAL_NOTICE_BODY:
  228. //
  229. // Just note that the notice has changed
  230. //
  231. if (HIWORD(lParam) == EN_UPDATE) {
  232. SecMgrpOriginalLegalNoticeChanged = TRUE;
  233. }
  234. return(TRUE);
  235. case SECMGR_ID_BUTTON_SYSACC_APPLY:
  236. //
  237. // Changing all the rights assignments takes
  238. // a while. Change to an hourglass icon.
  239. //
  240. hCursor = SetCursor( LoadCursor(NULL, IDC_WAIT) );
  241. ShowCursor(TRUE);
  242. //
  243. // Get the legal notice strings, if necessary
  244. //
  245. if (SecMgrpOriginalLegalNoticeChanged) {
  246. if (SecMgrpCurrentLegalNotice == SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE ) {
  247. SecMgrpCurrentLegalNoticeCaption.Length =
  248. GetDlgItemText(hwnd,
  249. SECMGR_ID_EDIT_SYSACC_LEGAL_NOTICE_CAPTION,
  250. SecMgrpCurrentLegalNoticeCaption.Buffer,
  251. SecMgrpCurrentLegalNoticeCaption.MaximumLength
  252. );
  253. SecMgrpCurrentLegalNoticeBody.Length =
  254. GetDlgItemText(hwnd,
  255. SECMGR_ID_EDIT_SYSACC_LEGAL_NOTICE_BODY,
  256. SecMgrpCurrentLegalNoticeBody.Buffer,
  257. SecMgrpCurrentLegalNoticeBody.MaximumLength
  258. );
  259. }
  260. }
  261. if (SecMgrpSysAccApplyCurrentSettings( hwnd )) {
  262. EndDialog(hwnd, 0);
  263. }
  264. return(TRUE);
  265. case SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE_NONE:
  266. SecMgrpGreyLegalNotice( hwnd, TRUE );
  267. SecMgrpCurrentLegalNotice = LOWORD(wParam);
  268. if (SecMgrpOriginalLegalNotice != SecMgrpCurrentLegalNotice) {
  269. SecMgrpOriginalLegalNoticeChanged = TRUE;
  270. } else {
  271. SecMgrpOriginalLegalNoticeChanged = FALSE;
  272. }
  273. return(TRUE);
  274. case SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE:
  275. SecMgrpGreyLegalNotice( hwnd, FALSE );
  276. SecMgrpCurrentLegalNotice = LOWORD(wParam);
  277. //
  278. // If the original setting was "LEGAL NOTICE", we can't
  279. // say that the original notice hasn't changed if we
  280. // re-select this button. This is because the text of
  281. // the message might have changed.
  282. //
  283. if (SecMgrpOriginalLegalNotice != SecMgrpCurrentLegalNotice) {
  284. SecMgrpOriginalLegalNoticeChanged = TRUE;
  285. }
  286. return(TRUE);
  287. case IDCANCEL:
  288. case IDOK:
  289. EndDialog(hwnd, 0);
  290. return(TRUE);
  291. default:
  292. return FALSE;
  293. }
  294. case WM_VSCROLL:
  295. Index = GetWindowLong((HWND)lParam, GWL_ID);
  296. switch (Index) {
  297. case SECMGR_ID_SPIN_SYSACC_LOGON_CACHE:
  298. Changed = FALSE;
  299. if (LOWORD(wParam) == SB_LINEUP) {
  300. if (SecMgrpCurrentCacheSize < SECMGRP_MAX_LOGON_CACHE_COUNT) {
  301. SecMgrpCurrentCacheSize++;
  302. Changed = TRUE;
  303. }
  304. } else if (LOWORD(wParam) == SB_LINEDOWN) {
  305. if (SecMgrpCurrentCacheSize > 0) {
  306. SecMgrpCurrentCacheSize--;
  307. Changed = TRUE;
  308. }
  309. }
  310. if (Changed) {
  311. SetDlgItemInt( hwnd,
  312. SECMGR_ID_EDIT_SYSACC_LOGON_CACHE,
  313. SecMgrpCurrentCacheSize,
  314. FALSE // Not signed value
  315. );
  316. }
  317. return(TRUE);
  318. default:
  319. break;
  320. }
  321. default:
  322. break;
  323. }
  324. return FALSE;
  325. }
  326. BOOLEAN
  327. SecMgrpSysAccInitDialog(
  328. HWND hwnd,
  329. BOOLEAN ChangesAllowed
  330. )
  331. /*++
  332. Routine Description:
  333. This function initializes the System Access dialog box with
  334. current values and recommended values. This may be used for
  335. both [APPLY] and [CHECK] operations.
  336. For [CHECK] operations, the caller is responsible for greying
  337. all controls in the dialog box (except the [HELP] button) and
  338. making the [APPLY] and [CANCEL] buttons invisible.
  339. For [APPLY] operations, the caller is responsible for making the
  340. [OK] button invisible.
  341. Current settings are placed in the module-wide current-setting
  342. variables.
  343. Arguments
  344. ChangesAllowed - TRUE: Leave change controls enabled.
  345. FALSE: Disable change controls.
  346. Return Values:
  347. TRUE - The dialog has been initialized without problem.
  348. FALSE - A problem was encountered. A popup has been displayed
  349. and the dialog has been ended.
  350. --*/
  351. {
  352. ///////////////////////////////////////////////////////////////////
  353. // //
  354. // Get current settings and recommended settings. //
  355. // //
  356. ///////////////////////////////////////////////////////////////////
  357. if (SecMgrpDisplayUnlock( hwnd, ChangesAllowed )) {
  358. if (SecMgrpDisplayShutdown( hwnd, ChangesAllowed )) {
  359. if (SecMgrpDisplayLegalNotice( hwnd, ChangesAllowed )) {
  360. if (SecMgrpDisplayLogonCache( hwnd, ChangesAllowed )) {
  361. return(TRUE);
  362. }
  363. }
  364. }
  365. }
  366. //
  367. // Something didn't work
  368. //
  369. EndDialog(hwnd, 0);
  370. return(FALSE);
  371. }
  372. BOOLEAN
  373. SecMgrpDisplayUnlock(
  374. HWND hwnd,
  375. BOOLEAN ChangesAllowed
  376. )
  377. /*++
  378. Routine Description:
  379. This function retrieves the current unlock setting and establishes
  380. the correct recommendation in the SYSTEM ACCESS dialog.
  381. The current setting is placed in SecMgrpCurrentUnlock.
  382. Arguments
  383. ChangesAllowed - TRUE: Leave change controls enabled.
  384. FALSE: Disable change controls.
  385. Return Values:
  386. TRUE - Completed successfully.
  387. FALSE - Did not complete successfully.
  388. A popup has been displayed.
  389. The dialog should be terminated.
  390. --*/
  391. {
  392. BOOLEAN
  393. UnlockByAnyone;
  394. HWND
  395. Control;
  396. //
  397. // Set the recommendation
  398. //
  399. // Administrator Only is always the recommended value
  400. // EXCEPT for WinNt running Standard.
  401. //
  402. if ((SecMgrpProductType == NtProductWinNt) &&
  403. (SecMgrpCurrentLevel == SECMGR_ID_LEVEL_STANDARD) ) {
  404. //
  405. // Anyone is default - hide the other recommendation
  406. //
  407. Control = GetDlgItem(hwnd, SECMGR_ID_RECOMMEND_SYSACC_UNLOCK_ADMIN);
  408. ShowWindow(Control, SW_HIDE);
  409. } else {
  410. //
  411. // Administrator only is default - hide the other recommendation
  412. //
  413. Control = GetDlgItem(hwnd, SECMGR_ID_RECOMMEND_SYSACC_UNLOCK_ANYONE);
  414. ShowWindow(Control, SW_HIDE);
  415. }
  416. SecMgrpGetUnlockSetting( hwnd, &UnlockByAnyone );
  417. //
  418. // Set the radio buttons accordingly
  419. //
  420. if (UnlockByAnyone) {
  421. SecMgrpCurrentUnlock = SECMGR_ID_RADIO_SYSACC_UNLOCK_ANYONE;
  422. } else {
  423. SecMgrpCurrentUnlock = SECMGR_ID_RADIO_SYSACC_UNLOCK_ADMIN;
  424. }
  425. CheckRadioButton( hwnd,
  426. SECMGR_ID_RADIO_SYSACC_UNLOCK_ANYONE,
  427. SECMGR_ID_RADIO_SYSACC_UNLOCK_ADMIN,
  428. SecMgrpCurrentUnlock);
  429. //
  430. // If changes aren't allowed, then grey the radio buttons
  431. //
  432. if (!ChangesAllowed) {
  433. Control = GetDlgItem(hwnd, SECMGR_ID_RADIO_SYSACC_UNLOCK_ANYONE);
  434. EnableWindow( Control, FALSE );
  435. Control = GetDlgItem(hwnd, SECMGR_ID_RADIO_SYSACC_UNLOCK_ADMIN);
  436. EnableWindow( Control, FALSE );
  437. }
  438. SecMgrpOriginalUnlock = SecMgrpCurrentUnlock;
  439. return(TRUE);
  440. }
  441. BOOLEAN
  442. SecMgrpDisplayShutdown(
  443. HWND hwnd,
  444. BOOLEAN ChangesAllowed
  445. )
  446. /*++
  447. Routine Description:
  448. This function retrieves the current shutdown setting and establishes
  449. the correct recommendation in the SYSTEM ACCESS dialog.
  450. The current setting is placed in SecMgrpCurrentShutdown.
  451. Arguments
  452. ChangesAllowed - TRUE: Leave change controls enabled.
  453. FALSE: Disable change controls.
  454. Return Values:
  455. TRUE - Completed successfully.
  456. FALSE - Did not complete successfully.
  457. A popup has been displayed.
  458. The dialog should be terminated.
  459. --*/
  460. {
  461. HWND
  462. Control;
  463. BOOLEAN
  464. Result;
  465. SECMGRP_WHO
  466. Who;
  467. //
  468. // Set the recommendation
  469. //
  470. // Operators and Administrators is always the recommended value
  471. // EXCEPT for WinNt running Standard.
  472. //
  473. Control = GetDlgItem(hwnd, SECMGR_ID_RECOMMEND_SYSACC_SHUTDOWN_LOGGED_ON);
  474. ShowWindow(Control, SW_HIDE);
  475. Control = GetDlgItem(hwnd, SECMGR_ID_RECOMMEND_SYSACC_SHUTDOWN_ADMIN);
  476. ShowWindow(Control, SW_HIDE);
  477. if ((SecMgrpProductType == NtProductWinNt) &&
  478. (SecMgrpCurrentLevel == SECMGR_ID_LEVEL_STANDARD) ) {
  479. //
  480. // Anyone is default - hide the other recommendation
  481. //
  482. Control = GetDlgItem(hwnd, SECMGR_ID_RECOMMEND_SYSACC_SHUTDOWN_OPERS);
  483. ShowWindow(Control, SW_HIDE);
  484. } else {
  485. //
  486. // Operators and Administrators is default - hide the other recommendation
  487. //
  488. Control = GetDlgItem(hwnd, SECMGR_ID_RECOMMEND_SYSACC_SHUTDOWN_ANYONE);
  489. ShowWindow(Control, SW_HIDE);
  490. }
  491. Result = SecMgrpGetShutdownSetting( hwnd, &Who );
  492. if (!Result) {
  493. //
  494. // Display popup
  495. //
  496. return(FALSE);
  497. }
  498. switch (Who) {
  499. case SecMgrpAnyone:
  500. SecMgrpCurrentShutdown = SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ANYONE;
  501. break;
  502. case SecMgrpAnyoneLoggedOn:
  503. SecMgrpCurrentShutdown = SECMGR_ID_RADIO_SYSACC_SHUTDOWN_LOGGED_ON;
  504. break;
  505. case SecMgrpOpersAndAdmins:
  506. SecMgrpCurrentShutdown = SECMGR_ID_RADIO_SYSACC_SHUTDOWN_OPERS;
  507. break;
  508. case SecMgrpAdminsOnly:
  509. SecMgrpCurrentShutdown = SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ADMIN;
  510. break;
  511. }
  512. //
  513. // Set the radio buttons accordingly
  514. //
  515. CheckRadioButton( hwnd,
  516. SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ANYONE,
  517. SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ADMIN,
  518. SecMgrpCurrentShutdown);
  519. //
  520. // If changes aren't allowed, then grey the radio buttons
  521. //
  522. if (!ChangesAllowed) {
  523. Control = GetDlgItem(hwnd, SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ANYONE);
  524. EnableWindow( Control, FALSE );
  525. Control = GetDlgItem(hwnd, SECMGR_ID_RADIO_SYSACC_SHUTDOWN_LOGGED_ON);
  526. EnableWindow( Control, FALSE );
  527. Control = GetDlgItem(hwnd, SECMGR_ID_RADIO_SYSACC_SHUTDOWN_OPERS);
  528. EnableWindow( Control, FALSE );
  529. Control = GetDlgItem(hwnd, SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ADMIN);
  530. EnableWindow( Control, FALSE );
  531. }
  532. SecMgrpOriginalShutdown = SecMgrpCurrentShutdown;
  533. return(TRUE);
  534. }
  535. BOOLEAN
  536. SecMgrpDisplayLegalNotice(
  537. HWND hwnd,
  538. BOOLEAN ChangesAllowed
  539. )
  540. /*++
  541. Routine Description:
  542. This function retrieves the current legal notice setting and
  543. establishes the correct recommendation in the SYSTEM ACCESS dialog.
  544. It also greys the caption and body fields if no legal notice is
  545. in effect.
  546. The current setting is placed in SecMgrpCurrentLegalNotice, and
  547. SecMgrpLegalNoticeCaption and SecMgrpLegalNoticeBody will be set
  548. to either NULL, or to point to appropriate strings.
  549. Arguments
  550. ChangesAllowed - TRUE: Leave change controls enabled.
  551. FALSE: Disable change controls.
  552. Return Values:
  553. TRUE - Completed successfully.
  554. FALSE - Did not complete successfully.
  555. A popup has been displayed.
  556. The dialog should be terminated.
  557. --*/
  558. {
  559. HWND
  560. Control;
  561. //
  562. // The recommendation is set in the dialog by default.
  563. // We always recommend a legal notice.
  564. //
  565. if (!SecMgrpGetLegalNotice( hwnd,
  566. &SecMgrpCurrentLegalNoticeCaption,
  567. &SecMgrpCurrentLegalNoticeBody) ) {
  568. return(FALSE);
  569. }
  570. if ( (SecMgrpCurrentLegalNoticeCaption.Length != 0) ||
  571. (SecMgrpCurrentLegalNoticeBody.Length != 0) ) {
  572. SecMgrpCurrentLegalNotice = SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE;
  573. } else {
  574. SecMgrpCurrentLegalNotice = SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE_NONE;
  575. }
  576. //
  577. // Set the radio buttons accordingly
  578. //
  579. CheckRadioButton( hwnd,
  580. SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE_NONE,
  581. SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE,
  582. SecMgrpCurrentLegalNotice);
  583. //
  584. // If we have a legal notice, then display it.
  585. // Otherwise, grey the legal notice edit boxes.
  586. //
  587. if (SecMgrpCurrentLegalNotice == SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE) {
  588. if (SecMgrpCurrentLegalNoticeCaption.Length != 0) {
  589. SetDlgItemText( hwnd,
  590. SECMGR_ID_EDIT_SYSACC_LEGAL_NOTICE_CAPTION,
  591. SecMgrpCurrentLegalNoticeCaption.Buffer);
  592. }
  593. if (SecMgrpCurrentLegalNoticeBody.Length != 0) {
  594. SetDlgItemText( hwnd,
  595. SECMGR_ID_EDIT_SYSACC_LEGAL_NOTICE_BODY,
  596. SecMgrpCurrentLegalNoticeBody.Buffer);
  597. }
  598. } else {
  599. SecMgrpGreyLegalNotice( hwnd, TRUE );
  600. }
  601. //
  602. // If changes aren't allowed, then grey the radio buttons
  603. // and the text.
  604. //
  605. if (!ChangesAllowed) {
  606. Control = GetDlgItem(hwnd, SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE_NONE);
  607. EnableWindow( Control, FALSE );
  608. Control = GetDlgItem(hwnd, SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE);
  609. EnableWindow( Control, FALSE );
  610. SecMgrpGreyLegalNotice( hwnd, TRUE );
  611. }
  612. SecMgrpOriginalLegalNotice = SecMgrpCurrentLegalNotice;
  613. SecMgrpOriginalLegalNoticeChanged = FALSE;
  614. return(TRUE);
  615. }
  616. BOOLEAN
  617. SecMgrpDisplayLogonCache(
  618. HWND hwnd,
  619. BOOLEAN ChangesAllowed
  620. )
  621. /*++
  622. Routine Description:
  623. This function retrieves the current logon cache settings and
  624. establishes the correct recommendation in the SYSTEM ACCESS dialog.
  625. The current setting is placed in SecMgrpCurrentCacheSize.
  626. Arguments
  627. ChangesAllowed - TRUE: Leave change controls enabled.
  628. FALSE: Disable change controls.
  629. Return Values:
  630. TRUE - Completed successfully.
  631. FALSE - Did not complete successfully.
  632. A popup has been displayed.
  633. The dialog should be terminated.
  634. --*/
  635. {
  636. NTSTATUS
  637. NtStatus;
  638. ULONG
  639. Recommendation;
  640. HWND
  641. Control;
  642. NtStatus = SecMgrpGetLogonCache( hwnd,
  643. &SecMgrpCurrentCacheSize,
  644. &Recommendation);
  645. if (!NT_SUCCESS(NtStatus)) {
  646. //
  647. // Put up a popup here.
  648. //
  649. return(FALSE);
  650. }
  651. SetDlgItemInt( hwnd,
  652. SECMGR_ID_RECOMMEND_SYSACC_LOGON_CACHE,
  653. Recommendation,
  654. FALSE // Not signed value
  655. );
  656. SetDlgItemInt( hwnd,
  657. SECMGR_ID_CURRENT_SYSACC_LOGON_CACHE,
  658. SecMgrpCurrentCacheSize,
  659. FALSE // Not signed value
  660. );
  661. SetDlgItemInt( hwnd,
  662. SECMGR_ID_EDIT_SYSACC_LOGON_CACHE,
  663. SecMgrpCurrentCacheSize,
  664. FALSE // Not signed value
  665. );
  666. //
  667. // If changes aren't allowed, then hide the modification controls
  668. //
  669. if (!ChangesAllowed) {
  670. Control = GetDlgItem(hwnd, SECMGR_ID_TEXT_SYSACC_SIZE_TO_APPLY);
  671. ShowWindow(Control, SW_HIDE);
  672. Control = GetDlgItem(hwnd, SECMGR_ID_EDIT_SYSACC_LOGON_CACHE);
  673. ShowWindow(Control, SW_HIDE);
  674. Control = GetDlgItem(hwnd, SECMGR_ID_SPIN_SYSACC_LOGON_CACHE);
  675. ShowWindow(Control, SW_HIDE);
  676. }
  677. SecMgrpOriginalCacheSize = SecMgrpCurrentCacheSize;
  678. return(TRUE);
  679. }
  680. VOID
  681. SecMgrpGreyLegalNotice(
  682. HWND hwnd,
  683. BOOLEAN Grey
  684. )
  685. /*++
  686. Routine Description:
  687. This function greys or ungreys the legal notice edit boxes.
  688. Arguments
  689. hwnd - Window handle.
  690. Grey - If TRUE, the boxes will be greyed.
  691. If FALSE, the boxes will be un-greyed.
  692. Return Values:
  693. None.
  694. --*/
  695. {
  696. HWND
  697. Control;
  698. BOOLEAN
  699. Enable;
  700. if (Grey) {
  701. Enable = FALSE;
  702. } else {
  703. Enable = TRUE;
  704. }
  705. Control = GetDlgItem(hwnd, SECMGR_ID_TEXT_SYSACC_TITLE_BAR);
  706. EnableWindow( Control, Enable );
  707. Control = GetDlgItem(hwnd, SECMGR_ID_EDIT_SYSACC_LEGAL_NOTICE_CAPTION);
  708. EnableWindow( Control, Enable );
  709. Control = GetDlgItem(hwnd, SECMGR_ID_TEXT_SYSACC_LEGAL_NOTICE_BODY);
  710. EnableWindow( Control, Enable );
  711. Control = GetDlgItem(hwnd, SECMGR_ID_EDIT_SYSACC_LEGAL_NOTICE_BODY);
  712. EnableWindow( Control, Enable );
  713. return;
  714. }
  715. BOOLEAN
  716. SecMgrpSysAccApplyCurrentSettings(
  717. HWND hwnd
  718. )
  719. /*++
  720. Routine Description:
  721. This function applies the current settings to the operational system.
  722. If necessary, the RebootRequired flag will be set to TRUE.
  723. Also, if necessary, a pop-up describing any problems will be
  724. presented to the user.
  725. Arguments
  726. hwnd - Window handle.
  727. Return Values:
  728. TRUE - Everything was assigned correctly.
  729. FALSE - Something was not assigned correctly. A popup has been
  730. presented to the user.
  731. --*/
  732. {
  733. BOOLEAN
  734. UnlockByAnyone,
  735. Result = TRUE;
  736. SECMGRP_WHO
  737. Shutdown;
  738. if (SecMgrpCurrentUnlock == SECMGR_ID_RADIO_SYSACC_UNLOCK_ANYONE) {
  739. UnlockByAnyone = TRUE;
  740. } else {
  741. UnlockByAnyone = FALSE;
  742. }
  743. switch (SecMgrpCurrentShutdown) {
  744. case SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ANYONE:
  745. Shutdown = SecMgrpAnyone;
  746. break;
  747. case SECMGR_ID_RADIO_SYSACC_SHUTDOWN_LOGGED_ON:
  748. Shutdown = SecMgrpAnyoneLoggedOn;
  749. break;
  750. case SECMGR_ID_RADIO_SYSACC_SHUTDOWN_OPERS:
  751. Shutdown = SecMgrpOpersAndAdmins;
  752. break;
  753. case SECMGR_ID_RADIO_SYSACC_SHUTDOWN_ADMIN:
  754. Shutdown = SecMgrpAdminsOnly;
  755. break;
  756. } //end_switch
  757. if (SecMgrpCurrentLegalNotice == SECMGR_ID_RADIO_SYSACC_LEGAL_NOTICE_NONE) {
  758. SecMgrpCurrentLegalNoticeCaption.Length = 0;
  759. SecMgrpCurrentLegalNoticeCaption.Buffer[0] = TEXT('\0');
  760. SecMgrpCurrentLegalNoticeBody.Length = 0;
  761. SecMgrpCurrentLegalNoticeBody.Buffer[0] = TEXT('\0');
  762. }
  763. //
  764. // We count on the called routines to put up appropriate
  765. // pop-ups on error.
  766. //
  767. if (Result && (SecMgrpCurrentUnlock != SecMgrpOriginalUnlock)) {
  768. Result = SecMgrpSetUnlockSetting(hwnd, UnlockByAnyone);
  769. }
  770. if (Result && (SecMgrpCurrentCacheSize != SecMgrpOriginalCacheSize)) {
  771. Result = SecMgrpSetLogonCache(hwnd, SecMgrpCurrentCacheSize);
  772. }
  773. if (Result && (SecMgrpOriginalLegalNoticeChanged)) {
  774. Result = SecMgrpSetLegalNotice(hwnd,
  775. &SecMgrpCurrentLegalNoticeCaption,
  776. &SecMgrpCurrentLegalNoticeBody);
  777. }
  778. if (Result && (SecMgrpCurrentShutdown != SecMgrpOriginalShutdown)) {
  779. Result = SecMgrpSetShutdownSetting(hwnd, Shutdown);
  780. }
  781. return(Result);
  782. }
  783. VOID
  784. SecMgrpWarnOfAutologon(
  785. HWND hwnd
  786. )
  787. /*++
  788. Routine Description:
  789. This function checks to see if autologon is turned on.
  790. If it is, a warning is put up to warn the user. There is
  791. no UI in this utility which allows the user to change this.
  792. Therefore, tell the user how to do it with REGEDT32.
  793. Arguments
  794. hwnd - Window handle.
  795. Return Values:
  796. None.
  797. --*/
  798. {
  799. if (GetProfileInt( TEXT("Winlogon"), TEXT("AutoAdminLogon"), 0 ) != 0) {
  800. DialogBoxParam(SecMgrphInstance,
  801. MAKEINTRESOURCE(SECMGR_ID_DLG_AUTOLOGON_ENABLED),
  802. hwnd,
  803. (DLGPROC)SecMgrpDlgProcWarnOfAutologon,
  804. (LONG)0
  805. );
  806. }
  807. return;
  808. }
  809. LONG
  810. SecMgrpDlgProcWarnOfAutologon(
  811. HWND hwnd,
  812. UINT wMsg,
  813. DWORD wParam,
  814. LONG lParam
  815. )
  816. /*++
  817. Routine Description:
  818. This function is the dialog process for a dialog informing the
  819. user that autologon is enabled.
  820. Arguments
  821. Return Values:
  822. --*/
  823. {
  824. HWND
  825. OkButton;
  826. int
  827. Index;
  828. switch (wMsg) {
  829. case WM_INITDIALOG:
  830. //
  831. // Set the cursor
  832. //
  833. OkButton = GetDlgItem(hwnd, IDOK);
  834. Index = (int)SendMessage(OkButton, CB_GETCURSEL, 0, 0);
  835. SetForegroundWindow(hwnd);
  836. ShowWindow(hwnd, SW_NORMAL);
  837. return(TRUE);
  838. case WM_SYSCOMMAND:
  839. switch (wParam & 0xfff0) {
  840. case SC_CLOSE:
  841. EndDialog(hwnd, 0);
  842. return(TRUE);
  843. }
  844. return(FALSE);
  845. case WM_COMMAND:
  846. switch(LOWORD(wParam)) {
  847. case IDCANCEL:
  848. case IDOK:
  849. EndDialog(hwnd, 0);
  850. return(TRUE);
  851. break;
  852. default:
  853. return FALSE;
  854. }
  855. default:
  856. break;
  857. }
  858. return FALSE;
  859. }