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.

746 lines
27 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000 - 2001.
  5. //
  6. // File: util.h
  7. //
  8. // Contents:
  9. //
  10. // History: 07-26-2001 Hiteshr Created
  11. //
  12. //----------------------------------------------------------------------------
  13. //
  14. //Action items are used to for list controls which manage membership of
  15. //core properties. For ex: membership of group. Items can be
  16. //deleted and added from listbox at any time, but they are added to core
  17. //object only when apply button is pressed. Action item keeps track of action
  18. //to do on each item on Apply.
  19. //
  20. enum ACTION
  21. {
  22. ACTION_NONE,
  23. ACTION_ADD,
  24. ACTION_REMOVE,
  25. ACTION_REMOVED,
  26. };
  27. struct ActionItem
  28. {
  29. ActionItem(CBaseAz* pBaseAz):
  30. m_pMemberAz(pBaseAz),
  31. action(ACTION_NONE)
  32. {}
  33. ~ActionItem()
  34. {
  35. if(m_pMemberAz)
  36. delete m_pMemberAz;
  37. }
  38. CBaseAz* m_pMemberAz;
  39. ACTION action;
  40. };
  41. typedef multimap<const CString*,ActionItem*,ltstr> ActionMap;
  42. VOID
  43. RemoveItemsFromActionMap(ActionMap& map);
  44. //+----------------------------------------------------------------------------
  45. // Function: IsValidStoreType
  46. // Synopsis: Validates Store Type
  47. //-----------------------------------------------------------------------------
  48. BOOL IsValidStoreType(ULONG lStoreType);
  49. //+----------------------------------------------------------------------------
  50. // Function: ValidateStoreTypeAndName
  51. // Synopsis: Validates the user entered AD Store Name
  52. // Arguments: strName: User entered store name to verify
  53. // Returns: TRUE if name is valid else false
  54. //-----------------------------------------------------------------------------
  55. BOOL
  56. ValidateStoreTypeAndName(IN HWND hWnd,
  57. IN LONG ulStoreType,
  58. IN const CString& strName);
  59. //+----------------------------------------------------------------------------
  60. // Function: NameToFormatStoreName
  61. // Synopsis: Converts user entered name to format which core understands
  62. // Arguments: ulStoreType: Type of store
  63. // strName: User entered store name
  64. // bUseLDAP:use LDAP string to format AD name instead msldap
  65. // strFormalName: gets the output ldap name
  66. //-----------------------------------------------------------------------------
  67. void
  68. NameToStoreName(IN LONG ulStoreType,
  69. IN const CString& strName,
  70. IN BOOL bUseLDAP,
  71. OUT CString& strFormalName);
  72. //+----------------------------------------------------------------------------
  73. // Function: AddColumnToListView
  74. // Synopsis: Add Columns to Listview and set column width according to
  75. // percentage specified in the COL_FOR_LV
  76. // Arguments:IN pListCtrl: ListCtrl pointer
  77. // IN pColForLV: Column Infomration Array
  78. //
  79. // Returns:
  80. //-----------------------------------------------------------------------------
  81. VOID
  82. AddColumnToListView(IN CListCtrl* pListCtrl,
  83. IN COL_FOR_LV* pColForLV);
  84. //+----------------------------------------------------------------------------
  85. // Function: BaseAzInListCtrl
  86. // Synopsis: Checks if Object of type eObjectTypeAz named strName is
  87. // in the Listview. If its present, returns
  88. // its index else returns -1.
  89. // Arguments:IN pListCtrl: ListCtrl pointer
  90. // IN strName: string to search for
  91. // IN eObjectTypeAz Compare the object of this type only
  92. //
  93. // Returns: If its present, returns its index else returns -1
  94. //-----------------------------------------------------------------------------
  95. int
  96. BaseAzInListCtrl(IN CListCtrl* pListCtrl,
  97. IN const CString& strName,
  98. IN OBJECT_TYPE_AZ eObjectTypeAz);
  99. //+----------------------------------------------------------------------------
  100. // Function: AddBaseAzFromListToListCtrl
  101. // Synopsis: Take the items from List and Add them to ListCtrl. Doesn't
  102. // add the items which are already in ListCtrl
  103. // Arguments:listBaseAz: List of items
  104. // pListCtrl: ListControl Pointer
  105. // uiFlags : Column Info
  106. // bCheckDuplicate: Check for duplicate items
  107. // Returns: The index of the new item if it is successful; otherwise, -1
  108. // NOTE: Function assume the Order of column is Name, Type and Description
  109. //-----------------------------------------------------------------------------
  110. void
  111. AddBaseAzFromListToListCtrl(IN CList<CBaseAz*, CBaseAz*>& listBaseAz,
  112. IN CListCtrl* pListCtrl,
  113. IN UINT uiFlags,
  114. IN BOOL bCheckDuplicate);
  115. //+----------------------------------------------------------------------------
  116. // Function: AddActionItemFromListToListCtrl
  117. // Synopsis: Take the Actions items from List and Add them to ListCtrl.
  118. // Arguments:listBaseAz: List of items
  119. // pListCtrl: ListControl Pointer
  120. // uiFlags : Column Info
  121. // bCheckDuplicate: Check for duplicate items
  122. // Returns: The index of the new item if it is successful; otherwise, -1
  123. // NOTE: Function assume the Order of column is Name, Type and Description
  124. //-----------------------------------------------------------------------------
  125. void
  126. AddActionItemFromListToListCtrl(IN CList<ActionItem*, ActionItem*>& listActionItem,
  127. IN CListCtrl* pListCtrl,
  128. IN UINT uiFlags,
  129. IN BOOL bCheckDuplicate);
  130. //+----------------------------------------------------------------------------
  131. // Function: AddActionItemFromMapToListCtrl
  132. // Synopsis: Take the Actions items from Map and Add them to ListCtrl.
  133. // Arguments:listBaseAz: List of items
  134. // pListCtrl: ListControl Pointer
  135. // uiFlags : Column Info
  136. // bCheckDuplicate: Check for duplicate items
  137. // Returns: The index of the new item if it is successful; otherwise, -1
  138. // NOTE: Function assume the Order of column is Name, Type and Description
  139. //-----------------------------------------------------------------------------
  140. void
  141. AddActionItemFromMapToListCtrl(IN ActionMap& mapActionItem,
  142. IN CListCtrl* pListCtrl,
  143. IN UINT uiFlags,
  144. IN BOOL bCheckDuplicate);
  145. //+----------------------------------------------------------------------------
  146. // Function: AddActionItemToListCtrl
  147. // Synopsis: Adds a new item to ListCtrl.
  148. // Arguments:pListCtrl: ListControl Pointer
  149. // iIndex: Index at which to Add
  150. // pActionItem: Item to add
  151. // uiFlags: column info
  152. // Returns: The index of the new item if it is successful; otherwise, -1
  153. //-----------------------------------------------------------------------------
  154. int
  155. AddActionItemToListCtrl(IN CListCtrl* pListCtrl,
  156. IN int iIndex,
  157. IN ActionItem* pActionItem,
  158. IN UINT uiFlags);
  159. //+----------------------------------------------------------------------------
  160. // Function: AddBaseAzToListCtrl
  161. // Synopsis: Adds a new item to ListCtrl.
  162. // Arguments:pListCtrl: ListControl Pointer
  163. // iIndex: Index at which to Add
  164. // pBaseAz: Item to add
  165. // uiFlags: column info
  166. // Returns: The index of the new item if it is successful; otherwise, -1
  167. //-----------------------------------------------------------------------------
  168. int
  169. AddBaseAzToListCtrl(IN CListCtrl* pListCtrl,
  170. IN int iIndex,
  171. IN CBaseAz* pBaseAz,
  172. IN UINT uiFlags);
  173. //+----------------------------------------------------------------------------
  174. // Function: EnableButtonIfSelectedInListCtrl
  175. // Synopsis: Enables the button if something is selected in Listctrl
  176. // Arguments:
  177. // Returns: TRUE if Enabled the button, FALSE if didn't.
  178. //-----------------------------------------------------------------------------
  179. BOOL
  180. EnableButtonIfSelectedInListCtrl(IN CListCtrl * pListCtrl,
  181. IN CButton* pButton);
  182. //+----------------------------------------------------------------------------
  183. // Function: DeleteSelectedRows
  184. // Synopsis: Deletes the selected rows
  185. //-----------------------------------------------------------------------------
  186. void
  187. DeleteSelectedRows(IN CListCtrl* pListCtrl);
  188. //+----------------------------------------------------------------------------
  189. // Function: SelectListCtrlItem
  190. // Synopsis: Select the item in List Ctrl and mark it visible
  191. // Arguments:
  192. // Returns:
  193. //-----------------------------------------------------------------------------
  194. void
  195. SelectListCtrlItem(IN CListCtrl* pListCtrl,
  196. IN int iSelected);
  197. //+----------------------------------------------------------------------------
  198. // Synopsis: Empties the list and calls delete on items in list
  199. //-----------------------------------------------------------------------------
  200. template<class T>
  201. VOID RemoveItemsFromList(IN CList<T, T>& list, BOOL bLocalFree = FALSE)
  202. {
  203. while(!list.IsEmpty())
  204. {
  205. if(bLocalFree)
  206. LocalFree(list.RemoveTail());
  207. else
  208. delete list.RemoveTail();
  209. }
  210. }
  211. template<class T>
  212. VOID
  213. EmptyList(IN CList<T, T>& list)
  214. {
  215. while(!list.IsEmpty())
  216. list.RemoveTail();
  217. }
  218. //+----------------------------------------------------------------------------
  219. // Synopsis: Gets long value from Edit box
  220. // Returns: FALSE if edit box is empty. Assumes only numeric can be entered
  221. // in edit box
  222. //-----------------------------------------------------------------------------
  223. BOOL
  224. GetLongValue(CEdit& refEdit, LONG& reflValue, HWND hWnd = NULL);
  225. //+----------------------------------------------------------------------------
  226. // Synopsis: Sets long value in Edit box
  227. // Returns:
  228. //-----------------------------------------------------------------------------
  229. VOID SetLongValue(CEdit* pEdit, LONG lValue);
  230. //+----------------------------------------------------------------------------
  231. // Synopsis: Converts a sid in binary format to a sid in string format
  232. //-----------------------------------------------------------------------------
  233. BOOL
  234. ConvertSidToStringSid(IN PSID Sid,
  235. OUT CString* pstrSid);
  236. //+----------------------------------------------------------------------------
  237. // Synopsis: Converts a sid in string format to sid in binary format
  238. //-----------------------------------------------------------------------------
  239. BOOL
  240. ConvertStringSidToSid(IN const CString& strSid,
  241. OUT PSID *ppSid);
  242. //+----------------------------------------------------------------------------
  243. // Function:GetStringSidFromSidCachecAz
  244. // Synopsis:Gets the string sid from CSidCacheAz object
  245. //-----------------------------------------------------------------------------
  246. BOOL
  247. GetStringSidFromSidCachecAz(CBaseAz* pBaseAz,
  248. CString* pstrStringSid);
  249. //+----------------------------------------------------------------------------
  250. // Function: AddBaseAzItemsFromListCtrlToList
  251. // Synopsis: Add items from ListCtrl to List
  252. //-----------------------------------------------------------------------------
  253. VOID
  254. AddBaseAzItemsFromListCtrlToList(IN CListCtrl* pListCtrl,
  255. OUT CList<CBaseAz*,CBaseAz*>& listBaseAz);
  256. //+----------------------------------------------------------------------------
  257. // Function:GetFileName
  258. // Synopsis:Displays FileOpen dialog box and return file selected by user
  259. // Arguments:hwndOwner : owner window
  260. // bOpen: File must exist
  261. // nIDTitle : title of open dialog box
  262. // pszFilter : filter
  263. // strFileName : gets selected file name
  264. //
  265. //-----------------------------------------------------------------------------
  266. BOOL
  267. GetFileName(IN HWND hwndOwner,
  268. IN BOOL bOpen,
  269. IN int nIDTitle,
  270. IN const CString& strInitFolderPath,
  271. IN LPCTSTR pszFilter,
  272. CString& strFileName);
  273. template<class CObjectAz, class CObjectAzNode>
  274. class AddChildNodes
  275. {
  276. public:
  277. static HRESULT DoEnum(IN CList<CBaseAz*, CBaseAz*>& listAzChildObject,
  278. IN CBaseContainerNode* pContainerNode)
  279. {
  280. HRESULT hr = S_OK;
  281. POSITION pos = listAzChildObject.GetHeadPosition();
  282. for (int i=0;i < listAzChildObject.GetCount();i++)
  283. {
  284. CObjectAz* pObjectAz= dynamic_cast<CObjectAz*>(listAzChildObject.GetNext(pos));
  285. if(pObjectAz)
  286. {
  287. //Create Container/Leaf Node corresponding to CObjectAz
  288. CObjectAzNode* pObjectAzNode =
  289. new CObjectAzNode(pContainerNode->GetComponentDataObject(),
  290. pContainerNode->GetAdminManagerNode(),
  291. pObjectAz);
  292. if(!pObjectAzNode)
  293. {
  294. hr = E_OUTOFMEMORY;
  295. DBG_OUT_HRESULT(hr);
  296. break;
  297. }
  298. VERIFY(pContainerNode->AddChildToList(pObjectAzNode));
  299. }
  300. else
  301. {
  302. ASSERT(FALSE);
  303. hr = E_UNEXPECTED;
  304. break;
  305. }
  306. }
  307. return hr;
  308. }
  309. };
  310. typedef AddChildNodes<CApplicationAz, CApplicationNode> ADD_APPLICATION_FUNCTION;
  311. typedef AddChildNodes<CScopeAz, CScopeNode> ADD_SCOPE_FUNCTION;
  312. typedef AddChildNodes<CRoleAz, CRoleNode> ADD_ROLE_FUNCTION;
  313. typedef AddChildNodes<COperationAz, COperationNode> ADD_OPERATION_FUNCTION;
  314. typedef AddChildNodes<CTaskAz, CTaskNode> ADD_TASK_FUNCTION;
  315. typedef AddChildNodes<CGroupAz, CGroupNode> ADD_GROUP_FUNCTION;
  316. //+----------------------------------------------------------------------------
  317. // Function: AddAzObjectNodesToList
  318. // Synopsis: Adds the nodes for object of type eObjectType to the Container
  319. // node.
  320. // Arguments:IN eObjectType: Type of object
  321. // IN listAzChildObject: List of objects to be added
  322. // IN pContainerNode: Container in snapin to which new nodes will
  323. // be added.
  324. // Returns:
  325. //-----------------------------------------------------------------------------
  326. HRESULT
  327. AddAzObjectNodesToList(IN OBJECT_TYPE_AZ eObjectType,
  328. IN CList<CBaseAz*, CBaseAz*>& listAzChildObject,
  329. IN CBaseContainerNode* pContainerNode);
  330. ////////////////////////////////////////////////////////////////////////////////////
  331. // Theme support
  332. class CThemeContextActivator
  333. {
  334. public:
  335. CThemeContextActivator() : m_ulActivationCookie(0)
  336. {
  337. SHActivateContext (&m_ulActivationCookie);
  338. }
  339. ~CThemeContextActivator()
  340. { SHDeactivateContext (m_ulActivationCookie); }
  341. private:
  342. ULONG_PTR m_ulActivationCookie;
  343. };
  344. //
  345. //Error Handling
  346. //
  347. VOID
  348. vFormatString(CString &strOutput, UINT nIDPrompt, va_list *pargs);
  349. VOID
  350. FormatString(CString &strOutput, UINT nIDPrompt, ...);
  351. int DisplayMessageBox(HWND hWnd,
  352. const CString& strMessage,
  353. UINT uStyle);
  354. VOID
  355. GetSystemError(CString &strOutput, DWORD dwErr);
  356. void DisplayError(HWND hWnd, UINT nIDPrompt, ...);
  357. void
  358. DisplayInformation(HWND hWnd, UINT nIDPrompt, ...);
  359. int DisplayConfirmation(HWND hwnd,
  360. UINT nIDPrompt,
  361. ...);
  362. void
  363. DisplayWarning(HWND hWnd, UINT nIDPrompt, ...);
  364. BOOL
  365. IsDeleteConfirmed(HWND hwndOwner,
  366. CBaseAz& refBaseAz);
  367. //
  368. //This struct maps the common error messages for each object type
  369. //
  370. struct ErrorMap
  371. {
  372. OBJECT_TYPE_AZ eObjectType;
  373. UINT idObjectType;
  374. UINT idNameAlreadyExist;
  375. UINT idInvalidName;
  376. LPWSTR pszInvalidChars;
  377. };
  378. ErrorMap *GetErrorMap(OBJECT_TYPE_AZ eObjectType);
  379. //+----------------------------------------------------------------------------
  380. // Function: GetLSAConnection
  381. // Synopsis: Wrapper for LsaOpenPolicy
  382. //-----------------------------------------------------------------------------
  383. LSA_HANDLE
  384. GetLSAConnection(IN const CString& strServer,
  385. IN DWORD dwAccessDesired);
  386. //+----------------------------------------------------------------------------
  387. // Function:CompareBaseAzObjects
  388. // Synopsis:Compares two baseaz objects for equivalance. If two pAzA and pAzB
  389. // are two different instances of same coreaz object, they are equal
  390. //-----------------------------------------------------------------------------
  391. BOOL
  392. CompareBaseAzObjects(CBaseAz* pAzA, CBaseAz* pAzB);
  393. //+----------------------------------------------------------------------------
  394. // Function: OpenCreateAdminManager
  395. // Synopsis: Open an existing an existing Authorization Store or
  396. // creates a new Authorization Store and adds corresponding
  397. // AdminManager object to snapin
  398. // Arguments:IN hWnd: Handle of window for dialog box
  399. // IN bNew: If True create a new Authz store else open existing
  400. // one
  401. // IN bOpenFromSavedConsole: This is valid when bNew is False.
  402. // True if open is in resopnse to a console file.
  403. // IN lStoreType: XML or AD
  404. // IN strName: Name of store
  405. // IN strDesc: Description. Only valid in case of new
  406. // IN strScriptDir : Script directory
  407. // IN pRootData: Snapin Rootdata
  408. // IN pComponentData: ComponentData
  409. // Returns:
  410. //-----------------------------------------------------------------------------
  411. HRESULT OpenCreateAdminManager(IN BOOL bNew,
  412. IN BOOL bOpenFromSavedConsole,
  413. IN ULONG lStoreType,
  414. IN const CString& strStoreName,
  415. IN const CString& strDesc,
  416. IN const CString& strScriptDir,
  417. IN CRootData* pRootData,
  418. IN CComponentDataObject* pComponentData);
  419. //+----------------------------------------------------------------------------
  420. // Function: OpenAdminManager
  421. // Synopsis: Open an existing an existing Authorization Store adds
  422. // corresponding adminManager object to snapin
  423. // Arguments:IN hWnd: Handle of window for dialog box
  424. // IN bOpenFromSavedConsole: True if open is in resopnse to a console
  425. // file.
  426. // IN lStoreType: XML or AD
  427. // IN strName: Name of store
  428. // IN strScriptDir : Script directory
  429. // IN pRootData: Snapin Rootdata
  430. // IN pComponentData: ComponentData
  431. // Returns:
  432. //-----------------------------------------------------------------------------
  433. HRESULT OpenAdminManager(IN HWND hWnd,
  434. IN BOOL bOpenFromSavedConsole,
  435. IN ULONG lStoreType,
  436. IN const CString& strStoreName,
  437. IN const CString& strStoreDir,
  438. IN CRootData* pRootData,
  439. IN CComponentDataObject* pComponentData);
  440. //+----------------------------------------------------------------------------
  441. // Function:GetADContainerPath
  442. // Synopsis:Displays a dialog box to allow for selecting a AD container
  443. //-----------------------------------------------------------------------------
  444. BOOL
  445. GetADContainerPath(HWND hWndOwner,
  446. ULONG nIDCaption,
  447. ULONG nIDTitle,
  448. CString& strPath,
  449. CADInfo& refAdInfo);
  450. BOOL FindDialogContextTopic(/*IN*/UINT nDialogID,
  451. /*IN*/DWORD_PTR* pMap);
  452. //+----------------------------------------------------------------------------
  453. // Function:CanReadOneProperty
  454. // Synopsis:Function tries to read IsWriteable property. If that fails displays
  455. // an error message. This is used before adding property pages.
  456. // if we cannot read IsWritable property,thereisn't much hope.
  457. //-----------------------------------------------------------------------------
  458. BOOL
  459. CanReadOneProperty(LPCWSTR pszName,
  460. CBaseAz* pBaseAz);
  461. struct CompareInfo
  462. {
  463. BOOL bActionItem;
  464. UINT uiFlags;
  465. int iColumn;
  466. int iSortDirection;
  467. };
  468. //+----------------------------------------------------------------------------
  469. // Function: ListCompareProc
  470. // Synopsis: Comparison function used by list control
  471. //-----------------------------------------------------------------------------
  472. int CALLBACK
  473. ListCompareProc(LPARAM lParam1,
  474. LPARAM lParam2,
  475. LPARAM lParamSort);
  476. //+----------------------------------------------------------------------------
  477. // Function:SortListControl
  478. // Synopsis:Sorts a list control
  479. // Arguments:pListCtrl: List control to sort
  480. // iColumnClicked: column clicked
  481. // iSortDirection: direction in which to sort
  482. // uiFlags: column info
  483. // bActionItem: if item in list is actionitem
  484. //-----------------------------------------------------------------------------
  485. void
  486. SortListControl(CListCtrl* pListCtrl,
  487. int ColumnClicked,
  488. int SortDirection,
  489. UINT uiFlags,
  490. BOOL bActionItem);
  491. //+----------------------------------------------------------------------------
  492. // Synopsis: Ensures that selection in listview control is visible
  493. //-----------------------------------------------------------------------------
  494. void
  495. EnsureListViewSelectionIsVisible(CListCtrl *pListCtrl);
  496. //+----------------------------------------------------------------------------
  497. // Synopsis:Convert input number in string format to long. if number is out
  498. // of range displays a message.
  499. //-----------------------------------------------------------------------------
  500. BOOL
  501. ConvertStringToLong(LPCWSTR pszInput,
  502. long &reflongOutput,
  503. HWND hWnd = NULL);
  504. VOID
  505. SetSel(CEdit& refEdit);
  506. void
  507. TrimWhiteSpace(CString& str);
  508. //+----------------------------------------------------------------------------
  509. // Function:LoadIcons
  510. // Synopsis:Adds icons to imagelist
  511. //-----------------------------------------------------------------------------
  512. HRESULT
  513. LoadIcons(LPIMAGELIST pImageList);
  514. //+----------------------------------------------------------------------------
  515. // Function: LoadImageList
  516. // Synopsis: Loads image list
  517. //-----------------------------------------------------------------------------
  518. HIMAGELIST
  519. LoadImageList(HINSTANCE hInstance, LPCTSTR pszBitmapID);
  520. //+----------------------------------------------------------------------------
  521. // Function:BrowseAdStores
  522. // Synopsis:Displays a dialog box with list of AD stores available.
  523. // Arguments:strDN: Gets the selected ad store name
  524. //-----------------------------------------------------------------------------
  525. void
  526. BrowseAdStores(IN HWND hwndOwner,
  527. OUT CString& strDN,
  528. IN CADInfo& refAdInfo);
  529. //+----------------------------------------------------------------------------
  530. // Function:GetFolderName
  531. // Synopsis:Displays Folder selection dialog box and return folder selected
  532. // by user
  533. // Arguments:hwndOwner : owner window
  534. // nIDTitle : title of dialog box
  535. // strInitBrowseRoot : location of the root folder from which to
  536. // start browsing
  537. // strFolderName : gets selected file name
  538. //-----------------------------------------------------------------------------
  539. BOOL
  540. GetFolderName(IN HWND hwndOwner,
  541. IN INT nIDTitle,
  542. IN const CString& strInitBrowseRoot,
  543. IN OUT CString& strFolderName);
  544. //+----------------------------------------------------------------------------
  545. // Function: AddExtensionToFileName
  546. // Synopsis: Functions adds .xml extension to name of file if no extension
  547. // is present.
  548. // Arguments:
  549. // Returns:
  550. //-----------------------------------------------------------------------------
  551. VOID
  552. AddExtensionToFileName(IN OUT CString& strFileName);
  553. //+----------------------------------------------------------------------------
  554. // Function:GetCurrentWorkingDirectory
  555. // Synopsis:Gets the current working directory
  556. //-----------------------------------------------------------------------------
  557. BOOL
  558. GetCurrentWorkingDirectory(IN OUT CString& strCWD);
  559. //+----------------------------------------------------------------------------
  560. // Function: GetFileExtension
  561. // Synopsis: Get the extension of the file.
  562. //-----------------------------------------------------------------------------
  563. BOOL
  564. GetFileExtension(IN const CString& strFileName,
  565. OUT CString& strExtension);
  566. //+--------------------------------------------------------------------------
  567. // Function: AzRoleAdsOpenObject
  568. // Synopsis: A wrapper around ADsOpenObject
  569. //+--------------------------------------------------------------------------
  570. HRESULT AzRoleAdsOpenObject(LPWSTR lpszPathName,
  571. LPWSTR lpszUserName,
  572. LPWSTR lpszPassword,
  573. REFIID riid,
  574. VOID** ppObject,
  575. BOOL bBindToServer = FALSE);
  576. VOID
  577. GetDefaultADContainerPath(IN CADInfo& refAdInfo,
  578. IN BOOL bAddServer,
  579. IN BOOL bAddLdap,
  580. OUT CString& strPath);
  581. //+--------------------------------------------------------------------------
  582. // Function: IsBizRuleWritable
  583. // Synopsis: Checks if bizrules are writable for this object
  584. //+--------------------------------------------------------------------------
  585. BOOL
  586. IsBizRuleWritable(HWND hWnd, CContainerAz& refBaseAz);
  587. /******************************************************************************
  588. Class: CCommandLineOptions
  589. Purpose:class for reading the command line options for console file
  590. ******************************************************************************/
  591. class CCommandLineOptions
  592. {
  593. public:
  594. CCommandLineOptions():m_bInit(FALSE),
  595. m_bCommandLineSpecified(FALSE),
  596. m_lStoreType(AZ_ADMIN_STORE_INVALID)
  597. {
  598. }
  599. void Initialize();
  600. const CString& GetStoreName() const { return m_strStoreName;}
  601. LONG GetStoreType() const { return m_lStoreType;}
  602. BOOL CommandLineOptionSpecified() const { return m_bCommandLineSpecified;}
  603. private:
  604. BOOL m_bInit;
  605. BOOL m_bCommandLineSpecified;
  606. CString m_strStoreName;
  607. LONG m_lStoreType;
  608. };
  609. extern CCommandLineOptions commandLineOptions;
  610. //+----------------------------------------------------------------------------
  611. // Function: GetDisplayNameFromStoreURL
  612. // Synopsis: Get the display name for the store.
  613. // Arguments: strPolicyURL: This is store url in msxml://filepath or
  614. // msldap://dn format.
  615. // strDisplayName: This gets the display name. For xml, display
  616. // name is name of file, for AD its name of leaf element
  617. // Returns:
  618. //-----------------------------------------------------------------------------
  619. void
  620. GetDisplayNameFromStoreURL(IN const CString& strPolicyURL,
  621. OUT CString& strDisplayName);
  622. void
  623. SetXMLStoreDirectory(IN CRoleRootData& roleRootData,
  624. IN const CString& strXMLStorePath);
  625. //+----------------------------------------------------------------------------
  626. // Function: GetDirectoryFromPath
  627. // Synopsis: Removes the file name from the input file path and return
  628. // the folder path. For Ex: Input is C:\temp\foo.xml. Return
  629. // value will be C:\temp\
  630. //-----------------------------------------------------------------------------
  631. CString
  632. GetDirectoryFromPath(IN const CString& strPath);
  633. //+----------------------------------------------------------------------------
  634. // Function: ConvertToExpandedAndAbsolutePath
  635. // Synopsis: Expands the environment variables in the input path and also
  636. // makes it absolute if necessary.
  637. //-----------------------------------------------------------------------------
  638. void
  639. ConvertToExpandedAndAbsolutePath(IN OUT CString& strPath);
  640. //+----------------------------------------------------------------------------
  641. // Function: PreprocessScript
  642. // Synopsis: Script is read from XML file and displayed multi line edit control.
  643. // End of line in the XML is indicated by LF instead of CRLF sequence,
  644. // however Edit Control requires CRLF sequence to format correctly and
  645. // with only LF it displays everything in a single line with a box for
  646. // LF char. This function checks if script uses LF for line termination
  647. // and changes it with CRLF sequence.
  648. //-----------------------------------------------------------------------------
  649. void
  650. PreprocessScript(CString& strScript);