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.

538 lines
11 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. LDAPUnMarshallProperties3(
  181. LPWSTR pszServerPath,
  182. PADSLDP pLdapHandle,
  183. LDAPMessage *ldapmsg,
  184. BOOL fExplicit,
  185. DWORD dwDefaultSyntaxID,
  186. CCredentials& Credentials
  187. );
  188. HRESULT
  189. CPropertyCache::
  190. LDAPUnMarshallPropertyAs(
  191. LPWSTR pszServerPath,
  192. PADSLDP pLdapHandle,
  193. LDAPMessage *ldapmsg,
  194. LPWSTR szPropertyName,
  195. DWORD dwSyntaxId,
  196. BOOL fExplicit,
  197. CCredentials& Credentials
  198. );
  199. HRESULT
  200. CPropertyCache::
  201. LDAPUnMarshallPropertiesAs(
  202. LPWSTR pszServerPath,
  203. PADSLDP pLdapHandle,
  204. LDAPMessage *ldapmsg,
  205. DWORD dwSyntaxId,
  206. BOOL fExplicit,
  207. CCredentials& Credentials
  208. );
  209. HRESULT
  210. CPropertyCache::
  211. LDAPMarshallProperties(
  212. LDAPModW ***aMods,
  213. PBOOL pfNTSecDes,
  214. SECURITY_INFORMATION *pSeInfo
  215. );
  216. HRESULT
  217. CPropertyCache::
  218. LDAPMarshallProperties2(
  219. LDAPModW ***aMods,
  220. DWORD *pdwNumOfMods
  221. );
  222. HRESULT
  223. CPropertyCache::
  224. ClearMarshalledProperties(
  225. VOID
  226. );
  227. HRESULT
  228. CPropertyCache::
  229. ClearAllPropertyFlags(
  230. VOID
  231. );
  232. HRESULT
  233. CPropertyCache::
  234. ClearPropertyFlag(
  235. LPWSTR szPropertyName
  236. );
  237. HRESULT
  238. CPropertyCache::
  239. SetPropertyFlag(
  240. LPWSTR szPropertyName,
  241. DWORD dwFlag
  242. );
  243. HRESULT
  244. CPropertyCache::
  245. GetPropertyFlag(
  246. LPWSTR szPropertyName,
  247. DWORD* pdwFlag
  248. );
  249. HRESULT
  250. CPropertyCache::
  251. IsPropertyUpdated(
  252. LPWSTR szPropertyName,
  253. BOOL *pfUpdated
  254. );
  255. HRESULT
  256. CPropertyCache::
  257. unboundgetproperty(
  258. DWORD dwIndex,
  259. PDWORD pdwSyntaxId,
  260. PDWORD pdwStatusFlag,
  261. LDAPOBJECTARRAY *pLdapObjectArray
  262. );
  263. void
  264. CPropertyCache::
  265. reset_propindex(
  266. );
  267. //
  268. // All methods which use the _dwCurrentIndex attribute must check that the
  269. // index is valid using this test and ONLY then proceed
  270. //
  271. BOOL
  272. CPropertyCache::
  273. index_valid(
  274. );
  275. BOOL
  276. CPropertyCache::
  277. index_valid(
  278. DWORD dwIndex
  279. );
  280. LPWSTR
  281. CPropertyCache::
  282. get_PropName(
  283. DWORD dwIndex
  284. );
  285. HRESULT
  286. CPropertyCache::
  287. skip_propindex(
  288. DWORD dwElements
  289. );
  290. HRESULT
  291. CPropertyCache::
  292. get_PropertyCount(
  293. PDWORD pdwMaxProperties
  294. );
  295. DWORD
  296. CPropertyCache::
  297. get_CurrentIndex(
  298. );
  299. LPWSTR
  300. CPropertyCache::
  301. get_CurrentPropName(
  302. );
  303. void
  304. setGetInfoFlag();
  305. //
  306. // Returns the status of the GetInfo flag. TRUE indicates that GetInfo
  307. // has been performed and FALSE indicates that GetInfo has not yet been
  308. // called on this object.
  309. //
  310. BOOL
  311. getGetInfoFlag()
  312. {
  313. return _fGetInfoDone;
  314. }
  315. //
  316. // The following three are for dynamic dispid's, so they shouldn't
  317. // return any ADSI return values.
  318. //
  319. HRESULT
  320. locateproperty(
  321. LPWSTR szPropertyName,
  322. PDWORD pdwIndex
  323. );
  324. //
  325. // Because of the IPropertyCache interface, we need to get
  326. // rid of it
  327. //
  328. // NO ! DO NOT GET RID OF THIS FUNCTION!!!
  329. //
  330. HRESULT
  331. getproperty(
  332. DWORD dwIndex,
  333. VARIANT *pVarResult,
  334. CCredentials &Credentials
  335. );
  336. HRESULT
  337. putproperty(
  338. DWORD dwIndex,
  339. VARIANT varValue
  340. );
  341. HRESULT
  342. CPropertyCache::
  343. DispatchFindProperty(
  344. LPWSTR szPropertyName,
  345. PDWORD pdwIndex
  346. );
  347. // No longer private
  348. //
  349. // This is the "real" putproperty, called by the other two.
  350. //
  351. HRESULT
  352. CPropertyCache::
  353. putproperty(
  354. DWORD dwIndex,
  355. DWORD dwFlags,
  356. DWORD dwSyntaxId,
  357. LDAPOBJECTARRAY ldapObjectArray
  358. );
  359. //
  360. // add entry to the GlobalListSavingEntries, the entries are the properties requested in GetInfoEx
  361. //
  362. HRESULT
  363. CPropertyCache::
  364. AddSavingEntry(
  365. LPWSTR propertyName
  366. );
  367. //
  368. // compare the property with the entries in the list to determine whether we will go on wire again
  369. //
  370. BOOL
  371. CPropertyCache::
  372. FindSavingEntry(
  373. LPWSTR propertyName
  374. );
  375. //
  376. // delete the entry in the GlobalListSavingEntries, so after a SetInfo, we will have a fresh start
  377. //
  378. HRESULT
  379. CPropertyCache::
  380. DeleteSavingEntry();
  381. private:
  382. HRESULT
  383. getproperty(
  384. DWORD dwIndex,
  385. PDWORD dwStatusFlag,
  386. VARIANT *pVarResult,
  387. CCredentials &Credentials
  388. );
  389. protected:
  390. DWORD _dwMaxProperties;
  391. PPROPERTY _pProperties;
  392. DWORD _cb;
  393. DWORD _dwCurrentIndex;
  394. DWORD _dwDispMaxProperties;
  395. PDISPPROPERTY _pDispProperties;
  396. DWORD _cbDisp;
  397. CCoreADsObject *_pCoreADsObject;
  398. IGetAttributeSyntax *_pGetAttributeSyntax;
  399. BOOL _fGetInfoDone;
  400. CCredentials* _pCredentials;
  401. LPWSTR _pszServerName;
  402. DWORD _dwPort;
  403. LIST_ENTRY _ListSavingEntries;
  404. };
  405. //
  406. // In-lined methods of CPropertyCache
  407. //
  408. inline
  409. BOOL
  410. CPropertyCache::
  411. index_valid(
  412. )
  413. {
  414. //
  415. // NOTE: - _dwCurrentIndex is of type DWORD which is unsigned long.
  416. // - _dwMaxProperties -1 is also of type unsigned long (so
  417. // if _dwMaxProperites = 0, _dwMaxproperties -1 = 0xffffff)
  418. // - comparision checking must taken the above into account
  419. // for proper checking
  420. //
  421. if ( (_dwMaxProperties==0) || (_dwCurrentIndex >_dwMaxProperties-1) )
  422. return(FALSE);
  423. else
  424. return(TRUE);
  425. }
  426. inline
  427. BOOL
  428. CPropertyCache::
  429. index_valid(
  430. DWORD dwIndex
  431. )
  432. {
  433. //
  434. // NOTE: - _dwIndex is of type DWORD which is unsigned long.
  435. // - _dwMaxProperties -1 is also of type unsigned long (so
  436. // if _dwMaxProperites = 0, _dwMaxproperties -1 = 0xffffff)
  437. // - comparision checking must taken the above into account
  438. // for proper checking
  439. //
  440. if ( (_dwMaxProperties==0) || (dwIndex >_dwMaxProperties-1) )
  441. return(FALSE);
  442. else
  443. return(TRUE);
  444. }