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.

520 lines
10 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: cprops.hxx
  7. //
  8. // Contents:
  9. //
  10. // History: 06-16-96 yihsins Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. typedef struct _dispproperty{
  14. LPWSTR szPropertyName; // Property name
  15. }DISPPROPERTY, *PDISPPROPERTY;
  16. typedef struct _property{
  17. LPWSTR szPropertyName; // Property name
  18. LDAPOBJECTARRAY ldapObjectArray; // An array of LDAP Objects ( values )
  19. DWORD dwFlags; // Status of the value
  20. DWORD dwSyntaxId; // LDAP Syntax Id
  21. }PROPERTY, *PPROPERTY;
  22. typedef struct _savingentry{
  23. LIST_ENTRY ListEntry;
  24. LPWSTR entryData;
  25. }SAVINGENTRY, *PSAVINGENTRY;
  26. #define PROPERTY_NAME(pProperty) pProperty->szPropertyName
  27. #define PROPERTY_LDAPOBJECTARRAY(pProperty) pProperty->ldapObjectArray
  28. #define PROPERTY_SYNTAX(pProperty) pProperty->dwSyntaxId
  29. #define PROPERTY_FLAGS(pProperty) pProperty->dwFlags
  30. //
  31. // A test to see if a returned property entry actually has data.
  32. //
  33. #define PROPERTY_EMPTY(pProperty) \
  34. (((pProperty)->ldapObjectArray.pLdapObjects) == NULL)
  35. #define INDEX_EMPTY(dwIndex) PROPERTY_EMPTY(_pProperties + (dwIndex))
  36. #define PROPERTY_INIT 0
  37. #define PROPERTY_UPDATE 1
  38. #define PROPERTY_ADD 2
  39. #define PROPERTY_DELETE 3
  40. #define PROPERTY_DELETE_VALUE 4
  41. #define PROPERTY_DELETED(pProperty) \
  42. ((pProperty)->dwFlags == PROPERTY_DELETE)
  43. #define PROP_DELETED(dwIndex) PROPERTY_DELETED(_pProperties + (dwIndex))
  44. //
  45. // This is used to tag the flags value so that we can make sure we
  46. // use the correct seInfo when the SD has been updated.
  47. //
  48. #define INVALID_SE_VALUE 0xffffffff
  49. class CPropertyCache : public IPropertyCache {
  50. public:
  51. HRESULT
  52. CPropertyCache::
  53. addproperty(
  54. LPWSTR szPropertyName
  55. );
  56. HRESULT
  57. CPropertyCache::
  58. updateproperty(
  59. LPWSTR szPropertyName,
  60. DWORD dwSyntaxId,
  61. LDAPOBJECTARRAY ldapObjectArray,
  62. BOOL fExplicit
  63. );
  64. //
  65. // This one will automatically add to cace as needed.
  66. //
  67. HRESULT
  68. CPropertyCache::
  69. putpropertyext(
  70. LPWSTR szPropertyName,
  71. DWORD dwFlags,
  72. DWORD dwSyntaxId,
  73. LDAPOBJECTARRAY ldapObjectArray
  74. );
  75. HRESULT
  76. CPropertyCache::
  77. findproperty(
  78. LPWSTR szPropertyName,
  79. PDWORD pdwIndex
  80. );
  81. HRESULT
  82. CPropertyCache::
  83. deleteproperty(
  84. DWORD dwIndex
  85. );
  86. HRESULT
  87. CPropertyCache::
  88. getproperty(
  89. LPWSTR szPropertyName,
  90. PDWORD pdwSyntaxId,
  91. PDWORD pwStatusFlag,
  92. LDAPOBJECTARRAY *pLdapObjectArray
  93. );
  94. // This should not be there but to force compile
  95. HRESULT
  96. CPropertyCache::
  97. getproperty(
  98. DWORD dwIndex,
  99. LDAPOBJECTARRAY *pLdapObjectArray
  100. );
  101. HRESULT
  102. CPropertyCache::
  103. unboundgetproperty(
  104. LPWSTR szPropertyName,
  105. PDWORD pdwSyntaxId,
  106. PDWORD pdwStatusFlag,
  107. LDAPOBJECTARRAY *pLdapObjectArray
  108. );
  109. HRESULT
  110. CPropertyCache::
  111. putproperty(
  112. LPWSTR szPropertyName,
  113. DWORD dwFlags,
  114. DWORD dwSyntaxId,
  115. LDAPOBJECTARRAY ldapObjectArray
  116. );
  117. //
  118. // Helper for Umi functionality.
  119. //
  120. HRESULT
  121. CPropertyCache::
  122. GetPropertyNames(UMI_PROPERTY_VALUES **ppUmiPropVals);
  123. CPropertyCache::
  124. CPropertyCache();
  125. CPropertyCache::
  126. ~CPropertyCache();
  127. static
  128. HRESULT
  129. CPropertyCache::
  130. createpropertycache(
  131. CCoreADsObject *pCoreADsObject,
  132. IGetAttributeSyntax *pGetAttributeSyntax,
  133. CPropertyCache FAR * FAR * ppPropertyCache
  134. );
  135. //
  136. // PropCache needs the credentials, server and port no
  137. // to work properly on dynaminc dispid calls
  138. //
  139. HRESULT
  140. CPropertyCache::
  141. SetObjInformation(
  142. CCredentials* pCredentials,
  143. LPWSTR pszServerName,
  144. DWORD dwPortNo
  145. );
  146. VOID
  147. CPropertyCache::
  148. flushpropertycache();
  149. HRESULT
  150. CPropertyCache::
  151. unmarshallproperty(
  152. LPWSTR szPropertyName,
  153. PADSLDP pLdapHandle,
  154. LDAPMessage *entry,
  155. DWORD dwSyntaxId,
  156. BOOL fExplicit,
  157. BOOL * pfRangeRetrieval = NULL
  158. );
  159. HRESULT
  160. CPropertyCache::
  161. LDAPUnMarshallProperties(
  162. LPWSTR pszServerPath,
  163. PADSLDP pLdapHandle,
  164. LDAPMessage *ldapmsg,
  165. BOOL fExplicit,
  166. CCredentials& Credentials
  167. );
  168. HRESULT
  169. CPropertyCache::
  170. LDAPUnMarshallProperties2(
  171. LPWSTR pszServerPath,
  172. PADSLDP pLdapHandle,
  173. LDAPMessage *ldapmsg,
  174. BOOL fExplicit,
  175. CCredentials& Credentials,
  176. BOOL * pfRangeRetrieval
  177. );
  178. HRESULT
  179. CPropertyCache::
  180. LDAPUnMarshallPropertyAs(
  181. LPWSTR pszServerPath,
  182. PADSLDP pLdapHandle,
  183. LDAPMessage *ldapmsg,
  184. LPWSTR szPropertyName,
  185. DWORD dwSyntaxId,
  186. BOOL fExplicit,
  187. CCredentials& Credentials
  188. );
  189. HRESULT
  190. CPropertyCache::
  191. LDAPUnMarshallPropertiesAs(
  192. LPWSTR pszServerPath,
  193. PADSLDP pLdapHandle,
  194. LDAPMessage *ldapmsg,
  195. DWORD dwSyntaxId,
  196. BOOL fExplicit,
  197. CCredentials& Credentials
  198. );
  199. HRESULT
  200. CPropertyCache::
  201. LDAPMarshallProperties(
  202. LDAPModW ***aMods,
  203. PBOOL pfNTSecDes,
  204. SECURITY_INFORMATION *pSeInfo
  205. );
  206. HRESULT
  207. CPropertyCache::
  208. LDAPMarshallProperties2(
  209. LDAPModW ***aMods,
  210. DWORD *pdwNumOfMods
  211. );
  212. HRESULT
  213. CPropertyCache::
  214. ClearMarshalledProperties(
  215. VOID
  216. );
  217. HRESULT
  218. CPropertyCache::
  219. ClearAllPropertyFlags(
  220. VOID
  221. );
  222. HRESULT
  223. CPropertyCache::
  224. ClearPropertyFlag(
  225. LPWSTR szPropertyName
  226. );
  227. HRESULT
  228. CPropertyCache::
  229. SetPropertyFlag(
  230. LPWSTR szPropertyName,
  231. DWORD dwFlag
  232. );
  233. HRESULT
  234. CPropertyCache::
  235. IsPropertyUpdated(
  236. LPWSTR szPropertyName,
  237. BOOL *pfUpdated
  238. );
  239. HRESULT
  240. CPropertyCache::
  241. unboundgetproperty(
  242. DWORD dwIndex,
  243. PDWORD pdwSyntaxId,
  244. PDWORD pdwStatusFlag,
  245. LDAPOBJECTARRAY *pLdapObjectArray
  246. );
  247. void
  248. CPropertyCache::
  249. reset_propindex(
  250. );
  251. //
  252. // All methods which use the _dwCurrentIndex attribute must check that the
  253. // index is valid using this test and ONLY then proceed
  254. //
  255. BOOL
  256. CPropertyCache::
  257. index_valid(
  258. );
  259. BOOL
  260. CPropertyCache::
  261. index_valid(
  262. DWORD dwIndex
  263. );
  264. LPWSTR
  265. CPropertyCache::
  266. get_PropName(
  267. DWORD dwIndex
  268. );
  269. HRESULT
  270. CPropertyCache::
  271. skip_propindex(
  272. DWORD dwElements
  273. );
  274. HRESULT
  275. CPropertyCache::
  276. get_PropertyCount(
  277. PDWORD pdwMaxProperties
  278. );
  279. DWORD
  280. CPropertyCache::
  281. get_CurrentIndex(
  282. );
  283. LPWSTR
  284. CPropertyCache::
  285. get_CurrentPropName(
  286. );
  287. void
  288. setGetInfoFlag();
  289. //
  290. // Returns the status of the GetInfo flag. TRUE indicates that GetInfo
  291. // has been performed and FALSE indicates that GetInfo has not yet been
  292. // called on this object.
  293. //
  294. BOOL
  295. getGetInfoFlag()
  296. {
  297. return _fGetInfoDone;
  298. }
  299. //
  300. // The following three are for dynamic dispid's, so they shouldn't
  301. // return any ADSI return values.
  302. //
  303. HRESULT
  304. locateproperty(
  305. LPWSTR szPropertyName,
  306. PDWORD pdwIndex
  307. );
  308. //
  309. // Because of the IPropertyCache interface, we need to get
  310. // rid of it
  311. //
  312. // NO ! DO NOT GET RID OF THIS FUNCTION!!!
  313. //
  314. HRESULT
  315. getproperty(
  316. DWORD dwIndex,
  317. VARIANT *pVarResult,
  318. CCredentials &Credentials
  319. );
  320. HRESULT
  321. putproperty(
  322. DWORD dwIndex,
  323. VARIANT varValue
  324. );
  325. HRESULT
  326. CPropertyCache::
  327. DispatchFindProperty(
  328. LPWSTR szPropertyName,
  329. PDWORD pdwIndex
  330. );
  331. // No longer private
  332. //
  333. // This is the "real" putproperty, called by the other two.
  334. //
  335. HRESULT
  336. CPropertyCache::
  337. putproperty(
  338. DWORD dwIndex,
  339. DWORD dwFlags,
  340. DWORD dwSyntaxId,
  341. LDAPOBJECTARRAY ldapObjectArray
  342. );
  343. //
  344. // add entry to the GlobalListSavingEntries, the entries are the properties requested in GetInfoEx
  345. //
  346. HRESULT
  347. CPropertyCache::
  348. AddSavingEntry(
  349. LPWSTR propertyName
  350. );
  351. //
  352. // compare the property with the entries in the list to determine whether we will go on wire again
  353. //
  354. BOOL
  355. CPropertyCache::
  356. FindSavingEntry(
  357. LPWSTR propertyName
  358. );
  359. //
  360. // delete the entry in the GlobalListSavingEntries, so after a SetInfo, we will have a fresh start
  361. //
  362. HRESULT
  363. CPropertyCache::
  364. DeleteSavingEntry();
  365. private:
  366. HRESULT
  367. getproperty(
  368. DWORD dwIndex,
  369. PDWORD dwStatusFlag,
  370. VARIANT *pVarResult,
  371. CCredentials &Credentials
  372. );
  373. protected:
  374. DWORD _dwMaxProperties;
  375. PPROPERTY _pProperties;
  376. DWORD _cb;
  377. DWORD _dwCurrentIndex;
  378. DWORD _dwDispMaxProperties;
  379. PDISPPROPERTY _pDispProperties;
  380. DWORD _cbDisp;
  381. CCoreADsObject *_pCoreADsObject;
  382. IGetAttributeSyntax *_pGetAttributeSyntax;
  383. BOOL _fGetInfoDone;
  384. CCredentials* _pCredentials;
  385. LPWSTR _pszServerName;
  386. DWORD _dwPort;
  387. LIST_ENTRY _ListSavingEntries;
  388. };
  389. //
  390. // In-lined methods of CPropertyCache
  391. //
  392. inline
  393. BOOL
  394. CPropertyCache::
  395. index_valid(
  396. )
  397. {
  398. //
  399. // NOTE: - _dwCurrentIndex is of type DWORD which is unsigned long.
  400. // - _dwMaxProperties -1 is also of type unsigned long (so
  401. // if _dwMaxProperites = 0, _dwMaxproperties -1 = 0xffffff)
  402. // - comparision checking must taken the above into account
  403. // for proper checking
  404. //
  405. if ( (_dwMaxProperties==0) || (_dwCurrentIndex >_dwMaxProperties-1) )
  406. return(FALSE);
  407. else
  408. return(TRUE);
  409. }
  410. inline
  411. BOOL
  412. CPropertyCache::
  413. index_valid(
  414. DWORD dwIndex
  415. )
  416. {
  417. //
  418. // NOTE: - _dwIndex is of type DWORD which is unsigned long.
  419. // - _dwMaxProperties -1 is also of type unsigned long (so
  420. // if _dwMaxProperites = 0, _dwMaxproperties -1 = 0xffffff)
  421. // - comparision checking must taken the above into account
  422. // for proper checking
  423. //
  424. if ( (_dwMaxProperties==0) || (dwIndex >_dwMaxProperties-1) )
  425. return(FALSE);
  426. else
  427. return(TRUE);
  428. }