Leaked source code of windows server 2003
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.

721 lines
21 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. } // CServerPropGeneral::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. int hour = 0, min = 0;
  244. hour = m_spinHours.GetPos();
  245. min = m_spinMinutes.GetPos();
  246. if ( hour > HOURS_MAX ) {
  247. m_spinHours.SetPos( HOURS_MAX );
  248. MessageBeep( MB_ICONEXCLAMATION );
  249. }
  250. if ( min > MINUTES_MAX ) {
  251. m_spinMinutes.SetPos( MINUTES_MAX );
  252. MessageBeep( MB_ICONEXCLAMATION );
  253. }
  254. if (( 0 == hour ) && ( 0 == min )) {
  255. m_spinMinutes.SetPos( 1 );
  256. MessageBeep( MB_ICONEXCLAMATION );
  257. }
  258. } // CServerPropGeneral::ValidateRefreshInterval()
  259. void CServerPropGeneral::OnCheckShowBootp()
  260. {
  261. SetDirty(TRUE);
  262. }
  263. /////////////////////////////////////////////////////////////////////////////
  264. // CServerPropAdvanced property page
  265. IMPLEMENT_DYNCREATE(CServerPropAdvanced, CPropertyPageBase)
  266. CServerPropAdvanced::CServerPropAdvanced() : CPropertyPageBase(CServerPropAdvanced::IDD)
  267. {
  268. //{{AFX_DATA_INIT(CServerPropAdvanced)
  269. //}}AFX_DATA_INIT
  270. m_nConflictAttempts = 0;
  271. m_fPathChange = FALSE;
  272. }
  273. CServerPropAdvanced::~CServerPropAdvanced()
  274. {
  275. }
  276. void CServerPropAdvanced::DoDataExchange(CDataExchange* pDX)
  277. {
  278. CPropertyPageBase::DoDataExchange(pDX);
  279. //{{AFX_DATA_MAP(CServerPropAdvanced)
  280. DDX_Control(pDX, IDC_STATIC_CREDENTIALS, m_staticCredentials);
  281. DDX_Control(pDX, IDC_BUTTON_CREDENTIALS, m_buttonCredentials);
  282. DDX_Control(pDX, IDC_BUTTON_BROWSE_BACKUP, m_buttonBrowseBackup);
  283. DDX_Control(pDX, IDC_STATIC_MODIFY_BINDINGS_STRING, m_staticBindings);
  284. DDX_Control(pDX, IDC_BUTTON_BINDINGS, m_buttonBindings);
  285. DDX_Control(pDX, IDC_STATIC_DATABASE, m_staticDatabase);
  286. DDX_Control(pDX, IDC_BUTTON_BROWSE_DATABASE, m_buttonBrowseDatabase);
  287. DDX_Control(pDX, IDC_EDIT_DATABASE_PATH, m_editDatabasePath);
  288. DDX_Control(pDX, IDC_BUTTON_BROWSE_LOG, m_buttonBrowseLog);
  289. DDX_Control(pDX, IDC_EDIT_LOG_PATH, m_editAuditLogPath);
  290. DDX_Control(pDX, IDC_EDIT_BACKUP, m_editBackupPath);
  291. DDX_Control(pDX, IDC_STATIC_LOGFILE, m_staticLogFile);
  292. DDX_Control(pDX, IDC_SPIN_CONFLICT_ATTEMPTS, m_spinConflictAttempts);
  293. DDX_Control(pDX, IDC_EDIT_CONFLICT_ATTEMPTS, m_editConflictAttempts);
  294. //}}AFX_DATA_MAP
  295. }
  296. BEGIN_MESSAGE_MAP(CServerPropAdvanced, CPropertyPageBase)
  297. //{{AFX_MSG_MAP(CServerPropAdvanced)
  298. ON_BN_CLICKED(IDC_BUTTON_BROWSE_DATABASE, OnButtonBrowseDatabase)
  299. ON_BN_CLICKED(IDC_BUTTON_BROWSE_LOG, OnButtonBrowseLog)
  300. ON_EN_CHANGE(IDC_EDIT_CONFLICT_ATTEMPTS, OnChangeEditConflictAttempts)
  301. ON_EN_CHANGE(IDC_EDIT_DATABASE_PATH, OnChangeEditDatabasePath)
  302. ON_EN_CHANGE(IDC_EDIT_LOG_PATH, OnChangeEditLogPath)
  303. ON_BN_CLICKED(IDC_BUTTON_BINDINGS, OnButtonBindings)
  304. ON_BN_CLICKED(IDC_BUTTON_BROWSE_BACKUP, OnButtonBrowseBackup)
  305. ON_EN_CHANGE(IDC_EDIT_BACKUP, OnChangeEditBackup)
  306. ON_BN_CLICKED(IDC_BUTTON_CREDENTIALS, OnButtonCredentials)
  307. //}}AFX_MSG_MAP
  308. END_MESSAGE_MAP()
  309. /////////////////////////////////////////////////////////////////////////////
  310. // CServerPropAdvanced message handlers
  311. BOOL CServerPropAdvanced::OnInitDialog()
  312. {
  313. BOOL fEnable = FALSE;
  314. TCHAR szBuffer[64];
  315. DWORD dwSize = sizeof( szBuffer ) / sizeof( TCHAR );
  316. SPITFSNode spNode;
  317. CDhcpServer * pServer;
  318. DWORD dwError;
  319. CPropertyPageBase::OnInitDialog();
  320. // check to see if this is the local machine. If so, enable the browse buttons
  321. BEGIN_WAIT_CURSOR;
  322. GetMachineName(m_strComputerName);
  323. END_WAIT_CURSOR;
  324. GetComputerName(szBuffer, &dwSize);
  325. if (m_strComputerName.CompareNoCase(szBuffer) == 0)
  326. fEnable = TRUE;
  327. // can only browse for folders if this is the local machine
  328. m_buttonBrowseLog.EnableWindow(fEnable);
  329. m_buttonBrowseDatabase.EnableWindow(fEnable);
  330. m_buttonBrowseBackup.EnableWindow(fEnable);
  331. // enable Bindings button only if server allows bindings..
  332. // also hide the buttons if they are not enabled.
  333. spNode = GetHolder()->GetNode();
  334. pServer = GETHANDLER(CDhcpServer, spNode);
  335. if( FALSE == pServer->FSupportsBindings() ) {
  336. m_buttonBindings.EnableWindow(FALSE);
  337. m_staticBindings.EnableWindow(FALSE);
  338. m_buttonBindings.ShowWindow(SW_HIDE);
  339. m_staticBindings.ShowWindow(SW_HIDE);
  340. }
  341. // enable the appropriate controls based on the server version
  342. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart < DHCP_NT5_VERSION)
  343. {
  344. // changing the audit logging path only available on NT5
  345. m_buttonBrowseLog.EnableWindow(FALSE);
  346. m_staticLogFile.EnableWindow(FALSE);
  347. m_editAuditLogPath.EnableWindow(FALSE);
  348. }
  349. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart < DHCP_NT51_VERSION)
  350. {
  351. // DHCP credentials for Dynamic DNS registrations available on this version.
  352. m_buttonCredentials.EnableWindow(FALSE);
  353. }
  354. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart < DHCP_SP2_VERSION)
  355. {
  356. // conflict detection not available
  357. m_editConflictAttempts.EnableWindow(FALSE);
  358. m_spinConflictAttempts.EnableWindow(FALSE);
  359. }
  360. else
  361. {
  362. m_spinConflictAttempts.SetPos(m_nConflictAttempts);
  363. }
  364. m_spinConflictAttempts.SetRange(0,5);
  365. m_dwSetFlags = 0;
  366. // set the path's
  367. m_editAuditLogPath.SetWindowText(m_strAuditLogPath);
  368. m_editDatabasePath.SetWindowText(m_strDatabasePath);
  369. m_editBackupPath.SetWindowText(m_strBackupPath);
  370. m_fPathChange = FALSE;
  371. SetDirty(FALSE);
  372. return TRUE; // return TRUE unless you set the focus to a control
  373. // EXCEPTION: OCX Property Pages should return FALSE
  374. }
  375. BOOL CServerPropAdvanced::OnApply()
  376. {
  377. UpdateData();
  378. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  379. BOOL fRestartService = FALSE;
  380. if (m_fPathChange)
  381. {
  382. if (AfxMessageBox(IDS_PATH_CHANGE_RESTART_SERVICE, MB_YESNO) == IDYES)
  383. {
  384. fRestartService = TRUE;
  385. }
  386. }
  387. m_nConflictAttempts = m_spinConflictAttempts.GetPos();
  388. m_editAuditLogPath.GetWindowText(m_strAuditLogPath);
  389. m_editDatabasePath.GetWindowText(m_strDatabasePath);
  390. m_editBackupPath.GetWindowText(m_strBackupPath);
  391. BOOL bRet = CPropertyPageBase::OnApply();
  392. if (bRet == FALSE) {
  393. // Something bad happened... grab the error code
  394. // AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  395. ::DhcpMessageBox(GetHolder()->GetError());
  396. }
  397. else {
  398. if (fRestartService) {
  399. SPITFSNode spNode;
  400. SPITFSNode spRootNode;
  401. CDhcpServer *pServer;
  402. SPIConsole spConsole;
  403. spNode = GetHolder()->GetNode();
  404. spNode->GetParent( &spRootNode );
  405. pServer = GETHANDLER( CDhcpServer, spNode );
  406. // Restart the server
  407. pServer->RestartService( spRootNode );
  408. // Refresh the server node
  409. CMTDhcpHandler *pMTHandler = GETHANDLER( CMTDhcpHandler, spNode );
  410. pMTHandler->OnRefresh( spNode, NULL, 0, 0, 0 );
  411. } // if
  412. m_fPathChange = FALSE;
  413. m_dwSetFlags = 0;
  414. } // else
  415. return bRet;
  416. } // CServerPropAdvanced::OnApply()
  417. BOOL CServerPropAdvanced::OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask)
  418. {
  419. SPITFSNode spNode;
  420. CDhcpServer * pServer;
  421. DWORD dwError;
  422. BEGIN_WAIT_CURSOR;
  423. spNode = GetHolder()->GetNode();
  424. pServer = GETHANDLER(CDhcpServer, spNode);
  425. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart >= DHCP_NT5_VERSION) {
  426. // Get all of the parameters so we can just change the audit log path
  427. LPWSTR pAuditLogPath = NULL;
  428. DWORD dwDiskCheckInterval = 0, dwMaxLogFilesSize = 0, dwMinSpaceOnDisk = 0;
  429. dwError = ::DhcpAuditLogGetParams((LPWSTR) pServer->GetIpAddress(),
  430. 0,
  431. &pAuditLogPath,
  432. &dwDiskCheckInterval,
  433. &dwMaxLogFilesSize,
  434. &dwMinSpaceOnDisk);
  435. if (dwError == ERROR_SUCCESS) {
  436. ::DhcpRpcFreeMemory(pAuditLogPath);
  437. dwError = ::DhcpAuditLogSetParams((LPWSTR) pServer->GetIpAddress(),
  438. 0,
  439. (LPWSTR) (LPCTSTR) m_strAuditLogPath,
  440. dwDiskCheckInterval,
  441. dwMaxLogFilesSize,
  442. dwMinSpaceOnDisk);
  443. if (dwError != ERROR_SUCCESS) {
  444. GetHolder()->SetError(dwError);
  445. }
  446. else {
  447. // don't update this until the service is restarted...
  448. //pServer->SetAuditLogPath(m_strAuditLogPath);
  449. }
  450. } // if success
  451. } // if NT5
  452. int nPingRetries = pServer->GetPingRetries();
  453. if (((CServerProperties *) GetHolder())->m_liVersion.QuadPart >= DHCP_SP2_VERSION) {
  454. // only available on NT4 Sp2 and higher
  455. nPingRetries = m_nConflictAttempts;
  456. }
  457. dwError = pServer->SetConfigInfo(pServer->GetAuditLogging(),
  458. nPingRetries, m_strDatabasePath,
  459. m_strBackupPath);
  460. if (dwError != ERROR_SUCCESS) {
  461. GetHolder()->SetError(dwError);
  462. }
  463. END_WAIT_CURSOR;
  464. return FALSE;
  465. } // CServerPropAdvanced::OnPropertyChange()
  466. void CServerPropAdvanced::OnButtonBrowseDatabase()
  467. {
  468. CString strNewPath, strHelpText;
  469. strHelpText.LoadString(IDS_BROWSE_DATABASE_PATH);
  470. UtilGetFolderName(m_strDatabasePath, strHelpText, strNewPath);
  471. if (!strNewPath.IsEmpty() &&
  472. strNewPath.CompareNoCase(m_strDatabasePath) != 0)
  473. {
  474. m_strDatabasePath = strNewPath;
  475. m_editDatabasePath.SetWindowText(strNewPath);
  476. }
  477. }
  478. void CServerPropAdvanced::OnButtonBrowseLog()
  479. {
  480. CString strNewPath, strHelpText;
  481. strHelpText.LoadString(IDS_BROWSE_LOG_PATH);
  482. UtilGetFolderName(m_strAuditLogPath, strHelpText, strNewPath);
  483. if (!strNewPath.IsEmpty() &&
  484. strNewPath.CompareNoCase(m_strAuditLogPath) != 0)
  485. {
  486. m_strAuditLogPath = strNewPath;
  487. m_editAuditLogPath.SetWindowText(m_strAuditLogPath);
  488. SetDirty(TRUE);
  489. }
  490. }
  491. void CServerPropAdvanced::OnButtonBrowseBackup()
  492. {
  493. CString strNewPath, strHelpText;
  494. strHelpText.LoadString(IDS_BACKUP_HELP);
  495. UtilGetFolderName(m_strBackupPath, strHelpText, strNewPath);
  496. if (!strNewPath.IsEmpty() &&
  497. strNewPath.CompareNoCase(m_strBackupPath) != 0)
  498. {
  499. m_strBackupPath = strNewPath;
  500. m_editBackupPath.SetWindowText(m_strBackupPath);
  501. SetDirty(TRUE);
  502. }
  503. }
  504. void CServerPropAdvanced::OnChangeEditConflictAttempts()
  505. {
  506. m_dwSetFlags |= Set_PingRetries;
  507. SetDirty(TRUE);
  508. }
  509. void CServerPropAdvanced::OnChangeEditDatabasePath()
  510. {
  511. m_fPathChange = TRUE;
  512. SetDirty(TRUE);
  513. }
  514. void CServerPropAdvanced::OnChangeEditLogPath()
  515. {
  516. m_fPathChange = TRUE;
  517. SetDirty(TRUE);
  518. }
  519. void CServerPropAdvanced::OnChangeEditBackup()
  520. {
  521. SetDirty(TRUE);
  522. }
  523. DWORD
  524. CServerPropAdvanced::GetMachineName(CString & strName)
  525. {
  526. CString strHostName, strNetbiosName;
  527. DHC_HOST_INFO_STRUCT dhcHostInfo;
  528. ::UtilGetHostInfo(m_dwIp, &dhcHostInfo);
  529. strHostName = dhcHostInfo._chHostName;
  530. strNetbiosName = dhcHostInfo._chNetbiosName;
  531. if (strNetbiosName.IsEmpty())
  532. strName = strHostName;
  533. else
  534. strName = strNetbiosName;
  535. // strip off any periods
  536. int nIndex = strName.Find(_T("."));
  537. if (nIndex > 0)
  538. strName = strName.Left(nIndex);
  539. return ERROR_SUCCESS;
  540. }
  541. void CServerPropAdvanced::OnButtonBindings()
  542. {
  543. SPITFSNode spNode;
  544. CDhcpServer * pServer;
  545. spNode = GetHolder()->GetNode();
  546. pServer = GETHANDLER(CDhcpServer, spNode);
  547. CServerBindings BindingsDialog(pServer);
  548. BindingsDialog.DoModal();
  549. // if there is an error in CServerBindings.OnInitDialog,
  550. // it calls OnCancel, and for some reason loses focus.
  551. // So, regain focus.
  552. SetFocus();
  553. }
  554. void CServerPropAdvanced::OnButtonCredentials()
  555. {
  556. CCredentials dlgCred;
  557. SPITFSNode spNode;
  558. CDhcpServer * pServer;
  559. spNode = GetHolder()->GetNode();
  560. pServer = GETHANDLER(CDhcpServer, spNode);
  561. dlgCred.SetServerIp(pServer->GetIpAddress());
  562. dlgCred.DoModal();
  563. }