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.

909 lines
24 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998 - 1999
  3. All rights reserved.
  4. Module Name:
  5. locprop.cxx
  6. Abstract:
  7. Server Properties
  8. Author:
  9. Steve Kiraly (SteveKi) 09/08/98
  10. Lazar Ivanov (LazarI) Nov-28-2000 - validation
  11. Revision History:
  12. --*/
  13. #include "precomp.hxx"
  14. #pragma hdrstop
  15. #include <ADsOpenFlags.h>
  16. #include "dsinterf.hxx"
  17. #include "locprop.hxx"
  18. #include "findloc.hxx"
  19. #include "physloc.hxx"
  20. #define INVALID_RESOURCE_ID ((UINT )-1)
  21. TLocationPropertySheetFrontEnd::
  22. TLocationPropertySheetFrontEnd(
  23. IN IShellPropSheetExt *pShellPropSheetExt,
  24. IN LPDATAOBJECT lpdobj,
  25. IN LPFNADDPROPSHEETPAGE lpfnAddPage,
  26. IN LPARAM lParam
  27. ) : _bValid( FALSE ),
  28. _pShellPropSheetExt( pShellPropSheetExt ),
  29. _lpdobj( lpdobj ),
  30. _pLocation( NULL )
  31. {
  32. DBGMSG( DBG_TRACE, ( "TLocationPropertySheetFrontEnd::TLocationPropertySheetFrontEnd\n" ) );
  33. if( AddPropertyPages( lpfnAddPage, lParam ) )
  34. {
  35. _bValid = TRUE;
  36. }
  37. }
  38. TLocationPropertySheetFrontEnd::
  39. ~TLocationPropertySheetFrontEnd(
  40. VOID
  41. )
  42. {
  43. DBGMSG( DBG_TRACE, ( "TLocationPropertySheetFrontEnd::~TLocationPropertySheetFrontEnd\n" ) );
  44. delete _pLocation;
  45. }
  46. BOOL
  47. TLocationPropertySheetFrontEnd::
  48. bValid(
  49. VOID
  50. ) const
  51. {
  52. DBGMSG( DBG_TRACE, ( "TLocationPropertySheetFrontEnd::bValid\n" ) );
  53. return _bValid;
  54. }
  55. HRESULT
  56. TLocationPropertySheetFrontEnd::
  57. Create(
  58. IN OUT TLocationPropertySheetFrontEnd **ppPropertySheet,
  59. IN IShellPropSheetExt *pShellPropSheetExt,
  60. IN LPDATAOBJECT lpdobj,
  61. IN LPFNADDPROPSHEETPAGE lpfnAddPage,
  62. IN LPARAM lParam
  63. )
  64. {
  65. DBGMSG( DBG_TRACE, ( "TLocationPropertySheetFrontEnd::Create\n" ) );
  66. HRESULT hr = S_OK;
  67. *ppPropertySheet = new TLocationPropertySheetFrontEnd (pShellPropSheetExt, lpdobj, lpfnAddPage, lParam);
  68. if (!VALID_PTR(*ppPropertySheet))
  69. {
  70. Destroy (ppPropertySheet);
  71. hr = E_FAIL;
  72. }
  73. return hr;
  74. }
  75. VOID
  76. TLocationPropertySheetFrontEnd::
  77. Destroy(
  78. IN OUT TLocationPropertySheetFrontEnd **ppPropertySheet
  79. )
  80. {
  81. if (*ppPropertySheet)
  82. {
  83. DBGMSG( DBG_TRACE, ( "TLocationPropertySheetFrontEnd::Destroy\n" ) );
  84. delete *ppPropertySheet;
  85. *ppPropertySheet = NULL;
  86. }
  87. }
  88. BOOL
  89. TLocationPropertySheetFrontEnd::
  90. AddPropertyPages(
  91. IN LPFNADDPROPSHEETPAGE lpfnAddPage,
  92. IN LPARAM lParam
  93. )
  94. {
  95. DBGMSG( DBG_TRACE, ( "TLocationPropertySheetFrontEnd::AddPropertyPages\n" ) );
  96. BOOL bRetval = TRUE;
  97. if( bRetval )
  98. {
  99. _pLocation = new TLocationPropertySheet( _pShellPropSheetExt, _lpdobj );
  100. if( VALID_PTR( _pLocation ) )
  101. {
  102. bRetval = CreatePropertyPage( lpfnAddPage, lParam, _pLocation, _pLocation->uGetResourceTemplateID() );
  103. }
  104. }
  105. return bRetval;
  106. }
  107. BOOL
  108. TLocationPropertySheetFrontEnd::
  109. CreatePropertyPage(
  110. IN LPFNADDPROPSHEETPAGE lpfnAddPage,
  111. IN LPARAM lParam,
  112. IN MGenericProp *pPage,
  113. IN UINT Template
  114. )
  115. {
  116. DBGMSG( DBG_TRACE, ( "TLocationPropertySheetFrontEnd::CreatePropertyPage\n" ) );
  117. //
  118. // Ensure the page pointer and page object is valid.
  119. //
  120. BOOL bRetval = VALID_PTR( pPage );
  121. if( bRetval )
  122. {
  123. PROPSHEETPAGE psp = {0};
  124. psp.dwSize = sizeof( psp );
  125. psp.dwFlags = PSP_DEFAULT | PSP_USEREFPARENT | PSP_USECALLBACK | PSP_PREMATURE;
  126. psp.hInstance = ghInst;
  127. psp.pfnDlgProc = MGenericProp::SetupDlgProc;
  128. psp.pfnCallback = MGenericProp::CallbackProc;
  129. psp.pcRefParent = reinterpret_cast<UINT *>( &gcRefThisDll );
  130. psp.pszTemplate = MAKEINTRESOURCE( Template );
  131. psp.lParam = reinterpret_cast<LPARAM>( pPage );
  132. //
  133. // Create the actual page and get the pages handle.
  134. //
  135. HPROPSHEETPAGE hPage = ::CreatePropertySheetPage( &psp );
  136. //
  137. // Add the page to the property sheet.
  138. //
  139. if( hPage && lpfnAddPage( hPage, lParam ) )
  140. {
  141. if( _pShellPropSheetExt )
  142. {
  143. _pShellPropSheetExt->AddRef();
  144. }
  145. }
  146. else
  147. {
  148. //
  149. // We could not add the page, remember to destroy the handle
  150. //
  151. if( hPage )
  152. {
  153. ::DestroyPropertySheetPage (hPage);
  154. }
  155. bRetval = FALSE;
  156. }
  157. }
  158. return bRetval;
  159. }
  160. /********************************************************************
  161. Location property sheet.
  162. ********************************************************************/
  163. TLocationPropertySheet::
  164. TLocationPropertySheet(
  165. IN IShellPropSheetExt *pShellPropSheetExt,
  166. IN IDataObject *pdobj
  167. ) : _pShellPropSheetExt( pShellPropSheetExt ),
  168. _bValid( FALSE ),
  169. _cfDsObjectNames( 0 ),
  170. _pDsObject( NULL ),
  171. _uLocationEditID( INVALID_RESOURCE_ID ),
  172. _uBrowseID( INVALID_RESOURCE_ID ),
  173. _PropertyAccess( kPropertyAccessNone )
  174. {
  175. DBGMSG( DBG_TRACE, ( "TLocationPropertySheet::TLocationPropertySheet\n" ) );
  176. TStatusB bStatus;
  177. //
  178. // Ensure the ds interface object is in a valid state.
  179. //
  180. if( VALID_OBJ( _Ds ) )
  181. {
  182. //
  183. // Initialize the ds object clipboard format.
  184. //
  185. bStatus DBGCHK = InitializeDsObjectClipboardFormat();
  186. if( bStatus )
  187. {
  188. //
  189. // Get the ds object name.
  190. //
  191. bStatus DBGCHK = GetDsObjectNameFromIDataObject( pdobj, _strDsObjectName, _strDsObjectClass );
  192. if( bStatus )
  193. {
  194. DBGMSG( DBG_TRACE, ( "DsObjectName " TSTR "\n", (LPCTSTR)_strDsObjectName ) );
  195. DBGMSG( DBG_TRACE, ( "DsObjectClass " TSTR "\n", (LPCTSTR)_strDsObjectClass ) );
  196. //
  197. // Computer location page will have different resource
  198. // template in order to have different control IDs and
  199. // thereafter different help IDs.
  200. //
  201. _uBrowseID = IDC_BROWSE_PHYSICAL_LOCATION;
  202. if( !_tcsicmp( _strDsObjectClass, gszComputer ) )
  203. {
  204. _uLocationEditID = IDC_PHYSICAL_COMPUTER_LOCATION;
  205. }
  206. else
  207. {
  208. _uLocationEditID = IDC_PHYSICAL_LOCATION;
  209. }
  210. //
  211. // Get the objects interface.
  212. //
  213. bStatus DBGCHK = GetObjectInterface( _strDsObjectName, &_pDsObject );
  214. if( bStatus )
  215. {
  216. //
  217. // Check our current access priviliges. None, Read, Read|Write
  218. //
  219. bStatus DBGCHK = CheckPropertyAccess( gszLocation, _PropertyAccess );
  220. //
  221. // If were able to determine our access and we have at least read
  222. // access then display the property sheet.
  223. //
  224. if( bStatus && ( _PropertyAccess != kPropertyAccessNone ) )
  225. {
  226. //
  227. // If we get here every this is ok, ready to display the page.
  228. //
  229. _bValid = TRUE;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. TLocationPropertySheet::
  237. ~TLocationPropertySheet(
  238. VOID
  239. )
  240. {
  241. DBGMSG( DBG_TRACE, ( "TLocationPropertySheet::~TLocationPropertySheet\n" ) );
  242. //
  243. // Release the adsi interface, if aquired.
  244. //
  245. if( _pDsObject )
  246. {
  247. _pDsObject->Release();
  248. }
  249. }
  250. BOOL
  251. TLocationPropertySheet::
  252. bValid(
  253. VOID
  254. ) const
  255. {
  256. return _bValid;
  257. }
  258. UINT
  259. TLocationPropertySheet::
  260. uGetResourceTemplateID(
  261. VOID
  262. ) const
  263. {
  264. UINT uDefTemplateID = DLG_PRINTER_LOCATION;
  265. //
  266. // Computer location page will have different resource
  267. // template in order to have different control IDs and
  268. // different help IDs.
  269. //
  270. if( !_tcsicmp( _strDsObjectClass, gszComputer ) )
  271. {
  272. uDefTemplateID = DLG_COMPUTER_LOCATION;
  273. }
  274. return uDefTemplateID;
  275. }
  276. VOID
  277. TLocationPropertySheet::
  278. vDestroy(
  279. VOID
  280. )
  281. {
  282. //
  283. // This fuction is called from the property sheet callback when the
  284. // sheet is destroyed.
  285. //
  286. if( _pShellPropSheetExt )
  287. {
  288. _pShellPropSheetExt->Release();
  289. }
  290. }
  291. BOOL
  292. TLocationPropertySheet::
  293. InitializeDsObjectClipboardFormat(
  294. VOID
  295. )
  296. {
  297. //
  298. // If the clipboard format has not been registred then do it now.
  299. //
  300. if( !_cfDsObjectNames )
  301. {
  302. _cfDsObjectNames = RegisterClipboardFormat( CFSTR_DSOBJECTNAMES );
  303. }
  304. return _cfDsObjectNames != 0;
  305. }
  306. BOOL
  307. TLocationPropertySheet::
  308. GetDsObjectNameFromIDataObject(
  309. IN IDataObject *pdobj,
  310. IN TString &strDsObjectName,
  311. IN TString &strDsObjectClass
  312. )
  313. {
  314. HRESULT hr = E_FAIL;
  315. TStatusB bStatus;
  316. if( pdobj )
  317. {
  318. STGMEDIUM stgmedium = { TYMED_HGLOBAL, NULL };
  319. FORMATETC formatetc = { (CLIPFORMAT)_cfDsObjectNames, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
  320. hr = pdobj->GetData(&formatetc, &stgmedium);
  321. if (SUCCEEDED(hr))
  322. {
  323. LPDSOBJECTNAMES pDsObjectNames = reinterpret_cast<LPDSOBJECTNAMES>( stgmedium.hGlobal );
  324. hr = pDsObjectNames ? S_OK : E_FAIL;
  325. if( SUCCEEDED(hr) )
  326. {
  327. if( pDsObjectNames->cItems == 1 )
  328. {
  329. bStatus DBGCHK = strDsObjectName.bUpdate( ByteOffset( pDsObjectNames, pDsObjectNames->aObjects[0].offsetName ) );
  330. if( bStatus )
  331. {
  332. bStatus DBGCHK = strDsObjectClass.bUpdate( ByteOffset( pDsObjectNames, pDsObjectNames->aObjects[0].offsetClass ) );
  333. }
  334. hr = bStatus ? S_OK : E_FAIL;
  335. }
  336. else
  337. {
  338. hr = E_FAIL;
  339. }
  340. }
  341. ReleaseStgMedium(&stgmedium);
  342. }
  343. }
  344. return SUCCEEDED(hr);
  345. }
  346. BOOL
  347. TLocationPropertySheet::
  348. CheckPropertyAccess(
  349. IN LPCTSTR pszPropertyName,
  350. IN EPropertyAccess &Access
  351. )
  352. {
  353. DBGMSG( DBG_TRACE, ( "TLocationPropertySheet::CheckPropertyAccess\n" ) );
  354. //
  355. // Assume no access.
  356. //
  357. Access = kPropertyAccessNone;
  358. //
  359. // Need a directory object interface to query for the effective attributes.
  360. //
  361. IDirectoryObject *pDsObj = NULL;
  362. //
  363. // Get the directory object interface.
  364. //
  365. HRESULT hr = AdminToolsOpenObject( _strDsObjectName,
  366. NULL,
  367. NULL,
  368. ADS_SECURE_AUTHENTICATION,
  369. IID_IDirectoryObject,
  370. reinterpret_cast<LPVOID*>( &pDsObj ) );
  371. if( SUCCEEDED(hr) )
  372. {
  373. DWORD cAttrs = 0;
  374. PADS_ATTR_INFO pAttrs = NULL;
  375. LPCTSTR szNames[2] = {gszName, gszAllowed};
  376. //
  377. // Query for this objects attributes.
  378. //
  379. hr = pDsObj->GetObjectAttributes( (LPTSTR*)szNames, 2, &pAttrs, &cAttrs );
  380. if( SUCCEEDED(hr) )
  381. {
  382. //
  383. // The object was opened and we were able to read the attributes then
  384. // We assume we have read access.
  385. //
  386. Access = kPropertyAccessRead;
  387. for (UINT i = 0; i < cAttrs; i++)
  388. {
  389. DBGMSG( DBG_TRACE, ( "Allowed Name " TSTR "\n", pAttrs[i].pszAttrName ) );
  390. if (!_tcsicmp( pAttrs[i].pszAttrName, gszAllowed ))
  391. {
  392. for (UINT j = 0; j < pAttrs[i].dwNumValues; j++)
  393. {
  394. DBGMSG( DBG_TRACE, ( "Allowed attribute (effective): %d " TSTR "\n", pAttrs[i].pADsValues[j].dwType, pAttrs[i].pADsValues[j].CaseIgnoreString ) );
  395. if (!_tcsicmp( pAttrs[i].pADsValues[j].CaseIgnoreString, gszLocation ))
  396. {
  397. //
  398. // We found the location property in the attribute list,
  399. // by this fact we now know we can write this property.
  400. //
  401. Access = kPropertyAccessWrite;
  402. }
  403. }
  404. }
  405. }
  406. //
  407. // Release the writeable attribute memory.
  408. //
  409. if( pAttrs )
  410. {
  411. FreeADsMem( pAttrs );
  412. }
  413. }
  414. //
  415. // Release the directory object interface.
  416. //
  417. pDsObj->Release();
  418. }
  419. return TRUE;
  420. }
  421. LPTSTR
  422. TLocationPropertySheet::
  423. ByteOffset(
  424. IN LPDSOBJECTNAMES pObject,
  425. IN UINT uOffset
  426. )
  427. {
  428. return reinterpret_cast<LPTSTR>( reinterpret_cast<LPBYTE>( pObject ) + uOffset );
  429. }
  430. BOOL
  431. TLocationPropertySheet::
  432. bHandleMessage(
  433. IN UINT uMsg,
  434. IN WPARAM wParam,
  435. IN LPARAM lParam
  436. )
  437. {
  438. BOOL bRetval;
  439. switch( uMsg )
  440. {
  441. case WM_INITDIALOG:
  442. bRetval = Handle_InitDialog( wParam, lParam );
  443. break;
  444. case WM_COMMAND:
  445. bRetval = Handle_Command( wParam, lParam );
  446. break;
  447. case WM_NOTIFY:
  448. bRetval = Handle_Notify( wParam, lParam );
  449. vSetDlgMsgResult( bRetval );
  450. break;
  451. case WM_HELP:
  452. bRetval = Handle_Help( uMsg, wParam, lParam );
  453. break;
  454. case WM_CONTEXTMENU:
  455. bRetval = Handle_Help( uMsg, wParam, lParam );
  456. break;
  457. default:
  458. bRetval = FALSE;
  459. break;
  460. }
  461. return bRetval;
  462. }
  463. BOOL
  464. TLocationPropertySheet::
  465. Handle_InitDialog(
  466. IN WPARAM wParam,
  467. IN LPARAM lParam
  468. )
  469. {
  470. TStatusB bStatus;
  471. //
  472. // Get the location property from the object. We ignore the return
  473. // value because the Get will fail if the property is not set.
  474. //
  475. bStatus DBGCHK = _Ds.Get( _pDsObject, gszLocation, _strLocation );
  476. //
  477. //
  478. // If we have write access then allow browsing the location tree,
  479. // otherwise disable the button
  480. //
  481. if( (kPropertyAccessWrite != _PropertyAccess) || !TPhysicalLocation::bLocationEnabled() )
  482. {
  483. EnableWindow( GetDlgItem(_hDlg, _uBrowseID), FALSE );
  484. }
  485. //
  486. // Set the location text in the UI.
  487. //
  488. bStatus DBGCHK = bSetEditText( _hDlg, _uLocationEditID, _strLocation );
  489. //
  490. // If we only have read access to the location property then
  491. // set the location edit control to read only.
  492. //
  493. if( _PropertyAccess == kPropertyAccessRead )
  494. {
  495. SendDlgItemMessage( _hDlg, _uLocationEditID, EM_SETREADONLY, TRUE, 0);
  496. }
  497. //
  498. // Set the location limit text.
  499. //
  500. SendDlgItemMessage( _hDlg, _uLocationEditID, EM_SETLIMITTEXT, kPrinterLocationBufMax, 0 );
  501. return TRUE;
  502. }
  503. BOOL
  504. TLocationPropertySheet::
  505. Handle_Help(
  506. IN UINT uMsg,
  507. IN WPARAM wParam,
  508. IN LPARAM lParam
  509. )
  510. {
  511. PrintUIHelp( uMsg, _hDlg, wParam, lParam );
  512. return TRUE;
  513. }
  514. BOOL
  515. TLocationPropertySheet::
  516. Handle_Command(
  517. IN WPARAM wParam,
  518. IN LPARAM lParam
  519. )
  520. {
  521. BOOL bRetval = TRUE;
  522. UINT uID = GET_WM_COMMAND_ID( wParam, lParam );
  523. if( uID == _uLocationEditID )
  524. {
  525. //
  526. // If the user changed the text in the location edit control then
  527. // enable the apply button.
  528. //
  529. if( GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE )
  530. {
  531. PropSheet_Changed( GetParent( _hDlg ), _hDlg );
  532. }
  533. }
  534. else if( uID == _uBrowseID )
  535. {
  536. BrowseLocations ();
  537. }
  538. else
  539. {
  540. bRetval = FALSE;
  541. }
  542. return bRetval;
  543. }
  544. BOOL
  545. TLocationPropertySheet::
  546. Handle_Notify(
  547. IN WPARAM wParam,
  548. IN LPARAM lParam
  549. )
  550. {
  551. BOOL bRetval = TRUE;
  552. LPNMHDR pnmh = (LPNMHDR)lParam;
  553. switch( pnmh->code )
  554. {
  555. case PSN_APPLY:
  556. {
  557. DBGMSG( DBG_TRACE, ( "TLocationPropertySheet::Handle_Notify PSN_APPLY\n" ) );
  558. LPPSHNOTIFY lppsn = (LPPSHNOTIFY )lParam;
  559. TStatusB bStatus;
  560. bStatus DBGNOCHK = TRUE;
  561. //
  562. // Check if we have write access, not much to do if we only have read access.
  563. //
  564. if( _PropertyAccess == kPropertyAccessWrite )
  565. {
  566. UINT u, uLen;
  567. TString strLocation;
  568. bStatus DBGCHK = bGetEditText( _hDlg, _uLocationEditID, strLocation );
  569. // make all separators the same character
  570. strLocation.bReplaceAll( TEXT('\\'), TEXT('/') );
  571. StartOver:
  572. // remove the duplicated separators
  573. uLen = strLocation.uLen();
  574. for( u = 0; (u+1)<uLen; u++ )
  575. {
  576. if( TEXT('/') == strLocation[u] &&
  577. TEXT('/') == strLocation[u+1] )
  578. {
  579. // duplicated separator - delete & start all over
  580. strLocation.bDeleteChar(u);
  581. goto StartOver;
  582. }
  583. }
  584. // remove the leading separator
  585. uLen = strLocation.uLen();
  586. if( uLen && TEXT('/') == strLocation[0] )
  587. {
  588. strLocation.bDeleteChar(0);
  589. }
  590. // remove the trailing separator
  591. uLen = strLocation.uLen();
  592. if( uLen && TEXT('/') == strLocation[uLen-1] )
  593. {
  594. strLocation.bDeleteChar(uLen-1);
  595. }
  596. if( _tcscmp( _strLocation, strLocation ) && bStatus )
  597. {
  598. bStatus DBGCHK = _Ds.Put( _pDsObject, gszLocation, strLocation );
  599. }
  600. if (bStatus)
  601. {
  602. //
  603. // DS put succeeded. Just save the last valid location.
  604. //
  605. _strLocation.bUpdate( strLocation );
  606. //
  607. // Since we may have modified the location - update UI.
  608. //
  609. bSetEditText( _hDlg, _uLocationEditID, strLocation );
  610. }
  611. }
  612. //
  613. // Something failed let the user know.
  614. //
  615. if (!bStatus)
  616. {
  617. //
  618. // If the lParam is true the OK/Close button was used to
  619. // dismiss the dialog. Let the dialog exit in this case.
  620. //
  621. if( lppsn->lParam == TRUE )
  622. {
  623. if( iMessage( _hDlg,
  624. IDS_ERR_LOCATION_PROP_TITLE,
  625. IDS_ERR_WANT_TO_EXIT,
  626. MB_YESNO|MB_ICONSTOP,
  627. kMsgNone,
  628. NULL ) == IDYES )
  629. {
  630. bStatus DBGCHK = TRUE;
  631. }
  632. }
  633. else
  634. {
  635. iMessage( _hDlg,
  636. IDS_ERR_LOCATION_PROP_TITLE,
  637. IDS_ERR_GENERIC,
  638. MB_OK|MB_ICONSTOP,
  639. kMsgGetLastError,
  640. NULL );
  641. }
  642. }
  643. bRetval = bStatus ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE;
  644. break;
  645. }
  646. default:
  647. {
  648. bRetval = FALSE;
  649. break;
  650. }
  651. }
  652. return bRetval;
  653. }
  654. BOOL
  655. TLocationPropertySheet::
  656. GetObjectInterface(
  657. IN LPCTSTR strDsObject,
  658. IN OUT IADs **ppDsObject
  659. )
  660. {
  661. //
  662. // Get the adsi object interface pointer.
  663. //
  664. HRESULT hr = AdminToolsOpenObject( strDsObject,
  665. NULL,
  666. NULL,
  667. ADS_SECURE_AUTHENTICATION,
  668. IID_IADs,
  669. reinterpret_cast<LPVOID*>( ppDsObject ) );
  670. return SUCCEEDED( hr );
  671. }
  672. BOOL
  673. TLocationPropertySheet::
  674. GetDefaultSiteName(
  675. IN TString &strSiteName
  676. )
  677. {
  678. TStatusB bStatus;
  679. //
  680. // Get the current objects site name. If the current
  681. // object is a site object we just read the site name
  682. //
  683. if( !_tcsicmp( _strDsObjectClass, gszSite ) )
  684. {
  685. bStatus DBGCHK = _Ds.Get( _pDsObject, gszName, strSiteName );
  686. }
  687. else if ( !_tcsicmp( _strDsObjectClass, gszSubnet ) )
  688. {
  689. //
  690. // To get the default site name for a subnet object
  691. // we need to build a path to the site object and read the
  692. // the name property from the site.
  693. //
  694. TString strSiteObjectName;
  695. bStatus DBGCHK = _Ds.Get( _pDsObject, gszSiteObject, strSiteObjectName );
  696. if( bStatus )
  697. {
  698. TString strSiteObjectPath;
  699. TString strLDAPPrefix;
  700. //
  701. // Build the site object path.
  702. //
  703. bStatus DBGCHK = _Ds.GetLDAPPrefix( strLDAPPrefix ) &&
  704. strSiteObjectPath.bUpdate( strLDAPPrefix ) &&
  705. strSiteObjectPath.bCat( strSiteObjectName );
  706. if( bStatus )
  707. {
  708. IADs *pDsSiteObject = NULL;
  709. //
  710. // Get the site object interface pointer.
  711. //
  712. bStatus DBGCHK = GetObjectInterface( strSiteObjectPath, &pDsSiteObject );
  713. if( bStatus )
  714. {
  715. //
  716. // Read the site name from the site object.
  717. //
  718. bStatus DBGCHK = _Ds.Get( pDsSiteObject, gszName, strSiteName );
  719. }
  720. if( pDsSiteObject )
  721. {
  722. pDsSiteObject->Release();
  723. }
  724. }
  725. }
  726. bStatus DBGNOCHK = FALSE;
  727. }
  728. else
  729. {
  730. bStatus DBGNOCHK = FALSE;
  731. }
  732. return bStatus;
  733. }
  734. VOID
  735. TLocationPropertySheet::
  736. BrowseLocations(
  737. VOID
  738. )
  739. {
  740. TFindLocDlg *pFindLocDlg = new TFindLocDlg(TFindLocDlg::kLocationShowHelp);
  741. if( VALID_PTR(pFindLocDlg) )
  742. {
  743. TString strLocation;
  744. TStatusB bStatus;
  745. bGetEditText ( _hDlg, _uLocationEditID, strLocation );
  746. bStatus DBGCHK = pFindLocDlg->bDoModal(_hDlg, &strLocation);
  747. if (bStatus)
  748. {
  749. bStatus DBGCHK = pFindLocDlg->bGetLocation(strLocation);
  750. if (bStatus && !strLocation.bEmpty())
  751. {
  752. //
  753. // Check to append a trailing slash
  754. //
  755. UINT uLen = strLocation.uLen();
  756. if( uLen && gchSeparator != static_cast<LPCTSTR>(strLocation)[uLen-1] )
  757. {
  758. static const TCHAR szSepStr[] = { gchSeparator };
  759. bStatus DBGCHK = strLocation.bCat( szSepStr );
  760. }
  761. bStatus DBGCHK = bSetEditText( _hDlg, _uLocationEditID, strLocation );
  762. }
  763. }
  764. }
  765. if( pFindLocDlg )
  766. {
  767. delete pFindLocDlg;
  768. }
  769. }