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.

708 lines
19 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: rrasqry.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // rrasqry.cpp : implementation file
  11. //
  12. #include "stdafx.h"
  13. #include "qryfrm.h"
  14. #include "rrasqry.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. static UINT g_cfDsObjectNames = 0;
  21. static UINT g_cfDsQueryParams = 0;
  22. static UINT g_cfDsQueryScope = 0;
  23. #define DIR_SEARCH_PAGE_SIZE 256
  24. #define DIR_SEARCH_PAGE_TIME_LIMIT 30
  25. #define CFSTR_DSQUERYSCOPE TEXT("DsQueryScope")
  26. HRESULT RRASDelRouterIdObj(
  27. /*[in]*/LPCWSTR pwszMachineName // DN of the computer object in DS
  28. )
  29. {
  30. HRESULT hr = S_OK;
  31. CComPtr<IADsContainer> spContainer;
  32. CString machineName;
  33. if(!pwszMachineName || *pwszMachineName == 0) // this machine
  34. machineName = GetLocalMachineName();
  35. else
  36. machineName = pwszMachineName;
  37. ASSERT(machineName.GetLength());
  38. if(machineName.GetLength() == 0) return S_FALSE;
  39. // prepare fileter,
  40. // in format
  41. // (&(objectClass=RRASAdministrationConnectionPoint)(distinguishedName=CN=RouterIdentity,CN=*)
  42. CString filter = FILTER_PREFIX;
  43. filter += _T("&");
  44. filter += FILTER_PREFIX;
  45. #if 1 /// use computer to query
  46. filter += ATTR_NAME_OBJECTCLASS;
  47. filter += _T("=");
  48. filter += ATTR_CLASS_COMPUTER;
  49. filter += FILTER_POSTFIX;
  50. filter += FILTER_PREFIX;
  51. filter += ATTR_NAME_CN;
  52. filter += _T("=");
  53. filter += machineName;
  54. #else // user router id of the computer object for query, not found
  55. filter += ATTR_NAME_OBJECTCLASS;
  56. filter += _T("=");
  57. filter += ATTR_CLASS_RRASID;
  58. filter += FILTER_POSTFIX;
  59. filter += FILTER_PREFIX;
  60. filter += ATTR_NAME_DN;
  61. filter += _T("=");
  62. filter += DNPREFIX_ROUTERID;
  63. filter += machineName;
  64. filter += _T(",*");
  65. #endif
  66. filter += FILTER_POSTFIX;
  67. filter += FILTER_POSTFIX;
  68. // end of filter
  69. // Query the routerId Object
  70. // Search Routers under configuration
  71. CComPtr<IADs> spIADs;
  72. CComPtr<IDirectorySearch> spISearch;
  73. CString RIdPath;
  74. BSTR RRASPath = NULL;
  75. CString RRASDNSName;
  76. CComPtr<IADs> spIADsRId;
  77. CComPtr<IADsContainer> spIADsContainerRRAS;
  78. VARIANT var;
  79. CString strSearchScope;
  80. ADS_SEARCH_HANDLE hSrch = NULL;
  81. ADS_SEARCH_COLUMN colDN;
  82. VariantInit(&var);
  83. // retieve the list of EAPTypes in the DS
  84. // get ROOTDSE
  85. // if no scope is specified, search the entire enterprise
  86. CHECK_HR(hr = ADsGetObject(L"LDAP://RootDSE", IID_IADs, (void**)&spIADs));
  87. ASSERT(spIADs.p);
  88. CHECK_HR(hr = spIADs->Get(L"rootDomainNamingContext", &var));
  89. ASSERT(V_BSTR(&var));
  90. strSearchScope = _T("LDAP://");
  91. strSearchScope += V_BSTR(&var);
  92. spIADs.Release();
  93. // Get the scope object
  94. CHECK_HR(hr = ADsGetObject(T2W((LPTSTR)(LPCTSTR)strSearchScope), IID_IDirectorySearch, (void**)&spISearch));
  95. ASSERT(spISearch.p);
  96. {
  97. ADS_SEARCHPREF_INFO s_aSearchPrefs[3];
  98. s_aSearchPrefs[0].dwSearchPref = ADS_SEARCHPREF_PAGED_TIME_LIMIT;
  99. s_aSearchPrefs[0].vValue.dwType = ADSTYPE_INTEGER;
  100. s_aSearchPrefs[0].vValue.Integer = DIR_SEARCH_PAGE_TIME_LIMIT;
  101. s_aSearchPrefs[0].dwStatus = ADS_STATUS_S_OK;
  102. s_aSearchPrefs[1].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
  103. s_aSearchPrefs[1].vValue.dwType = ADSTYPE_INTEGER;
  104. s_aSearchPrefs[1].vValue.Integer = ADS_SCOPE_SUBTREE;
  105. s_aSearchPrefs[1].dwStatus = ADS_STATUS_S_OK;
  106. s_aSearchPrefs[2].dwSearchPref = ADS_SEARCHPREF_CHASE_REFERRALS;
  107. s_aSearchPrefs[2].vValue.dwType = ADSTYPE_BOOLEAN;
  108. s_aSearchPrefs[2].vValue.Boolean = (ADS_BOOLEAN) -1;
  109. s_aSearchPrefs[2].dwStatus = ADS_STATUS_S_OK;
  110. PWSTR s_apwzAttrs[] = { L"distinguishedName" };
  111. CHECK_HR(hr = spISearch->SetSearchPreference(s_aSearchPrefs, ARRAYSIZE(s_aSearchPrefs)));
  112. // do the search
  113. CHECK_HR(hr = spISearch->ExecuteSearch(T2W((LPTSTR)(LPCTSTR)filter),
  114. s_apwzAttrs, ARRAYSIZE(s_apwzAttrs), &hSrch));
  115. ASSERT(hSrch);
  116. do
  117. {
  118. //
  119. // Get the columns for each of the properties we are interested in, if
  120. // we failed to get any of the base properties for the object then lets
  121. // just skip this entry as we cannot build a valid IDLIST for it. The
  122. // properties that we request should be present on all objects.
  123. //
  124. CHECK_HR(hr = spISearch->GetNextRow(hSrch));
  125. if(hr == S_OK) // it might equal to S_ADS_NOMORE_ROWS otherwise
  126. {
  127. CHECK_HR(hr = spISearch->GetColumn(hSrch, s_apwzAttrs[0], &colDN));
  128. RIdPath = _T("LDAP://");
  129. RIdPath += colDN.pADsValues->CaseIgnoreString;
  130. #if 1 //uses computer to query
  131. spIADsContainerRRAS.Release();
  132. CHECK_HR(hr = ADsGetObject(T2W((LPTSTR)(LPCTSTR)RIdPath), IID_IADsContainer, (void**)&spIADsContainerRRAS));
  133. ASSERT(spIADsContainerRRAS.p);
  134. #else // uses routerID to query -- this mothed can not find the object, so changed
  135. spIADsRId.Release();
  136. CHECK_HR(hr = ADsGetObject(T2W((LPTSTR)(LPCTSTR)RIdPath), IID_IADs, (void**)&spIADsRId));
  137. ASSERT(spIADsRId.p);
  138. CHECK_HR(hr = spIADsRId->get_Parent(&RRASPath));
  139. spIADsContainerRRAS.Release();
  140. CHECK_HR(hr = ADsGetObject(RRASPath, IID_IADsContainer, (void**)&spIADsContainerRRAS));
  141. ASSERT(spIADsContainerRRAS.p);
  142. SysFreeString(RRASPath);
  143. RRASPath = NULL;
  144. #endif
  145. VariantClear(&var);
  146. CHECK_HR(hr = spIADsContainerRRAS->Delete(ATTR_CLASS_RRASID, CN_ROUTERID));
  147. }
  148. } while( !FAILED(hr) && hr != S_ADS_NOMORE_ROWS);
  149. }
  150. //
  151. // If there is more than one computer found, ( should not ) and give use a chance to delete one.
  152. L_ERR:
  153. return S_OK;
  154. }
  155. HRESULT RRASOpenQryDlg(
  156. /*[in]*/ CWnd* pParent,
  157. /*[in, out]*/ RRASQryData& QryData
  158. )
  159. {
  160. CDlgSvr dlg(QryData, pParent);
  161. HRESULT hr = S_OK;
  162. if(dlg.DoModal() == IDOK)
  163. {
  164. if(QryData.dwCatFlag == RRAS_QRY_CAT_NT5LDAP)
  165. hr = RRASDSQueryDlg(pParent, QryData);
  166. }
  167. else
  168. hr = S_FALSE;
  169. return hr;
  170. }
  171. HRESULT RRASDSQueryDlg(
  172. /*[in]*/ CWnd* pParent,
  173. /*[in, out]*/ RRASQryData& QryData
  174. )
  175. {
  176. HRESULT hr = S_OK;
  177. CComPtr<ICommonQuery> spCommonQuery;
  178. CComPtr<IDataObject> spDataObject;
  179. FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
  180. STGMEDIUM medium = { TYMED_NULL, NULL, NULL };
  181. DSQUERYINITPARAMS dqip;
  182. OPENQUERYWINDOW oqw;
  183. CHECK_HR(hr = CoInitialize(NULL));
  184. CHECK_HR(hr = CoCreateInstance(CLSID_CommonQuery, NULL, CLSCTX_INPROC_SERVER, IID_ICommonQuery, (LPVOID*)&spCommonQuery));
  185. dqip.cbStruct = sizeof(dqip);
  186. dqip.dwFlags = 0;
  187. dqip.pDefaultScope = NULL;
  188. oqw.cbStruct = sizeof(oqw);
  189. oqw.dwFlags = 0;
  190. oqw.clsidHandler = CLSID_DsQuery;
  191. oqw.pHandlerParameters = &dqip;
  192. oqw.clsidDefaultForm = CLSID_RRASQueryForm;
  193. oqw.dwFlags |= OQWF_OKCANCEL;
  194. dqip.dwFlags |= DSQPF_NOSAVE;
  195. oqw.dwFlags |= OQWF_REMOVEFORMS;
  196. oqw.dwFlags |= OQWF_DEFAULTFORM;
  197. oqw.dwFlags |= OQWF_HIDEMENUS;
  198. oqw.dwFlags |= OQWF_HIDESEARCHUI;
  199. // Now display the dialog, and if we succeeded and get an IDataObject then
  200. // slurp the results into our list view.
  201. hr = spCommonQuery->OpenQueryWindow(pParent->GetSafeHwnd(), &oqw, &spDataObject);
  202. if ( SUCCEEDED(hr) && spDataObject.p )
  203. {
  204. // now get the DSQUERYPARAMS and lets get the filter string
  205. if ( !g_cfDsQueryScope )
  206. g_cfDsQueryScope = RegisterClipboardFormat(CFSTR_DSQUERYSCOPE);
  207. fmte.cfFormat = (CLIPFORMAT) g_cfDsQueryScope;
  208. if ( SUCCEEDED(spDataObject->GetData(&fmte, &medium)) )
  209. {
  210. LPWSTR pScopeStr = (LPWSTR)medium.hGlobal;
  211. QryData.strScope = pScopeStr;
  212. ReleaseStgMedium(&medium);
  213. }
  214. else
  215. QryData.strScope = _T("");
  216. if ( !g_cfDsQueryParams )
  217. g_cfDsQueryParams = RegisterClipboardFormat(CFSTR_DSQUERYPARAMS);
  218. fmte.cfFormat = (CLIPFORMAT) g_cfDsQueryParams;
  219. if ( SUCCEEDED(spDataObject->GetData(&fmte, &medium)) )
  220. {
  221. LPDSQUERYPARAMS pDsQueryParams = (LPDSQUERYPARAMS)medium.hGlobal;
  222. LPWSTR pFilter = (LPTSTR)ByteOffset(pDsQueryParams, pDsQueryParams->offsetQuery);
  223. QryData.strFilter = pFilter;
  224. ReleaseStgMedium(&medium);
  225. }
  226. else
  227. QryData.strFilter = _T("");
  228. }
  229. L_ERR:
  230. CoUninitialize();
  231. return hr;
  232. }
  233. //
  234. // S_OK -- User select OK
  235. // S_FALSE -- User select Cancel
  236. // ERROR:
  237. // DS error, search activeDs.dll
  238. // Win32 erroe
  239. // LDAP error
  240. // General error -- memory, invalid argument ...
  241. HRESULT RRASExecQry(
  242. /*[in]*/ RRASQryData& QryData,
  243. /*[out]*/ DWORD& dwFlags,
  244. /*[out]*/ CStringArray& RRASs
  245. )
  246. {
  247. USES_CONVERSION;
  248. HRESULT hr = S_OK;
  249. switch(QryData.dwCatFlag)
  250. {
  251. case RRAS_QRY_CAT_THIS:
  252. {
  253. CString machine;
  254. RRASs.Add(machine);
  255. break;
  256. }
  257. case RRAS_QRY_CAT_MACHINE:
  258. RRASs.Add(QryData.strFilter);
  259. break;
  260. // NT4 Domain
  261. case RRAS_QRY_CAT_NT4DOMAIN:
  262. {
  263. LPWSTR pDomainName;
  264. SERVER_INFO_100* pServerInfo100 = NULL;
  265. SERVER_INFO_101* pServerInfo101 = NULL;
  266. DWORD dwRead;
  267. DWORD dwTotal;
  268. NET_API_STATUS netret;
  269. dwFlags = RRAS_QRY_RESULT_HOSTNAME;
  270. if(QryData.strScope.IsEmpty())
  271. return E_INVALIDARG;
  272. // Although the API excepts TCHAR it is exclusively UNICODE
  273. if (QryData.strScope.Left(2) != _T("\\\\"))
  274. pDomainName = T2W((LPTSTR)(LPCTSTR)QryData.strScope);
  275. else
  276. pDomainName = T2W((LPTSTR)(LPCTSTR)QryData.strScope + 2);
  277. do
  278. {
  279. CWaitCursor wCursor;
  280. netret = ::NetServerEnum(NULL, 101, (LPBYTE*)&pServerInfo101,
  281. 0xffffffff, &dwRead, &dwTotal, SV_TYPE_DIALIN_SERVER,
  282. pDomainName, NULL);
  283. if(pServerInfo101 && netret == NERR_Success || netret == ERROR_MORE_DATA)
  284. {
  285. PSERVER_INFO_101 pSvInfo101_t = pServerInfo101;
  286. CString serverName;
  287. for (;dwRead > 0; dwRead--, pSvInfo101_t++)
  288. {
  289. // this option should addin all the server in the NT4 domain, not the NT4 servers in the domain
  290. // if(pSvInfo101_t->sv101_version_major == 4)
  291. {
  292. serverName = (LPWSTR)pSvInfo101_t->sv101_name;
  293. RRASs.Add(serverName);
  294. }
  295. }
  296. NetApiBufferFree(pServerInfo101);
  297. }
  298. } while (netret == ERROR_MORE_DATA);
  299. if(netret == NERR_Success)
  300. hr = S_OK;
  301. else
  302. hr = HRESULT_FROM_WIN32(netret);
  303. }
  304. break;
  305. // NT5 LADP Query
  306. case RRAS_QRY_CAT_NT5LDAP:
  307. {
  308. // Search Routers under configuration
  309. CComPtr<IADs> spIADs;
  310. CComPtr<IDirectorySearch> spISearch;
  311. CString RIdPath;
  312. BSTR RRASPath = NULL;
  313. CString RRASDNSName;
  314. CComPtr<IADs> spIADsRId;
  315. CComPtr<IADs> spIADsRRAS;
  316. VARIANT var;
  317. CString strSearchScope;
  318. ADS_SEARCH_HANDLE hSrch = NULL;
  319. ADS_SEARCH_COLUMN colDN;
  320. CWaitCursor cw;
  321. // dwFlags = RRAS_QRY_RESULT_DNSNAME;
  322. dwFlags = RRAS_QRY_RESULT_HOSTNAME;
  323. VariantInit(&var);
  324. // retieve the list of EAPTypes in the DS
  325. // get ROOTDSE
  326. // if no scope is specified, search the entire enterprise
  327. if(QryData.strScope.IsEmpty())
  328. {
  329. CHECK_HR(hr = ADsGetObject(L"LDAP://RootDSE", IID_IADs, (void**)&spIADs));
  330. ASSERT(spIADs.p);
  331. CHECK_HR(hr = spIADs->Get(L"rootDomainNamingContext", &var));
  332. ASSERT(V_BSTR(&var));
  333. strSearchScope = _T("LDAP://");
  334. strSearchScope += V_BSTR(&var);
  335. spIADs.Release();
  336. }
  337. else
  338. strSearchScope = QryData.strScope;
  339. // Get the scope object
  340. CHECK_HR(hr = ADsGetObject(T2W((LPTSTR)(LPCTSTR)strSearchScope), IID_IDirectorySearch, (void**)&spISearch));
  341. ASSERT(spISearch.p);
  342. {
  343. ADS_SEARCHPREF_INFO s_aSearchPrefs[3];
  344. s_aSearchPrefs[0].dwSearchPref = ADS_SEARCHPREF_PAGED_TIME_LIMIT;
  345. s_aSearchPrefs[0].vValue.dwType = ADSTYPE_INTEGER;
  346. s_aSearchPrefs[0].vValue.Integer = DIR_SEARCH_PAGE_TIME_LIMIT;
  347. s_aSearchPrefs[0].dwStatus = ADS_STATUS_S_OK;
  348. s_aSearchPrefs[1].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
  349. s_aSearchPrefs[1].vValue.dwType = ADSTYPE_INTEGER;
  350. s_aSearchPrefs[1].vValue.Integer = ADS_SCOPE_SUBTREE;
  351. s_aSearchPrefs[1].dwStatus = ADS_STATUS_S_OK;
  352. s_aSearchPrefs[2].dwSearchPref = ADS_SEARCHPREF_CHASE_REFERRALS;
  353. s_aSearchPrefs[2].vValue.dwType = ADSTYPE_BOOLEAN;
  354. s_aSearchPrefs[2].vValue.Boolean = (ADS_BOOLEAN) -1;
  355. s_aSearchPrefs[2].dwStatus = ADS_STATUS_S_OK;
  356. PWSTR s_apwzAttrs[] = { L"distinguishedName" };
  357. CHECK_HR(hr = spISearch->SetSearchPreference(s_aSearchPrefs, ARRAYSIZE(s_aSearchPrefs)));
  358. // do the search
  359. CHECK_HR(hr = spISearch->ExecuteSearch(T2W((LPTSTR)(LPCTSTR)QryData.strFilter),
  360. s_apwzAttrs, ARRAYSIZE(s_apwzAttrs), &hSrch));
  361. ASSERT(hSrch);
  362. do
  363. {
  364. //
  365. // Get the columns for each of the properties we are interested in, if
  366. // we failed to get any of the base properties for the object then lets
  367. // just skip this entry as we cannot build a valid IDLIST for it. The
  368. // properties that we request should be present on all objects.
  369. //
  370. CHECK_HR(hr = spISearch->GetNextRow(hSrch));
  371. if(hr == S_OK) // it might equal to S_ADS_NOMORE_ROWS otherwise
  372. {
  373. CHECK_HR(hr = spISearch->GetColumn(hSrch, s_apwzAttrs[0], &colDN));
  374. RIdPath = _T("LDAP://");
  375. RIdPath += colDN.pADsValues->CaseIgnoreString;
  376. spIADsRId.Release();
  377. CHECK_HR(hr = ADsGetObject(T2W((LPTSTR)(LPCTSTR)RIdPath), IID_IADs, (void**)&spIADsRId));
  378. ASSERT(spIADsRId.p);
  379. CHECK_HR(hr = spIADsRId->get_Parent(&RRASPath));
  380. spIADsRRAS.Release();
  381. CHECK_HR(hr = ADsGetObject(RRASPath, IID_IADs, (void**)&spIADsRRAS));
  382. ASSERT(spIADsRRAS.p);
  383. SysFreeString(RRASPath);
  384. RRASPath = NULL;
  385. VariantClear(&var);
  386. // build 1750, this is empty, changed to "name"
  387. // CHECK_HR(hr = spIADsRRAS->Get(L"dNSHostName", &var));
  388. CHECK_HR(hr = spIADsRRAS->Get(L"name", &var));
  389. RRASDNSName = V_BSTR(&var);
  390. if(!RRASDNSName.IsEmpty())
  391. RRASs.Add(RRASDNSName);
  392. }
  393. } while( !FAILED(hr) && hr != S_ADS_NOMORE_ROWS);
  394. }
  395. L_ERR:
  396. if(hSrch)
  397. CHECK_HR(hr = spISearch->CloseSearchHandle(hSrch));
  398. VariantClear(&var);
  399. SysFreeString(RRASPath);
  400. }
  401. break;
  402. default:
  403. hr = E_INVALIDARG;
  404. }
  405. if (FAILED(hr))
  406. DisplayErrorMessage(NULL, hr);
  407. return hr;
  408. }
  409. // S_OK -- User select OK
  410. // ERROR:
  411. // DS error, search activeDs.dll
  412. // Win32 erroe
  413. // LDAP error
  414. // General error -- memory, invalid argument ...
  415. /////////////////////////////////////////////////////////////////////////////
  416. // CDlgSvr dialog
  417. RRASQryData __staticQueryData;
  418. CDlgSvr::CDlgSvr(CWnd* pParent /*=NULL*/)
  419. : m_QueryData(__staticQueryData), CBaseDialog(CDlgSvr::IDD, pParent)
  420. {
  421. Init();
  422. }
  423. CDlgSvr::CDlgSvr(RRASQryData& QueryData, CWnd* pParent /*=NULL*/)
  424. : m_QueryData(QueryData), CBaseDialog(CDlgSvr::IDD, pParent)
  425. {
  426. Init();
  427. }
  428. void CDlgSvr::Init()
  429. {
  430. //{{AFX_DATA_INIT(CDlgSvr)
  431. // NOTE: the ClassWizard will add member initialization here
  432. //}}AFX_DATA_INIT
  433. }
  434. void CDlgSvr::DoDataExchange(CDataExchange* pDX)
  435. {
  436. CBaseDialog::DoDataExchange(pDX);
  437. //{{AFX_DATA_MAP(CDlgSvr)
  438. DDX_Control(pDX, IDC_QRY_EDIT_MACHINE, m_editMachine);
  439. DDX_Control(pDX, IDC_QRY_EDIT_DOMAIN, m_editDomain);
  440. DDX_Control(pDX, IDOK, m_btnNext);
  441. DDX_Radio(pDX, IDC_QRY_RADIO_THIS, m_nRadio);
  442. DDX_Text(pDX, IDC_QRY_EDIT_DOMAIN, m_strDomain);
  443. DDV_MaxChars(pDX, m_strDomain, 256);
  444. if(m_nRadio == 2)
  445. DDV_MinChars(pDX, m_strDomain, 1);
  446. DDX_Text(pDX, IDC_QRY_EDIT_MACHINE, m_strMachine);
  447. DDV_MaxChars(pDX, m_strMachine, 256);
  448. if(m_nRadio == 1)
  449. DDV_MinChars(pDX, m_strMachine, 1);
  450. //}}AFX_DATA_MAP
  451. }
  452. BEGIN_MESSAGE_MAP(CDlgSvr, CBaseDialog)
  453. //{{AFX_MSG_MAP(CDlgSvr)
  454. ON_BN_CLICKED(IDC_QRY_RADIO_ANOTHER, OnRadioAnother)
  455. ON_BN_CLICKED(IDC_QRY_RADIO_NT4, OnRadioNt4)
  456. ON_BN_CLICKED(IDC_QRY_RADIO_NT5, OnRadioNt5)
  457. ON_BN_CLICKED(IDC_QRY_RADIO_THIS, OnRadioThis)
  458. ON_BN_CLICKED(IDOK, OnButtonNext)
  459. //}}AFX_MSG_MAP
  460. END_MESSAGE_MAP()
  461. /////////////////////////////////////////////////////////////////////////////
  462. // CDlgSvr message handlers
  463. void CDlgSvr::OnRadioAnother()
  464. {
  465. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  466. CString str;
  467. str.LoadString(IDS_OK);
  468. m_editMachine.EnableWindow(TRUE);
  469. m_editDomain.EnableWindow(FALSE);
  470. m_btnNext.SetWindowText(str);
  471. }
  472. void CDlgSvr::OnRadioNt4()
  473. {
  474. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  475. CString str;
  476. str.LoadString(IDS_OK);
  477. m_editMachine.EnableWindow(FALSE);
  478. m_editDomain.EnableWindow(TRUE);
  479. m_btnNext.SetWindowText(str);
  480. }
  481. void CDlgSvr::OnRadioNt5()
  482. {
  483. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  484. CString str;
  485. str.LoadString(IDS_NEXT);
  486. m_editMachine.EnableWindow(FALSE);
  487. m_editDomain.EnableWindow(FALSE);
  488. m_btnNext.SetWindowText(str);
  489. }
  490. void CDlgSvr::OnRadioThis()
  491. {
  492. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  493. CString str;
  494. str.LoadString(IDS_OK);
  495. m_editMachine.EnableWindow(FALSE);
  496. m_editDomain.EnableWindow(FALSE);
  497. m_btnNext.SetWindowText(str);
  498. }
  499. void CDlgSvr::OnButtonNext()
  500. {
  501. if(UpdateData(TRUE) == 0) return;
  502. switch(m_nRadio)
  503. {
  504. case 0:
  505. m_QueryData.dwCatFlag = RRAS_QRY_CAT_THIS;
  506. break;
  507. case 1:
  508. m_QueryData.dwCatFlag = RRAS_QRY_CAT_MACHINE;
  509. m_QueryData.strFilter = m_strMachine;
  510. break;
  511. case 2:
  512. m_QueryData.dwCatFlag = RRAS_QRY_CAT_NT4DOMAIN;
  513. m_QueryData.strScope = m_strDomain;
  514. break;
  515. case 3:
  516. m_QueryData.dwCatFlag = RRAS_QRY_CAT_NT5LDAP;
  517. break;
  518. default:
  519. ASSERT(0); // this should not happen
  520. break;
  521. }
  522. EndDialog(IDOK);
  523. }
  524. /////////////////////////////////////////////////////////////////////////////
  525. // CDlgSrv message handlers
  526. /////////////////////////////////////////////////////////////////////////////
  527. // CDlgSvr1 message handlers
  528. BOOL CDlgSvr::OnInitDialog()
  529. {
  530. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  531. BOOL bEnableMachine = FALSE, bEnableDomain = FALSE;
  532. UINT okIDS = IDS_OK;
  533. switch(m_QueryData.dwCatFlag)
  534. {
  535. case RRAS_QRY_CAT_THIS:
  536. m_nRadio = 0;
  537. break;
  538. case RRAS_QRY_CAT_MACHINE:
  539. bEnableMachine = TRUE;
  540. m_strMachine = m_QueryData.strFilter;
  541. m_nRadio = 1;
  542. break;
  543. case RRAS_QRY_CAT_NT4DOMAIN:
  544. bEnableDomain = TRUE;
  545. m_strDomain = m_QueryData.strScope;
  546. m_nRadio = 2;
  547. break;
  548. case RRAS_QRY_CAT_NT5LDAP:
  549. m_nRadio = 3;
  550. okIDS = IDS_NEXT;
  551. break;
  552. default:
  553. m_nRadio = 0;
  554. break;
  555. }
  556. CBaseDialog::OnInitDialog();
  557. CString str;
  558. str.LoadString(okIDS);
  559. m_editMachine.EnableWindow(bEnableMachine);
  560. m_editDomain.EnableWindow(bEnableDomain);
  561. m_btnNext.SetWindowText(str);
  562. return TRUE; // return TRUE unless you set the focus to a control
  563. // EXCEPTION: OCX Property Pages should return FALSE
  564. }