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.

916 lines
23 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1999.
  5. //
  6. // File: CommonQueriesDlg.cxx
  7. //
  8. // Contents: Implementation of dialog that produces an LDAP filter for
  9. // a number of common queries.
  10. //
  11. // Classes: CCommonQueriesTab
  12. //
  13. // History: 04-03-2000 DavidMun Created
  14. //
  15. //---------------------------------------------------------------------------
  16. #include "headers.hxx"
  17. #pragma hdrstop
  18. static ULONG
  19. s_aulHelpIds[] =
  20. {
  21. IDC_NAME_COMBO, IDH_NAME_COMBO,
  22. IDC_NAME_EDIT, IDH_NAME_EDIT,
  23. IDC_DESCRIPTION_COMBO, IDH_DESCRIPTION_COMBO,
  24. IDC_DESCRIPTION_EDIT, IDH_DESCRIPTION_EDIT,
  25. IDC_DISABLED_CKBOX, IDH_DISABLED_CKBOX,
  26. IDC_NON_EXPIRING_CKBOX, IDH_NON_EXPIRING_CKBOX,
  27. IDC_LASTLOGON_COMBO, IDH_LASTLOGON_COMBO,
  28. IDC_LASTLOGON_LBL, IDH_LASTLOGON_LBL,
  29. IDC_DESCRIPTION_LBL, IDH_DESCRIPTION_LBL,
  30. IDC_NAME_LBL, IDH_NAME_LBL1,
  31. 0,0
  32. };
  33. //
  34. // Forward references
  35. //
  36. void
  37. GetCurrentTimeStampMinusInterval(
  38. int iDays,
  39. ULARGE_INTEGER* pULI);
  40. //+--------------------------------------------------------------------------
  41. //
  42. // Member: CCommonQueriesTab::CCommonQueriesTab
  43. //
  44. // Synopsis: ctor
  45. //
  46. // Arguments: [rop] - containing object picker instance
  47. //
  48. // History: 06-22-2000 DavidMun Created
  49. //
  50. //---------------------------------------------------------------------------
  51. CCommonQueriesTab::CCommonQueriesTab(
  52. const CObjectPicker &rop):
  53. CAdvancedDlgTab(rop),
  54. m_pfnFindValidCallback(NULL),
  55. m_CallbackLparam(0),
  56. m_flUser(0),
  57. m_fDescriptionIsPrefix(TRUE),
  58. m_fNameIsPrefix(TRUE),
  59. m_cDaysSinceLastLogon(0)
  60. {
  61. TRACE_CONSTRUCTOR(CCommonQueriesTab);
  62. }
  63. //+--------------------------------------------------------------------------
  64. //
  65. // Member: CCommonQueriesTab::~CCommonQueriesTab
  66. //
  67. // Synopsis: dtor
  68. //
  69. // History: 06-22-2000 DavidMun Created
  70. //
  71. //---------------------------------------------------------------------------
  72. CCommonQueriesTab::~CCommonQueriesTab()
  73. {
  74. TRACE_DESTRUCTOR(CCommonQueriesTab);
  75. m_pfnFindValidCallback = NULL;
  76. }
  77. //+--------------------------------------------------------------------------
  78. //
  79. // Member: CCommonQueriesTab::DoModelessDlg
  80. //
  81. // Synopsis: Invoke the common queries subdialog as a child of the
  82. // tab control with window handle [hwndTab].
  83. //
  84. // Arguments: [hwndTab] - handle to parent tab control's window
  85. //
  86. // History: 06-22-2000 DavidMun Created
  87. //
  88. //---------------------------------------------------------------------------
  89. void
  90. CCommonQueriesTab::DoModelessDlg(
  91. HWND hwndTab)
  92. {
  93. TRACE_METHOD(CCommonQueriesTab, DoModelessDlg);
  94. HWND hwndDlg = _DoModelessDlg(hwndTab, IDD_COMMON_QUERIES);
  95. if (!hwndDlg)
  96. {
  97. DBG_OUT_LASTERROR;
  98. }
  99. }
  100. //+--------------------------------------------------------------------------
  101. //
  102. // Member: CCommonQueriesTab::Show
  103. //
  104. // Synopsis: Make the common queries child dialog visible and enable
  105. // its child controls as appropriate
  106. //
  107. // History: 06-22-2000 DavidMun Created
  108. //
  109. //---------------------------------------------------------------------------
  110. void
  111. CCommonQueriesTab::Show() const
  112. {
  113. TRACE_METHOD(CCommonQueriesTab, Show);
  114. ShowWindow(m_hwnd, SW_SHOW);
  115. EnableWindow(m_hwnd, TRUE);
  116. Refresh();
  117. }
  118. //+--------------------------------------------------------------------------
  119. //
  120. // Member: CCommonQueriesTab::Hide
  121. //
  122. // Synopsis: Hide the common queries child dialog and ensure its child
  123. // controls are disabled
  124. //
  125. // History: 06-22-2000 DavidMun Created
  126. //
  127. //---------------------------------------------------------------------------
  128. void
  129. CCommonQueriesTab::Hide() const
  130. {
  131. TRACE_METHOD(CCommonQueriesTab, Hide);
  132. ShowWindow(m_hwnd, SW_HIDE);
  133. _EnableChildControls(FALSE);
  134. EnableWindow(m_hwnd, FALSE);
  135. }
  136. //+--------------------------------------------------------------------------
  137. //
  138. // Member: CCommonQueriesTab::_EnableChildControls
  139. //
  140. // Synopsis: Enable or disable child window controls.
  141. //
  142. // Arguments: [fEnable] - TRUE: enable the child window controls
  143. // FALSE: disable all child controls.
  144. //
  145. // History: 05-11-2000 DavidMun Created
  146. //
  147. //---------------------------------------------------------------------------
  148. void
  149. CCommonQueriesTab::_EnableChildControls(
  150. BOOL fEnable) const
  151. {
  152. const CFilterManager &rfm = m_rop.GetFilterManager();
  153. const CScopeManager &rsm = m_rop.GetScopeManager();
  154. const CScope &rCurScope = rsm.GetCurScope();
  155. //
  156. // If caller wants to disable, or the current scope is invalid or
  157. // downlevel, disable all child controls.
  158. //
  159. if (!fEnable ||
  160. rCurScope.Type() == ST_INVALID ||
  161. IsDownlevel(rCurScope))
  162. {
  163. EnableWindow(_hCtrl(IDC_NAME_LBL), FALSE);
  164. EnableWindow(_hCtrl(IDC_NAME_COMBO), FALSE);
  165. EnableWindow(_hCtrl(IDC_NAME_EDIT), FALSE);
  166. EnableWindow(_hCtrl(IDC_DESCRIPTION_LBL), FALSE);
  167. EnableWindow(_hCtrl(IDC_DESCRIPTION_COMBO), FALSE);
  168. EnableWindow(_hCtrl(IDC_DESCRIPTION_EDIT), FALSE);
  169. EnableWindow(_hCtrl(IDC_DISABLED_CKBOX), FALSE);
  170. EnableWindow(_hCtrl(IDC_NON_EXPIRING_CKBOX), FALSE);
  171. Button_SetCheck(_hCtrl(IDC_DISABLED_CKBOX), FALSE);
  172. Button_SetCheck(_hCtrl(IDC_NON_EXPIRING_CKBOX), FALSE);
  173. Edit_SetText(_hCtrl(IDC_NAME_EDIT), L"");
  174. Edit_SetText(_hCtrl(IDC_DESCRIPTION_EDIT), L"");
  175. EnableWindow(_hCtrl(IDC_LASTLOGON_LBL), FALSE);
  176. EnableWindow(_hCtrl(IDC_LASTLOGON_COMBO), FALSE);
  177. return;
  178. }
  179. //
  180. // Figure out which controls to enable given the look-for and look-in
  181. // selections. Name is always enabled.
  182. //
  183. BOOL fEnableDescription = TRUE;
  184. BOOL fEnableObjectDisabled = TRUE;
  185. BOOL fEnableNonExpPwd = TRUE;
  186. BOOL fEnableLastLogon = TRUE;
  187. ULONG flCur = rfm.GetCurScopeSelectedFilterFlags();
  188. ASSERT(!(flCur & DOWNLEVEL_FILTER_BIT));
  189. ASSERT(flCur);
  190. if (flCur & (ALL_UPLEVEL_INTERNAL_CUSTOMIZER_FILTERS |
  191. DSOP_FILTER_EXTERNAL_CUSTOMIZER))
  192. {
  193. fEnableDescription = FALSE;
  194. fEnableObjectDisabled = FALSE;
  195. fEnableNonExpPwd = FALSE;
  196. fEnableLastLogon = FALSE;
  197. }
  198. if (flCur & (ALL_UPLEVEL_GROUP_FILTERS | DSOP_FILTER_CONTACTS))
  199. {
  200. fEnableObjectDisabled = FALSE;
  201. fEnableNonExpPwd = FALSE;
  202. fEnableLastLogon = FALSE;
  203. }
  204. if (flCur & DSOP_FILTER_COMPUTERS)
  205. {
  206. fEnableNonExpPwd = FALSE;
  207. }
  208. // the lastLogonTimestamp doesn't propagate to GC
  209. if (rCurScope.Type() == ST_GLOBAL_CATALOG)
  210. {
  211. fEnableLastLogon = FALSE;
  212. }
  213. //
  214. // Set enable/disable state of all controls
  215. //
  216. // name
  217. EnableWindow(_hCtrl(IDC_NAME_LBL), TRUE);
  218. EnableWindow(_hCtrl(IDC_NAME_COMBO), TRUE);
  219. EnableWindow(_hCtrl(IDC_NAME_EDIT), TRUE);
  220. Edit_SetText(_hCtrl(IDC_NAME_EDIT), m_strName.c_str());
  221. // description
  222. EnableWindow(_hCtrl(IDC_DESCRIPTION_LBL), fEnableDescription);
  223. EnableWindow(_hCtrl(IDC_DESCRIPTION_COMBO), fEnableDescription);
  224. EnableWindow(_hCtrl(IDC_DESCRIPTION_EDIT), fEnableDescription);
  225. if (fEnableDescription)
  226. {
  227. Edit_SetText(_hCtrl(IDC_DESCRIPTION_EDIT), m_strDescription.c_str());
  228. }
  229. else
  230. {
  231. Edit_SetText(_hCtrl(IDC_DESCRIPTION_EDIT), L"");
  232. }
  233. // non-expiring password
  234. EnableWindow(_hCtrl(IDC_NON_EXPIRING_CKBOX), fEnableNonExpPwd);
  235. if (fEnableNonExpPwd && (m_flUser & UF_DONT_EXPIRE_PASSWD))
  236. {
  237. Button_SetCheck(_hCtrl(IDC_NON_EXPIRING_CKBOX), TRUE);
  238. }
  239. else
  240. {
  241. Button_SetCheck(_hCtrl(IDC_NON_EXPIRING_CKBOX), FALSE);
  242. }
  243. // object disabled
  244. if (!g_fExcludeDisabled)
  245. {
  246. EnableWindow(_hCtrl(IDC_DISABLED_CKBOX), fEnableObjectDisabled);
  247. if (fEnableObjectDisabled && (m_flUser & UF_ACCOUNTDISABLE))
  248. {
  249. Button_SetCheck(_hCtrl(IDC_DISABLED_CKBOX), TRUE);
  250. }
  251. else
  252. {
  253. Button_SetCheck(_hCtrl(IDC_DISABLED_CKBOX), FALSE);
  254. }
  255. }
  256. // last logon
  257. EnableWindow(_hCtrl(IDC_LASTLOGON_LBL), fEnableLastLogon);
  258. EnableWindow(_hCtrl(IDC_LASTLOGON_COMBO), fEnableLastLogon);
  259. }
  260. void
  261. CCommonQueriesTab::Save(
  262. IPersistStream *pstm) const
  263. {
  264. }
  265. void
  266. CCommonQueriesTab::Load(
  267. IPersistStream *pstm)
  268. {
  269. }
  270. //+--------------------------------------------------------------------------
  271. //
  272. // Member: CCommonQueriesTab::GetLdapFilter
  273. //
  274. // Synopsis: Return the LDAP filter specified by the settings of the
  275. // child controls
  276. //
  277. // Returns: LDAP filter
  278. //
  279. // History: 06-22-2000 DavidMun Created
  280. //
  281. // Notes: Filter returned contains the filter specified by current
  282. // Look For and Look In settings, concatenated with a more
  283. // specific filter based on child controls.
  284. //
  285. //---------------------------------------------------------------------------
  286. String
  287. CCommonQueriesTab::GetLdapFilter() const
  288. {
  289. TRACE_METHOD(CCommonQueriesTab, GetLdapFilter);
  290. //
  291. // Get the LDAP filter associated with the current scope. If it's
  292. // empty, return.
  293. //
  294. const CScopeManager &rsm = m_rop.GetScopeManager();
  295. const CScope &rCurScope = rsm.GetCurScope();
  296. const CFilterManager &rfm = m_rop.GetFilterManager();
  297. String strScopeFilter = rfm.GetLdapFilter(m_hwnd, rCurScope);
  298. if (strScopeFilter.empty())
  299. {
  300. return strScopeFilter;
  301. }
  302. //
  303. // Construct the filter based on the dialog control values and
  304. // concatenate it to the scope filter.
  305. //
  306. String strQuery;
  307. if (!m_strName.empty())
  308. {
  309. String strEscaped(m_strName);
  310. LdapEscape(&strEscaped);
  311. if (m_fNameIsPrefix)
  312. {
  313. if (m_strName.find(L'@') != String::npos)
  314. {
  315. strQuery += String::format(c_wzUpnQueryFormat, strEscaped.c_str());
  316. }
  317. else
  318. {
  319. strQuery += String::format(c_wzCnQueryFormat, strEscaped.c_str());
  320. }
  321. }
  322. else
  323. {
  324. if (m_strName.find(L'@') != String::npos)
  325. {
  326. strQuery += String::format(c_wzUpnQueryFormatExact, strEscaped.c_str());
  327. }
  328. else
  329. {
  330. strQuery += String::format(c_wzCnQueryFormatExact, strEscaped.c_str());
  331. }
  332. }
  333. }
  334. if (!m_strDescription.empty())
  335. {
  336. String strEscaped(m_strDescription);
  337. LdapEscape(&strEscaped);
  338. //
  339. // A leading space is not significant inside the ldap filter, so we
  340. // must escape it to get it noticed. We do this only for
  341. // descriptions, not for names, as it seems unlikely that any RDNs
  342. // will have leading spaces.
  343. //
  344. if (strEscaped[0] == L' ')
  345. {
  346. strEscaped.erase(strEscaped.begin());
  347. strEscaped.insert(0, String(L"\\20"));
  348. }
  349. strQuery += L"(description=" + strEscaped;
  350. if (m_fDescriptionIsPrefix)
  351. {
  352. strQuery += L"*";
  353. }
  354. strQuery += L")";
  355. }
  356. if (m_flUser)
  357. {
  358. WCHAR wzUserFlag[20];
  359. strQuery += L"(userAccountControl:" LDAP_MATCHING_RULE_BIT_AND_W;
  360. wsprintf(wzUserFlag, L":=%u", m_flUser);
  361. strQuery += wzUserFlag;
  362. strQuery += L")";
  363. }
  364. if (m_cDaysSinceLastLogon)
  365. {
  366. ULARGE_INTEGER li;
  367. GetCurrentTimeStampMinusInterval(m_cDaysSinceLastLogon, &li);
  368. strQuery += L"(lastLogonTimestamp<=" + UliToStr(li) + L")";
  369. }
  370. if (strQuery.empty())
  371. {
  372. return strScopeFilter;
  373. }
  374. return L"(&" + strScopeFilter + strQuery + L")";
  375. }
  376. //+--------------------------------------------------------------------------
  377. //
  378. // Member: CCommonQueriesTab::GetCustomizerInteraction
  379. //
  380. // Synopsis: Set the interaction the query engine should use
  381. // with the ICustomizeDsBrowser interface.
  382. //
  383. //
  384. // Arguments: [pInteraction] - filled with CUSTINT_* enum
  385. // [pstrCustomizerArg] - if *[pInteraction] is not set to
  386. // CUSTINT_IGNORE_CUSTOM_OBJECTS this
  387. // string is optionally filled with a
  388. // value to give the customizer.
  389. //
  390. // History: 06-22-2000 DavidMun Created
  391. //
  392. //---------------------------------------------------------------------------
  393. void
  394. CCommonQueriesTab::GetCustomizerInteraction(
  395. CUSTOMIZER_INTERACTION *pInteraction,
  396. String *pstrCustomizerArg) const
  397. {
  398. TRACE_METHOD(CCommonQueriesTab, GetCustomizerInteraction);
  399. // set default response
  400. *pInteraction = CUSTINT_IGNORE_CUSTOM_OBJECTS;
  401. ULONG flags = m_rop.GetFilterManager().GetCurScopeSelectedFilterFlags();
  402. if (m_rop.GetExternalCustomizer())
  403. {
  404. if (!(flags & DSOP_FILTER_EXTERNAL_CUSTOMIZER))
  405. {
  406. return;
  407. }
  408. }
  409. else
  410. {
  411. ASSERT(!(flags & DOWNLEVEL_FILTER_BIT));
  412. if (!(flags & (DSOP_FILTER_EXTERNAL_CUSTOMIZER
  413. | ALL_UPLEVEL_INTERNAL_CUSTOMIZER_FILTERS)))
  414. {
  415. return;
  416. }
  417. }
  418. //
  419. // Custom objects will only be included if the only search is on the
  420. // name attribute.
  421. //
  422. if (!m_flUser && m_strDescription.empty())
  423. {
  424. *pstrCustomizerArg = m_strName;
  425. if (m_fNameIsPrefix)
  426. {
  427. *pInteraction = CUSTINT_PREFIX_SEARCH_CUSTOM_OBJECTS;
  428. }
  429. else
  430. {
  431. *pInteraction = CUSTINT_EXACT_SEARCH_CUSTOM_OBJECTS;
  432. }
  433. }
  434. }
  435. //+--------------------------------------------------------------------------
  436. //
  437. // Member: CCommonQueriesTab::Refresh
  438. //
  439. // Synopsis: Enable child windows as appropriate for current Look For
  440. // and Look In settings and update the state of the Find Now
  441. // button.
  442. //
  443. // History: 06-22-2000 DavidMun Created
  444. //
  445. //---------------------------------------------------------------------------
  446. void
  447. CCommonQueriesTab::Refresh() const
  448. {
  449. TRACE_METHOD(CCommonQueriesTab, Refresh);
  450. //
  451. // Enable whichever of the child controls are applicable for the
  452. // current scope and look-in
  453. //
  454. _EnableChildControls(TRUE);
  455. //
  456. // Read all child controls and update the find now button enabled state
  457. //
  458. _ReadChildControls();
  459. _UpdateFindNow();
  460. }
  461. //+--------------------------------------------------------------------------
  462. //
  463. // Member: CCommonQueriesTab::_ReadChildControls
  464. //
  465. // Synopsis: Store the values in the child controls in member variables.
  466. //
  467. // History: 06-22-2000 DavidMun Created
  468. //
  469. //---------------------------------------------------------------------------
  470. void
  471. CCommonQueriesTab::_ReadChildControls() const
  472. {
  473. m_fNameIsPrefix = !ComboBox_GetCurSel(_hCtrl(IDC_NAME_COMBO));
  474. m_fDescriptionIsPrefix = !ComboBox_GetCurSel(_hCtrl(IDC_DESCRIPTION_COMBO));
  475. _ReadEditCtrl(IDC_NAME_EDIT, &m_strName);
  476. m_strName.strip(String::BOTH);
  477. _ReadEditCtrl(IDC_DESCRIPTION_EDIT, &m_strDescription);
  478. m_flUser = 0;
  479. if (IsWindowEnabled(_hCtrl(IDC_DISABLED_CKBOX)) &&
  480. IsDlgButtonChecked(m_hwnd, IDC_DISABLED_CKBOX))
  481. {
  482. m_flUser |= UF_ACCOUNTDISABLE;
  483. }
  484. if (IsWindowEnabled(_hCtrl(IDC_NON_EXPIRING_CKBOX)) &&
  485. IsDlgButtonChecked(m_hwnd, IDC_NON_EXPIRING_CKBOX))
  486. {
  487. m_flUser |= UF_DONT_EXPIRE_PASSWD;
  488. }
  489. }
  490. //+--------------------------------------------------------------------------
  491. //
  492. // Member: CCommonQueriesTab::_UpdateFindNow
  493. //
  494. // Synopsis: Use the Advanced dialog's callback function to set the
  495. // state of the Find Now button.
  496. //
  497. // History: 06-22-2000 DavidMun Created
  498. //
  499. //---------------------------------------------------------------------------
  500. void
  501. CCommonQueriesTab::_UpdateFindNow() const
  502. {
  503. if (!m_pfnFindValidCallback)
  504. {
  505. return;
  506. }
  507. if (IsDownlevel(m_rop.GetScopeManager().GetCurScope()))
  508. {
  509. m_pfnFindValidCallback(TRUE, m_CallbackLparam);
  510. return;
  511. }
  512. const CFilterManager &rfm = m_rop.GetFilterManager();
  513. ULONG flCur = rfm.GetCurScopeSelectedFilterFlags();
  514. flCur &= (ALL_UPLEVEL_GROUP_FILTERS
  515. | ALL_UPLEVEL_INTERNAL_CUSTOMIZER_FILTERS
  516. | DSOP_FILTER_CONTACTS
  517. | DSOP_FILTER_USERS
  518. | DSOP_FILTER_COMPUTERS);
  519. m_pfnFindValidCallback(flCur != 0, m_CallbackLparam);
  520. }
  521. //+--------------------------------------------------------------------------
  522. //
  523. // Member: CCommonQueriesTab::SetFindValidCallback
  524. //
  525. // Synopsis: Store the Advanced dialog's callback.
  526. //
  527. // Arguments: [pfnFindValidCallback] - pointer to callback function
  528. // [lParam] - argument to give it
  529. //
  530. // History: 06-22-2000 DavidMun Created
  531. //
  532. //---------------------------------------------------------------------------
  533. void
  534. CCommonQueriesTab::SetFindValidCallback(
  535. PFN_FIND_VALID pfnFindValidCallback,
  536. LPARAM lParam)
  537. {
  538. m_pfnFindValidCallback = pfnFindValidCallback;
  539. m_CallbackLparam = lParam;
  540. }
  541. //
  542. // LASTLOGON_DAYS - used to initialize the combobox and compute the value
  543. // to query for.
  544. //
  545. struct LASTLOGON_DAYS
  546. {
  547. PCWSTR wzDays;
  548. ULONG ulDays;
  549. };
  550. static LASTLOGON_DAYS s_aLastLogonDays[] =
  551. {
  552. { L"", 0 },
  553. { L"30", 30 },
  554. { L"60", 60 },
  555. { L"90", 90 },
  556. { L"120", 120 },
  557. { L"180", 180 }
  558. };
  559. //+--------------------------------------------------------------------------
  560. //
  561. // Member: CCommonQueriesTab::_OnInit
  562. //
  563. // Synopsis: Initialize the dialog
  564. //
  565. // Arguments: [pfSetFocus] -
  566. //
  567. // Returns: HRESULT
  568. //
  569. // History: 06-22-2000 DavidMun Created
  570. //
  571. //---------------------------------------------------------------------------
  572. HRESULT
  573. CCommonQueriesTab::_OnInit(
  574. BOOL *pfSetFocus)
  575. {
  576. TRACE_METHOD(CCommonQueriesTab, _OnInit);
  577. HRESULT hr = S_OK;
  578. hr = AddStringToCombo(_hCtrl(IDC_NAME_COMBO), IDS_STARTS_WITH);
  579. CHECK_HRESULT(hr);
  580. hr = AddStringToCombo(_hCtrl(IDC_NAME_COMBO), IDS_IS_EXACTLY);
  581. CHECK_HRESULT(hr);
  582. hr = AddStringToCombo(_hCtrl(IDC_DESCRIPTION_COMBO), IDS_STARTS_WITH);
  583. CHECK_HRESULT(hr);
  584. hr = AddStringToCombo(_hCtrl(IDC_DESCRIPTION_COMBO), IDS_IS_EXACTLY);
  585. CHECK_HRESULT(hr);
  586. ULONG i;
  587. for (i = 0; i < ARRAYLEN(s_aLastLogonDays); i++)
  588. {
  589. ComboBox_AddString(_hCtrl(IDC_LASTLOGON_COMBO),
  590. s_aLastLogonDays[i].wzDays);
  591. }
  592. ComboBox_SetCurSel(_hCtrl(IDC_NAME_COMBO), 0);
  593. ComboBox_SetCurSel(_hCtrl(IDC_DESCRIPTION_COMBO), 0);
  594. ComboBox_SetCurSel(_hCtrl(IDC_LASTLOGON_COMBO), 0);
  595. if (g_fExcludeDisabled)
  596. {
  597. EnableWindow(_hCtrl(IDC_DISABLED_CKBOX), FALSE);
  598. ShowWindow(_hCtrl(IDC_DISABLED_CKBOX), SW_HIDE);
  599. }
  600. return hr;
  601. }
  602. //+--------------------------------------------------------------------------
  603. //
  604. // Member: CCommonQueriesTab::_OnCommand
  605. //
  606. // Synopsis: Handle WM_COMMAND messages
  607. //
  608. // Arguments: [wParam] - standard windows
  609. // [lParam] - standard windows
  610. //
  611. // Returns: standard windows
  612. //
  613. // History: 06-22-2000 DavidMun Created
  614. //
  615. //---------------------------------------------------------------------------
  616. BOOL
  617. CCommonQueriesTab::_OnCommand(
  618. WPARAM wParam,
  619. LPARAM lParam)
  620. {
  621. BOOL fNotHandled = FALSE;
  622. switch (LOWORD(wParam))
  623. {
  624. case IDC_NAME_EDIT:
  625. if (HIWORD(wParam) == EN_UPDATE &&
  626. IsWindowEnabled(reinterpret_cast<HWND>(lParam)))
  627. {
  628. _ReadEditCtrl(IDC_NAME_EDIT, &m_strName);
  629. m_strName.strip(String::BOTH);
  630. _UpdateFindNow();
  631. }
  632. break;
  633. case IDC_DESCRIPTION_EDIT:
  634. if (HIWORD(wParam) == EN_UPDATE &&
  635. IsWindowEnabled(reinterpret_cast<HWND>(lParam)))
  636. {
  637. _ReadEditCtrl(IDC_DESCRIPTION_EDIT, &m_strDescription);
  638. _UpdateFindNow();
  639. }
  640. break;
  641. case IDC_DISABLED_CKBOX:
  642. if (IsDlgButtonChecked(m_hwnd, IDC_DISABLED_CKBOX) &&
  643. IsWindowEnabled(reinterpret_cast<HWND>(lParam)))
  644. {
  645. m_flUser |= UF_ACCOUNTDISABLE;
  646. }
  647. else
  648. {
  649. m_flUser &= ~UF_ACCOUNTDISABLE;
  650. }
  651. _UpdateFindNow();
  652. break;
  653. case IDC_NON_EXPIRING_CKBOX:
  654. if (IsDlgButtonChecked(m_hwnd, IDC_NON_EXPIRING_CKBOX) &&
  655. IsWindowEnabled(reinterpret_cast<HWND>(lParam)))
  656. {
  657. m_flUser |= UF_DONT_EXPIRE_PASSWD;
  658. }
  659. else
  660. {
  661. m_flUser &= ~UF_DONT_EXPIRE_PASSWD;
  662. }
  663. _UpdateFindNow();
  664. break;
  665. case IDC_NAME_COMBO:
  666. if (IsWindowEnabled(reinterpret_cast<HWND>(lParam)))
  667. {
  668. m_fNameIsPrefix =
  669. !ComboBox_GetCurSel(reinterpret_cast<HWND>(lParam));
  670. }
  671. break;
  672. case IDC_DESCRIPTION_COMBO:
  673. if (IsWindowEnabled(reinterpret_cast<HWND>(lParam)))
  674. {
  675. m_fDescriptionIsPrefix =
  676. !ComboBox_GetCurSel(reinterpret_cast<HWND>(lParam));
  677. }
  678. break;
  679. case IDC_LASTLOGON_COMBO:
  680. if (IsWindowEnabled(reinterpret_cast<HWND>(lParam)))
  681. {
  682. int iCurSel = ComboBox_GetCurSel(reinterpret_cast<HWND>(lParam));
  683. if (iCurSel != CB_ERR)
  684. {
  685. m_cDaysSinceLastLogon = s_aLastLogonDays[iCurSel].ulDays;
  686. }
  687. else
  688. {
  689. m_cDaysSinceLastLogon = 0;
  690. }
  691. }
  692. break;
  693. default:
  694. fNotHandled = TRUE;
  695. break;
  696. }
  697. return fNotHandled;
  698. }
  699. BOOL
  700. CCommonQueriesTab::_OnNotify(
  701. WPARAM wParam,
  702. LPARAM lParam)
  703. {
  704. return TRUE;
  705. }
  706. //+--------------------------------------------------------------------------
  707. //
  708. // Function: GetCurrentTimeStampMinusInterval
  709. //
  710. // Synopsis: Calculate a value to be used in an LDAP filter for
  711. // querying against the lastLogonTimestamp attribute.
  712. //
  713. // Arguments: [iDays] - number of days in the past to calculate
  714. // [pULI] - filled with current time minus [iDays] days.
  715. //
  716. // History: 06-22-2000 DavidMun Created
  717. //
  718. //---------------------------------------------------------------------------
  719. void
  720. GetCurrentTimeStampMinusInterval(
  721. int iDays,
  722. ULARGE_INTEGER* pULI)
  723. {
  724. ASSERT(pULI);
  725. FILETIME ftCurrent;
  726. GetSystemTimeAsFileTime(&ftCurrent);
  727. pULI->LowPart = ftCurrent.dwLowDateTime;
  728. pULI->HighPart = ftCurrent.dwHighDateTime;
  729. pULI->QuadPart -= ((((ULONGLONG)iDays * 24) * 60) * 60) * 10000000;
  730. }
  731. void
  732. CCommonQueriesTab::_OnHelp(
  733. UINT message,
  734. WPARAM wParam,
  735. LPARAM lParam)
  736. {
  737. TRACE_METHOD(CCommonQueriesTab, _OnHelp);
  738. InvokeWinHelp(message, wParam, lParam, c_wzHelpFilename, s_aulHelpIds);
  739. }