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.

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