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.

752 lines
20 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. servpp.cpp
  7. This file contains the implementation for the server
  8. property page(s).
  9. FILE HISTORY:
  10. */
  11. #include "stdafx.h"
  12. #include "servpp.h"
  13. #include "server.h"
  14. #include "shlobj.h"
  15. #include "service.h"
  16. #include "servbind.h"
  17. #include "cred.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. //
  25. // CServerProperties holder
  26. //
  27. /////////////////////////////////////////////////////////////////////////////
  28. CServerProperties::CServerProperties
  29. (
  30. ITFSNode * pNode,
  31. IComponentData * pComponentData,
  32. ITFSComponentData * pTFSCompData,
  33. LPCTSTR pszSheetName
  34. ) : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  35. {
  36. //ASSERT(pFolderNode == GetContainerNode());
  37. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  38. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  39. m_liVersion.QuadPart = 0;
  40. Assert(pTFSCompData != NULL);
  41. m_spTFSCompData.Set(pTFSCompData);
  42. }
  43. CServerProperties::~CServerProperties()
  44. {
  45. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  46. if (m_liVersion.QuadPart >= DHCP_NT5_VERSION)
  47. {
  48. RemovePageFromList((CPropertyPageBase*) &m_pageDns, FALSE);
  49. }
  50. RemovePageFromList((CPropertyPageBase*) &m_pageAdvanced, FALSE);
  51. }
  52. void
  53. CServerProperties::SetVersion
  54. (
  55. LARGE_INTEGER & liVersion
  56. )
  57. {
  58. m_liVersion = liVersion;
  59. if (m_liVersion.QuadPart >= DHCP_NT5_VERSION)
  60. {
  61. AddPageToList((CPropertyPageBase*) &m_pageDns);
  62. }
  63. AddPageToList((CPropertyPageBase*) &m_pageAdvanced);
  64. }
  65. void
  66. CServerProperties::SetDnsRegistration
  67. (
  68. DWORD dwDynDnsFlags,
  69. DHCP_OPTION_SCOPE_TYPE dhcpOptionType
  70. )
  71. {
  72. m_pageDns.m_dwFlags = dwDynDnsFlags;
  73. m_pageDns.m_dhcpOptionType = dhcpOptionType;
  74. }
  75. /////////////////////////////////////////////////////////////////////////////
  76. //
  77. // CServerPropGeneral property page
  78. //
  79. /////////////////////////////////////////////////////////////////////////////
  80. IMPLEMENT_DYNCREATE(CServerPropGeneral, CPropertyPageBase)
  81. CServerPropGeneral::CServerPropGeneral() : CPropertyPageBase(CServerPropGeneral::IDD)
  82. {
  83. //{{AFX_DATA_INIT(CServerPropGeneral)
  84. m_nAuditLogging = FALSE;
  85. m_nAutoRefresh = FALSE;
  86. m_bShowBootp = FALSE;
  87. //}}AFX_DATA_INIT
  88. m_dwSetFlags = 0;
  89. m_bUpdateStatsRefresh = FALSE;
  90. m_uImage = 0;
  91. }
  92. CServerPropGeneral::~CServerPropGeneral()
  93. {
  94. }
  95. void CServerPropGeneral::DoDataExchange(CDataExchange* pDX)
  96. {
  97. CPropertyPageBase::DoDataExchange(pDX);
  98. //{{AFX_DATA_MAP(CServerPropGeneral)
  99. DDX_Control(pDX, IDC_EDIT_REFRESH_MINUTES, m_editMinutes);
  100. DDX_Control(pDX, IDC_EDIT_REFRESH_HOURS, m_editHours);
  101. DDX_Control(pDX, IDC_SPIN_REFRESH_MINUTES, m_spinMinutes);
  102. DDX_Control(pDX, IDC_SPIN_REFRESH_HOURS, m_spinHours);
  103. DDX_Control(pDX, IDC_CHECK_AUTO_REFRESH, m_checkStatAutoRefresh);
  104. DDX_Control(pDX, IDC_CHECK_AUDIT_LOGGING, m_checkAuditLogging);
  105. DDX_Check(pDX, IDC_CHECK_AUDIT_LOGGING, m_nAuditLogging);
  106. DDX_Check(pDX, IDC_CHECK_AUTO_REFRESH, m_nAutoRefresh);
  107. DDX_Check(pDX, IDC_CHECK_SHOW_BOOTP, m_bShowBootp);
  108. DDX_Text(pDX, IDC_EDIT_REFRESH_MINUTES, m_nMinutes);
  109. DDX_Text(pDX, IDC_EDIT_REFRESH_HOURS, m_nHours);
  110. //}}AFX_DATA_MAP
  111. }
  112. BEGIN_MESSAGE_MAP(CServerPropGeneral, CPropertyPageBase)
  113. //{{AFX_MSG_MAP(CServerPropGeneral)
  114. ON_BN_CLICKED(IDC_CHECK_AUTO_REFRESH, OnCheckAutoRefresh)
  115. ON_BN_CLICKED(IDC_CHECK_AUDIT_LOGGING, OnCheckAuditLogging)
  116. ON_EN_CHANGE(IDC_EDIT_REFRESH_HOURS, OnChangeEditRefreshHours)
  117. ON_EN_CHANGE(IDC_EDIT_REFRESH_MINUTES, OnChangeEditRefreshMinutes)
  118. ON_BN_CLICKED(IDC_CHECK_SHOW_BOOTP, OnCheckShowBootp)
  119. //}}AFX_MSG_MAP
  120. END_MESSAGE_MAP()
  121. /////////////////////////////////////////////////////////////////////////////
  122. // CServerPropGeneral message handlers
  123. BOOL CServerPropGeneral::OnApply()
  124. {
  125. UpdateData();
  126. BOOL bRet = CPropertyPageBase::OnApply();
  127. if (bRet == FALSE)
  128. {
  129. // Something bad happened... grab the error code
  130. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  131. ::DhcpMessageBox(GetHolder()->GetError());
  132. }
  133. else
  134. {
  135. m_dwSetFlags = 0;
  136. }
  137. return bRet;
  138. }
  139. BOOL CServerPropGeneral::OnInitDialog()
  140. {
  141. CPropertyPageBase::OnInitDialog();
  142. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart < DHCP_SP2_VERSION) {
  143. // bootp and audit logging available. Hide the options
  144. // to show bootp and classid
  145. m_checkAuditLogging.EnableWindow(FALSE);
  146. GetDlgItem(IDC_CHECK_SHOW_BOOTP)->ShowWindow(SW_HIDE);
  147. }
  148. m_spinMinutes.SetRange(0, 59);
  149. m_spinHours.SetRange(0, 23);
  150. m_editMinutes.LimitText(2);
  151. m_editHours.LimitText(2);
  152. DWORD dwRefreshInterval = m_dwRefreshInterval;
  153. m_nHours = dwRefreshInterval / MILLISEC_PER_HOUR;
  154. dwRefreshInterval -= m_nHours * MILLISEC_PER_HOUR;
  155. m_nMinutes = dwRefreshInterval / MILLISEC_PER_MINUTE;
  156. m_spinHours.SetPos(m_nHours);
  157. m_spinMinutes.SetPos(m_nMinutes);
  158. OnCheckAutoRefresh();
  159. m_dwSetFlags = 0;
  160. m_bUpdateStatsRefresh = FALSE;
  161. // load the correct icon
  162. for (int i = 0; i < ICON_IDX_MAX; i++)
  163. {
  164. if (g_uIconMap[i][1] == m_uImage)
  165. {
  166. HICON hIcon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(g_uIconMap[i][0]));
  167. if (hIcon)
  168. ((CStatic *) GetDlgItem(IDC_STATIC_ICON))->SetIcon(hIcon);
  169. break;
  170. }
  171. }
  172. SetDirty(FALSE);
  173. return TRUE; // return TRUE unless you set the focus to a control
  174. // EXCEPTION: OCX Property Pages should return FALSE
  175. }
  176. void CServerPropGeneral::OnCheckAutoRefresh()
  177. {
  178. int nCheck = m_checkStatAutoRefresh.GetCheck();
  179. m_editHours.EnableWindow(nCheck);
  180. m_editMinutes.EnableWindow(nCheck);
  181. m_spinHours.EnableWindow(nCheck);
  182. m_spinMinutes.EnableWindow(nCheck);
  183. m_bUpdateStatsRefresh = TRUE;
  184. SetDirty(TRUE);
  185. }
  186. void CServerPropGeneral::OnCheckAuditLogging()
  187. {
  188. m_dwSetFlags |= Set_AuditLogState;
  189. SetDirty(TRUE);
  190. }
  191. BOOL CServerPropGeneral::OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask)
  192. {
  193. SPITFSNode spNode;
  194. SPITFSNode spRootNode;
  195. CDhcpServer *pServer;
  196. DWORD dwError;
  197. BEGIN_WAIT_CURSOR;
  198. spNode = GetHolder()->GetNode();
  199. spNode->GetParent(&spRootNode);
  200. pServer = GETHANDLER(CDhcpServer, spNode);
  201. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart >= DHCP_SP2_VERSION) {
  202. if (m_dwSetFlags) {
  203. dwError = pServer->SetConfigInfo(m_nAuditLogging, pServer->GetPingRetries());
  204. if (dwError != ERROR_SUCCESS) {
  205. GetHolder()->SetError(dwError);
  206. }
  207. }
  208. }
  209. if (m_bUpdateStatsRefresh) {
  210. m_dwRefreshInterval = ( m_nHours * MILLISEC_PER_HOUR ) +
  211. ( m_nMinutes * MILLISEC_PER_MINUTE );
  212. pServer->SetAutoRefresh(spNode, m_nAutoRefresh, m_dwRefreshInterval );
  213. // mark the console as dirty
  214. spRootNode->SetData(TFS_DATA_DIRTY, TRUE);
  215. } // if m_bUpdateStatsRefresh
  216. // hide/show bootp and classid
  217. pServer->ShowNode(spNode, DHCPSNAP_BOOTP_TABLE, m_bShowBootp);
  218. DWORD dwServerOptions = pServer->GetServerOptions();
  219. // update options if they have changed
  220. if (dwServerOptions != pServer->GetServerOptions()) {
  221. pServer->SetServerOptions(dwServerOptions);
  222. // mark the console as dirty
  223. spRootNode->SetData(TFS_DATA_DIRTY, TRUE);
  224. }
  225. END_WAIT_CURSOR;
  226. return FALSE;
  227. } // CServerProperties::OnPropertyChange()
  228. void CServerPropGeneral::OnChangeEditRefreshHours()
  229. {
  230. m_bUpdateStatsRefresh = TRUE;
  231. ValidateRefreshInterval();
  232. SetDirty(TRUE);
  233. }
  234. void CServerPropGeneral::OnChangeEditRefreshMinutes()
  235. {
  236. m_bUpdateStatsRefresh = TRUE;
  237. ValidateRefreshInterval();
  238. SetDirty(TRUE);
  239. }
  240. void CServerPropGeneral::ValidateRefreshInterval()
  241. {
  242. CString strText;
  243. if (IsWindow(m_editHours.GetSafeHwnd()))
  244. {
  245. m_editHours.GetWindowText(strText);
  246. // check to see if the value is greater than the max
  247. if (_ttoi(strText) > HOURS_MAX)
  248. {
  249. LPTSTR pBuf = strText.GetBuffer(5);
  250. _itot(HOURS_MAX, pBuf, 10);
  251. strText.ReleaseBuffer();
  252. m_editHours.SetWindowText(strText);
  253. m_spinHours.SetPos(HOURS_MAX);
  254. MessageBeep(MB_ICONEXCLAMATION);
  255. } // if
  256. } // if
  257. if (IsWindow(m_editMinutes.GetSafeHwnd()))
  258. {
  259. m_editMinutes.GetWindowText(strText);
  260. // check to see if the value is greater than the max
  261. if (_ttoi(strText) > MINUTES_MAX)
  262. {
  263. LPTSTR pBuf = strText.GetBuffer(5);
  264. _itot(MINUTES_MAX, pBuf, 10);
  265. strText.ReleaseBuffer();
  266. m_editMinutes.SetWindowText(strText);
  267. m_spinMinutes.SetPos(MINUTES_MAX);
  268. MessageBeep(MB_ICONEXCLAMATION);
  269. } // if
  270. } // if
  271. } // CServerPropGeneral::ValidateRefreshInterval()
  272. void CServerPropGeneral::OnCheckShowBootp()
  273. {
  274. SetDirty(TRUE);
  275. }
  276. /////////////////////////////////////////////////////////////////////////////
  277. // CServerPropAdvanced property page
  278. IMPLEMENT_DYNCREATE(CServerPropAdvanced, CPropertyPageBase)
  279. CServerPropAdvanced::CServerPropAdvanced() : CPropertyPageBase(CServerPropAdvanced::IDD)
  280. {
  281. //{{AFX_DATA_INIT(CServerPropAdvanced)
  282. //}}AFX_DATA_INIT
  283. m_nConflictAttempts = 0;
  284. m_fPathChange = FALSE;
  285. }
  286. CServerPropAdvanced::~CServerPropAdvanced()
  287. {
  288. }
  289. void CServerPropAdvanced::DoDataExchange(CDataExchange* pDX)
  290. {
  291. CPropertyPageBase::DoDataExchange(pDX);
  292. //{{AFX_DATA_MAP(CServerPropAdvanced)
  293. DDX_Control(pDX, IDC_STATIC_CREDENTIALS, m_staticCredentials);
  294. DDX_Control(pDX, IDC_BUTTON_CREDENTIALS, m_buttonCredentials);
  295. DDX_Control(pDX, IDC_BUTTON_BROWSE_BACKUP, m_buttonBrowseBackup);
  296. DDX_Control(pDX, IDC_STATIC_MODIFY_BINDINGS_STRING, m_staticBindings);
  297. DDX_Control(pDX, IDC_BUTTON_BINDINGS, m_buttonBindings);
  298. DDX_Control(pDX, IDC_STATIC_DATABASE, m_staticDatabase);
  299. DDX_Control(pDX, IDC_BUTTON_BROWSE_DATABASE, m_buttonBrowseDatabase);
  300. DDX_Control(pDX, IDC_EDIT_DATABASE_PATH, m_editDatabasePath);
  301. DDX_Control(pDX, IDC_BUTTON_BROWSE_LOG, m_buttonBrowseLog);
  302. DDX_Control(pDX, IDC_EDIT_LOG_PATH, m_editAuditLogPath);
  303. DDX_Control(pDX, IDC_EDIT_BACKUP, m_editBackupPath);
  304. DDX_Control(pDX, IDC_STATIC_LOGFILE, m_staticLogFile);
  305. DDX_Control(pDX, IDC_SPIN_CONFLICT_ATTEMPTS, m_spinConflictAttempts);
  306. DDX_Control(pDX, IDC_EDIT_CONFLICT_ATTEMPTS, m_editConflictAttempts);
  307. //}}AFX_DATA_MAP
  308. }
  309. BEGIN_MESSAGE_MAP(CServerPropAdvanced, CPropertyPageBase)
  310. //{{AFX_MSG_MAP(CServerPropAdvanced)
  311. ON_BN_CLICKED(IDC_BUTTON_BROWSE_DATABASE, OnButtonBrowseDatabase)
  312. ON_BN_CLICKED(IDC_BUTTON_BROWSE_LOG, OnButtonBrowseLog)
  313. ON_EN_CHANGE(IDC_EDIT_CONFLICT_ATTEMPTS, OnChangeEditConflictAttempts)
  314. ON_EN_CHANGE(IDC_EDIT_DATABASE_PATH, OnChangeEditDatabasePath)
  315. ON_EN_CHANGE(IDC_EDIT_LOG_PATH, OnChangeEditLogPath)
  316. ON_BN_CLICKED(IDC_BUTTON_BINDINGS, OnButtonBindings)
  317. ON_BN_CLICKED(IDC_BUTTON_BROWSE_BACKUP, OnButtonBrowseBackup)
  318. ON_EN_CHANGE(IDC_EDIT_BACKUP, OnChangeEditBackup)
  319. ON_BN_CLICKED(IDC_BUTTON_CREDENTIALS, OnButtonCredentials)
  320. //}}AFX_MSG_MAP
  321. END_MESSAGE_MAP()
  322. /////////////////////////////////////////////////////////////////////////////
  323. // CServerPropAdvanced message handlers
  324. BOOL CServerPropAdvanced::OnInitDialog()
  325. {
  326. BOOL fEnable = FALSE;
  327. TCHAR szBuffer[64];
  328. DWORD dwSize = sizeof( szBuffer ) / sizeof( TCHAR );
  329. SPITFSNode spNode;
  330. CDhcpServer * pServer;
  331. DWORD dwError;
  332. CPropertyPageBase::OnInitDialog();
  333. // check to see if this is the local machine. If so, enable the browse buttons
  334. BEGIN_WAIT_CURSOR;
  335. GetMachineName(m_strComputerName);
  336. END_WAIT_CURSOR;
  337. GetComputerName(szBuffer, &dwSize);
  338. if (m_strComputerName.CompareNoCase(szBuffer) == 0)
  339. fEnable = TRUE;
  340. // can only browse for folders if this is the local machine
  341. m_buttonBrowseLog.EnableWindow(fEnable);
  342. m_buttonBrowseDatabase.EnableWindow(fEnable);
  343. m_buttonBrowseBackup.EnableWindow(fEnable);
  344. // enable Bindings button only if server allows bindings..
  345. // also hide the buttons if they are not enabled.
  346. spNode = GetHolder()->GetNode();
  347. pServer = GETHANDLER(CDhcpServer, spNode);
  348. if( FALSE == pServer->FSupportsBindings() ) {
  349. m_buttonBindings.EnableWindow(FALSE);
  350. m_staticBindings.EnableWindow(FALSE);
  351. m_buttonBindings.ShowWindow(SW_HIDE);
  352. m_staticBindings.ShowWindow(SW_HIDE);
  353. }
  354. // enable the appropriate controls based on the server version
  355. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart < DHCP_NT5_VERSION)
  356. {
  357. // changing the audit logging path only available on NT5
  358. m_buttonBrowseLog.EnableWindow(FALSE);
  359. m_staticLogFile.EnableWindow(FALSE);
  360. m_editAuditLogPath.EnableWindow(FALSE);
  361. }
  362. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart < DHCP_NT51_VERSION)
  363. {
  364. // DHCP credentials for Dynamic DNS registrations available on this version.
  365. m_buttonCredentials.EnableWindow(FALSE);
  366. }
  367. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart < DHCP_SP2_VERSION)
  368. {
  369. // conflict detection not available
  370. m_editConflictAttempts.EnableWindow(FALSE);
  371. m_spinConflictAttempts.EnableWindow(FALSE);
  372. }
  373. else
  374. {
  375. m_spinConflictAttempts.SetPos(m_nConflictAttempts);
  376. }
  377. m_spinConflictAttempts.SetRange(0,5);
  378. m_dwSetFlags = 0;
  379. // set the path's
  380. m_editAuditLogPath.SetWindowText(m_strAuditLogPath);
  381. m_editDatabasePath.SetWindowText(m_strDatabasePath);
  382. m_editBackupPath.SetWindowText(m_strBackupPath);
  383. m_fPathChange = FALSE;
  384. SetDirty(FALSE);
  385. return TRUE; // return TRUE unless you set the focus to a control
  386. // EXCEPTION: OCX Property Pages should return FALSE
  387. }
  388. BOOL CServerPropAdvanced::OnApply()
  389. {
  390. UpdateData();
  391. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  392. BOOL fRestartService = FALSE;
  393. if (m_fPathChange)
  394. {
  395. if (AfxMessageBox(IDS_PATH_CHANGE_RESTART_SERVICE, MB_YESNO) == IDYES)
  396. {
  397. fRestartService = TRUE;
  398. }
  399. }
  400. m_nConflictAttempts = m_spinConflictAttempts.GetPos();
  401. m_editAuditLogPath.GetWindowText(m_strAuditLogPath);
  402. m_editDatabasePath.GetWindowText(m_strDatabasePath);
  403. m_editBackupPath.GetWindowText(m_strBackupPath);
  404. BOOL bRet = CPropertyPageBase::OnApply();
  405. if (bRet == FALSE)
  406. {
  407. // Something bad happened... grab the error code
  408. // AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  409. ::DhcpMessageBox(GetHolder()->GetError());
  410. }
  411. else
  412. {
  413. if (fRestartService)
  414. {
  415. // do this here
  416. DWORD dwErr = 0;
  417. CString strServiceName, strComputerName;
  418. strServiceName.LoadString(IDS_SERVICE_NAME);
  419. dwErr = TFSStopServiceEx(m_strComputerName, _T("dhcpserver"), _T("DHCP Service"), strServiceName);
  420. if (dwErr != ERROR_SUCCESS)
  421. {
  422. Trace1("TFSStopService failed! %d\n", dwErr);
  423. }
  424. dwErr = TFSStartServiceEx(m_strComputerName, _T("dhcpserver"), _T("DHCP Service"), strServiceName);
  425. if (dwErr != ERROR_SUCCESS)
  426. {
  427. Trace1("TFSStartService failed! %d\n", dwErr);
  428. }
  429. }
  430. m_fPathChange = FALSE;
  431. m_dwSetFlags = 0;
  432. }
  433. return bRet;
  434. }
  435. BOOL CServerPropAdvanced::OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask)
  436. {
  437. SPITFSNode spNode;
  438. CDhcpServer * pServer;
  439. DWORD dwError;
  440. BEGIN_WAIT_CURSOR;
  441. spNode = GetHolder()->GetNode();
  442. pServer = GETHANDLER(CDhcpServer, spNode);
  443. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart >= DHCP_NT5_VERSION)
  444. {
  445. // Get all of the parameters so we can just change the audit log path
  446. LPWSTR pAuditLogPath = NULL;
  447. DWORD dwDiskCheckInterval = 0, dwMaxLogFilesSize = 0, dwMinSpaceOnDisk = 0;
  448. dwError = ::DhcpAuditLogGetParams((LPWSTR) pServer->GetIpAddress(),
  449. 0,
  450. &pAuditLogPath,
  451. &dwDiskCheckInterval,
  452. &dwMaxLogFilesSize,
  453. &dwMinSpaceOnDisk);
  454. if (dwError == ERROR_SUCCESS)
  455. {
  456. ::DhcpRpcFreeMemory(pAuditLogPath);
  457. dwError = ::DhcpAuditLogSetParams((LPWSTR) pServer->GetIpAddress(),
  458. 0,
  459. (LPWSTR) (LPCTSTR) m_strAuditLogPath,
  460. dwDiskCheckInterval,
  461. dwMaxLogFilesSize,
  462. dwMinSpaceOnDisk);
  463. if (dwError != ERROR_SUCCESS)
  464. {
  465. GetHolder()->SetError(dwError);
  466. }
  467. else
  468. {
  469. // don't update this until the service is restarted...
  470. //pServer->SetAuditLogPath(m_strAuditLogPath);
  471. }
  472. }
  473. }
  474. int nPingRetries = pServer->GetPingRetries();
  475. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart >= DHCP_SP2_VERSION)
  476. {
  477. // only available on NT4 Sp2 and higher
  478. nPingRetries = m_nConflictAttempts;
  479. }
  480. dwError = pServer->SetConfigInfo(pServer->GetAuditLogging(), nPingRetries, m_strDatabasePath, m_strBackupPath);
  481. if (dwError != ERROR_SUCCESS)
  482. {
  483. GetHolder()->SetError(dwError);
  484. }
  485. END_WAIT_CURSOR;
  486. return FALSE;
  487. }
  488. void CServerPropAdvanced::OnButtonBrowseDatabase()
  489. {
  490. CString strNewPath, strHelpText;
  491. strHelpText.LoadString(IDS_BROWSE_DATABASE_PATH);
  492. UtilGetFolderName(m_strDatabasePath, strHelpText, strNewPath);
  493. if (!strNewPath.IsEmpty() &&
  494. strNewPath.CompareNoCase(m_strDatabasePath) != 0)
  495. {
  496. m_strDatabasePath = strNewPath;
  497. m_editDatabasePath.SetWindowText(strNewPath);
  498. }
  499. }
  500. void CServerPropAdvanced::OnButtonBrowseLog()
  501. {
  502. CString strNewPath, strHelpText;
  503. strHelpText.LoadString(IDS_BROWSE_LOG_PATH);
  504. UtilGetFolderName(m_strAuditLogPath, strHelpText, strNewPath);
  505. if (!strNewPath.IsEmpty() &&
  506. strNewPath.CompareNoCase(m_strAuditLogPath) != 0)
  507. {
  508. m_strAuditLogPath = strNewPath;
  509. m_editAuditLogPath.SetWindowText(m_strAuditLogPath);
  510. SetDirty(TRUE);
  511. }
  512. }
  513. void CServerPropAdvanced::OnButtonBrowseBackup()
  514. {
  515. CString strNewPath, strHelpText;
  516. strHelpText.LoadString(IDS_BACKUP_HELP);
  517. UtilGetFolderName(m_strBackupPath, strHelpText, strNewPath);
  518. if (!strNewPath.IsEmpty() &&
  519. strNewPath.CompareNoCase(m_strBackupPath) != 0)
  520. {
  521. m_strBackupPath = strNewPath;
  522. m_editBackupPath.SetWindowText(m_strBackupPath);
  523. SetDirty(TRUE);
  524. }
  525. }
  526. void CServerPropAdvanced::OnChangeEditConflictAttempts()
  527. {
  528. m_dwSetFlags |= Set_PingRetries;
  529. SetDirty(TRUE);
  530. }
  531. void CServerPropAdvanced::OnChangeEditDatabasePath()
  532. {
  533. m_fPathChange = TRUE;
  534. SetDirty(TRUE);
  535. }
  536. void CServerPropAdvanced::OnChangeEditLogPath()
  537. {
  538. m_fPathChange = TRUE;
  539. SetDirty(TRUE);
  540. }
  541. void CServerPropAdvanced::OnChangeEditBackup()
  542. {
  543. SetDirty(TRUE);
  544. }
  545. DWORD
  546. CServerPropAdvanced::GetMachineName(CString & strName)
  547. {
  548. CString strHostName, strNetbiosName;
  549. DHC_HOST_INFO_STRUCT dhcHostInfo;
  550. ::UtilGetHostInfo(m_dwIp, &dhcHostInfo);
  551. strHostName = dhcHostInfo._chHostName;
  552. strNetbiosName = dhcHostInfo._chNetbiosName;
  553. if (strNetbiosName.IsEmpty())
  554. strName = strHostName;
  555. else
  556. strName = strNetbiosName;
  557. // strip off any periods
  558. int nIndex = strName.Find(_T("."));
  559. if (nIndex > 0)
  560. strName = strName.Left(nIndex);
  561. return ERROR_SUCCESS;
  562. }
  563. void CServerPropAdvanced::OnButtonBindings()
  564. {
  565. SPITFSNode spNode;
  566. CDhcpServer * pServer;
  567. spNode = GetHolder()->GetNode();
  568. pServer = GETHANDLER(CDhcpServer, spNode);
  569. CServerBindings BindingsDialog(pServer);
  570. BindingsDialog.DoModal();
  571. // if there is an error in CServerBindings.OnInitDialog,
  572. // it calls OnCancel, and for some reason loses focus.
  573. // So, regain focus.
  574. SetFocus();
  575. }
  576. void CServerPropAdvanced::OnButtonCredentials()
  577. {
  578. CCredentials dlgCred;
  579. SPITFSNode spNode;
  580. CDhcpServer * pServer;
  581. spNode = GetHolder()->GetNode();
  582. pServer = GETHANDLER(CDhcpServer, spNode);
  583. dlgCred.SetServerIp(pServer->GetIpAddress());
  584. dlgCred.DoModal();
  585. }