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.

379 lines
10 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: DSCookie.h
  7. //
  8. // Contents: DS Cookie functions
  9. //
  10. // History: 02-Oct-96 WayneSc Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #ifndef __DSCOOKIE_H__
  14. #define __DSCOOKIE_H__
  15. #include "dscache.h"
  16. #include "uinode.h"
  17. // Forward prototypes
  18. class CContextMenuVerbs;
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CDSCookieInfoBase : extra inof for special classes we know about
  21. class CDSCookieInfoBase
  22. {
  23. public:
  24. enum cookieClass { base, group, connection };
  25. CDSCookieInfoBase()
  26. {
  27. m_class = base;
  28. }
  29. virtual ~CDSCookieInfoBase()
  30. {
  31. }
  32. cookieClass GetClass() { return m_class;}
  33. virtual LPCWSTR GetFriendlyClassName() { return L"";}
  34. protected:
  35. cookieClass m_class;
  36. };
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CDSCookieInfoGroup : extra info for groups
  39. class CDSCookieInfoGroup : public CDSCookieInfoBase
  40. {
  41. public:
  42. CDSCookieInfoGroup()
  43. {
  44. m_class = group;
  45. m_GroupType = 0;
  46. }
  47. virtual LPCWSTR GetFriendlyClassName()
  48. {
  49. return GetGroupTypeStringHelper(m_GroupType);
  50. }
  51. INT m_GroupType;
  52. };
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CDSCookieInfoConnection : extra info for nTDSConnection objects
  55. class CDSCookieInfoConnection : public CDSCookieInfoBase
  56. {
  57. public:
  58. CDSCookieInfoConnection()
  59. {
  60. m_class = connection;
  61. m_nOptions = 0;
  62. m_fFRSConnection = FALSE;
  63. }
  64. CString m_strFRSComputerReference; // not always present
  65. int m_nOptions;
  66. BOOL m_fFRSConnection;
  67. };
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CDSCookie
  70. // CODEWORK these flags come from ntdsa.h
  71. /* Object Class independent bits */
  72. // NOTE: These flags MAY have different behaviour in different NCs.
  73. // For example, the FLAG_CONFIG_foo flags only have meaning inside the
  74. // configuration NC. the FLAG_DOMAIN_foo flags have meaning only outside the
  75. // configuration NC.
  76. #define FLAG_DISALLOW_DELETE 0x80000000
  77. #define FLAG_CONFIG_ALLOW_RENAME 0x40000000
  78. #define FLAG_CONFIG_ALLOW_MOVE 0x20000000
  79. #define FLAG_CONFIG_ALLOW_LIMITED_MOVE 0x10000000
  80. #define FLAG_DOMAIN_DISALLOW_RENAME 0x08000000
  81. #define FLAG_DOMAIN_DISALLOW_MOVE 0x04000000
  82. // Bit flags for options attribute on NTDS-Connection objects.
  83. #define NTDSCONN_OPT_IS_GENERATED ( 1 << 0 ) /* object generated by DS, not admin */
  84. /* Object Class specific bits, by object class */
  85. /* CrossReference objects */
  86. #define FLAG_CR_NTDS_NC 0x00000001 // NC is in NTDS (not VC or foreign)
  87. #define FLAG_CR_NTDS_DOMAIN 0x00000002 // NC is a domain (not non-domain NC)
  88. // end of ntdsa.h
  89. class CDSCookie : public CNodeData
  90. {
  91. public:
  92. CDSCookie();
  93. virtual ~CDSCookie();
  94. //operators
  95. public:
  96. // values retrieved from the cache item (per class values)
  97. int GetImage(BOOL bOpen); // base and DS
  98. GUID* GetGUID(); // base and DS
  99. LPCWSTR GetClass();
  100. LPCWSTR GetLocalizedClassName();
  101. // Value management functions
  102. void SetName(LPCWSTR lpszName) { m_strName = lpszName;}
  103. LPCWSTR GetName() { return m_strName; }
  104. void SetPath(LPCWSTR lpszPath) { m_strPath = lpszPath;}
  105. LPCWSTR GetPath(void) { return m_strPath;}
  106. void SetSystemFlags(int iSystemFlags) { m_iSystemFlags=iSystemFlags;}
  107. int GetSystemFlags(void) { return m_iSystemFlags; }
  108. void SetDesc(LPCWSTR lpszDesc) { m_strDesc = lpszDesc;}
  109. LPCWSTR GetDesc() { return m_strDesc; }
  110. void SetCacheItem(CDSClassCacheItemBase* pCacheItem)
  111. {
  112. ASSERT(pCacheItem != NULL);
  113. m_pCacheItem = pCacheItem;
  114. }
  115. void SetChildList(WCHAR **ppList);
  116. WCHAR ** GetChildList(void) { return m_ppChildList; }
  117. void SetChildCount(int cChildCount) { m_cChildCount=cChildCount;}
  118. int GetChildCount(void) { return m_cChildCount; }
  119. LPCWSTR GetChildListEntry(int iChildIndex)
  120. {
  121. ASSERT(iChildIndex >= 0 && iChildIndex < GetChildCount());
  122. return m_ppChildList[iChildIndex];
  123. }
  124. BOOL IsDisabled() { return m_bDisabled; }
  125. void SetDisabled() { m_bDisabled=TRUE; }
  126. void ReSetDisabled() { m_bDisabled=FALSE; }
  127. BOOL IsNonExpiringPwd() { return m_bNonExpiringPassword; }
  128. void SetNonExpiringPwd() { m_bNonExpiringPassword = TRUE; }
  129. void ReSetNonExpiringPwd() { m_bNonExpiringPassword = FALSE; }
  130. BOOL IsContainerClass()
  131. {
  132. if (m_pCacheItem == NULL)
  133. {
  134. ASSERT(FALSE); // should never happen
  135. return TRUE;
  136. }
  137. // ask the class cache item about it
  138. return m_pCacheItem->IsContainer();
  139. }
  140. CDSCookieInfoBase* GetExtraInfo() { return m_pExtraInfo;}
  141. void SetExtraInfo(CDSCookieInfoBase* pExtraInfo)
  142. {
  143. ASSERT(pExtraInfo != NULL);
  144. if (m_pExtraInfo != NULL)
  145. delete m_pExtraInfo;
  146. m_pExtraInfo = pExtraInfo;
  147. }
  148. CStringList& GetParentClassSpecificStrings(void)
  149. { return m_strlistParentClassSpecificStrings; }
  150. SYSTEMTIME* GetModifiedTime() { return m_pModifiedTime; }
  151. void SetModifiedTime(SYSTEMTIME* pModifiedTime)
  152. {
  153. if (m_pModifiedTime == NULL)
  154. {
  155. m_pModifiedTime = (SYSTEMTIME*)malloc(sizeof(SYSTEMTIME));
  156. }
  157. if (m_pModifiedTime != NULL)
  158. {
  159. memcpy(m_pModifiedTime, pModifiedTime, sizeof(SYSTEMTIME));
  160. }
  161. }
  162. //attributes
  163. private:
  164. CString m_strName;
  165. CString m_strPath;
  166. int m_iSystemFlags; // systemFlags of the node
  167. CString m_strDesc;
  168. WCHAR **m_ppChildList; // list of allowable child classes
  169. int m_cChildCount; // count of items in above list
  170. BOOL m_bDisabled; // only valid if class is sec. princ.
  171. BOOL m_bNonExpiringPassword; // only valid if class is sec. princ.
  172. // We enumerate additional attributes depending on the class of the parent.
  173. CStringList m_strlistParentClassSpecificStrings;
  174. SYSTEMTIME* m_pModifiedTime;
  175. CDSClassCacheItemBase* m_pCacheItem;
  176. CDSCookieInfoBase* m_pExtraInfo;
  177. };
  178. /////////////////////////////////////////////////////////////////////////////
  179. // CDSUINode : UI node corresponding to a DS object (result of an ADSI query)
  180. class CDSUINode : public CUINode
  181. {
  182. public:
  183. CDSUINode(CUINode* pParentNode);
  184. // override of pure virtual functions
  185. virtual void SetName(LPCWSTR lpszName) { GetCookie()->SetName(lpszName);}
  186. virtual LPCWSTR GetName() { return GetCookie()->GetName();}
  187. virtual void SetDesc(LPCWSTR lpszDesc) { GetCookie()->SetDesc(lpszDesc);}
  188. virtual LPCWSTR GetDesc() { return GetCookie()->GetDesc();}
  189. int GetImage(BOOL bOpen) { return GetCookie()->GetImage(bOpen);}
  190. virtual GUID* GetGUID() { return GetCookie()->GetGUID();}
  191. virtual LPCWSTR GetDisplayString(int nCol, CDSColumnSet* pColumnSet);
  192. CDSCookie* GetCookie()
  193. {
  194. // assume that the cast succeeds
  195. CDSCookie* pCookie = dynamic_cast<CDSCookie*>(m_pNodeData);
  196. ASSERT(pCookie != NULL);
  197. return pCookie;
  198. }
  199. void SetCookie(CDSCookie* pCookie)
  200. {
  201. ASSERT(m_pNodeData == NULL);
  202. m_pNodeData = pCookie;
  203. }
  204. // end port
  205. virtual CDSColumnSet* GetColumnSet(CDSComponentData* pComponentData);
  206. //
  207. // These set the state of the standard context menu items
  208. //
  209. virtual BOOL IsDeleteAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  210. virtual BOOL IsRenameAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  211. virtual BOOL IsRefreshAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  212. virtual BOOL ArePropertiesAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  213. virtual BOOL IsCutAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  214. virtual BOOL IsCopyAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  215. virtual BOOL IsPasteAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  216. virtual CContextMenuVerbs* GetContextMenuVerbsObject(CDSComponentData* pComponentData);
  217. virtual BOOL HasPropertyPages(LPDATAOBJECT pDataObject);
  218. };
  219. // REVIEW_MARCOC_PORT: this is just to get going, cannot assume this ever
  220. inline CDSCookie* GetDSCookieFromUINode(CUINode* pUINode)
  221. {
  222. ASSERT(pUINode != NULL);
  223. CDSUINode* pDSUINode = dynamic_cast<CDSUINode*>(pUINode);
  224. ASSERT(pDSUINode != NULL);
  225. return pDSUINode->GetCookie();
  226. }
  227. /////////////////////////////////////////////////////////////////////////////
  228. // CDSThreadQueryInfo
  229. typedef enum DSQueryType { unk, rootFolder, dsFolder, queryFolder };
  230. class CDSThreadQueryInfo : public CThreadQueryInfo
  231. {
  232. public:
  233. CDSThreadQueryInfo()
  234. {
  235. m_bOneLevel = TRUE;
  236. m_QueryType = unk;
  237. }
  238. void SetQueryDSQueryParameters(DSQueryType QueryType,
  239. LPCWSTR lpszPath,
  240. LPCWSTR lpszClass,
  241. LPCWSTR lpszQueryString,
  242. UINT nMaxItemCount,
  243. BOOL bOneLevel,
  244. LPCWSTR lpszColumnSetID)
  245. {
  246. ASSERT(m_QueryType == unk);
  247. ASSERT(QueryType != unk);
  248. m_QueryType = QueryType;
  249. SetMaxItemCount(nMaxItemCount);
  250. m_szPath = lpszPath;
  251. m_szClass = lpszClass;
  252. m_szQueryString = lpszQueryString;
  253. m_bOneLevel = bOneLevel;
  254. m_szColumnSetID = lpszColumnSetID;
  255. }
  256. BOOL IsOneLevel() { return m_bOneLevel;}
  257. DSQueryType GetType() { return m_QueryType;}
  258. LPCWSTR GetPath() { return m_szPath;}
  259. LPCWSTR GetClass() { return m_szClass;}
  260. LPCWSTR GetQueryString() { return m_szQueryString;}
  261. LPCWSTR GetColumnSetID() { return m_szColumnSetID;}
  262. private:
  263. BOOL m_bOneLevel;
  264. DSQueryType m_QueryType;
  265. CString m_szPath;
  266. CString m_szClass;
  267. CString m_szQueryString;
  268. CString m_szColumnSetID;
  269. };
  270. /////////////////////////////////////////////////////////////////////////////
  271. // CThreadQueryResult
  272. class CThreadQueryResult
  273. {
  274. public:
  275. CThreadQueryResult()
  276. {
  277. m_hr = S_OK;
  278. m_bOwnMemory = TRUE;
  279. }
  280. ~CThreadQueryResult()
  281. {
  282. if (m_bOwnMemory)
  283. {
  284. while (!m_nodeList.IsEmpty())
  285. delete m_nodeList.RemoveHead();
  286. }
  287. }
  288. CUINodeList m_nodeList;
  289. HRESULT m_hr;
  290. BOOL m_bOwnMemory;
  291. };
  292. #endif //__DSCOOKIE_H__