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.

501 lines
18 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. // ***************************************************************************
  5. //
  6. // Original Author: Rajesh Rao
  7. //
  8. // $Author: rajeshr $
  9. // $Date: 6/11/98 4:43p $
  10. // $Workfile:ldapprov.cpp $
  11. //
  12. // $Modtime: 6/11/98 11:21a $
  13. // $Revision: 1 $
  14. // $Nokeywords: $
  15. //
  16. //
  17. // Description: Contains the declaration for the DS LDAP Class Provider class. This
  18. // class provides the classes in the DS LDAP namespace to WBEM. Note that an instance of the CDSClassProviderInitializer
  19. // class has to be created to initialize the static members of the CDSClassProvider class. Hence exactly
  20. // one instance of the CLDAPClassProviderInitializer class should be created for this
  21. // class to function properly.
  22. //
  23. //***************************************************************************
  24. /////////////////////////////////////////////////////////////////////////
  25. #ifndef LDAP_CLASS_PROVIDER_H
  26. #define LDAP_CLASS_PROVIDER_H
  27. // Forward declaration for the initializer class
  28. class CLDAPClassProviderInitializer;
  29. class CLDAPClassProvider : public CDSClassProvider
  30. {
  31. // The initializer class is a friend of this class
  32. friend CLDAPClassProviderInitializer;
  33. public:
  34. //***************************************************************************
  35. //
  36. // CLDAPClassProvider::CLDAPClassProvider
  37. // CLDAPClassProvider::~CLDAPClassProvider
  38. //
  39. // Constructor Parameters:
  40. // None
  41. //***************************************************************************
  42. CLDAPClassProvider () ;
  43. ~CLDAPClassProvider () ;
  44. //***************************************************************************
  45. //
  46. // CLDAPClassProvider::Initialize
  47. //
  48. // Purpose:
  49. // As defined by the IWbemProviderInit interface
  50. //
  51. // Parameters:
  52. // As defined by IWbemProviderInit interface
  53. //
  54. // Return Value: The COM status value indicating the status of the request
  55. //***************************************************************************
  56. HRESULT STDMETHODCALLTYPE Initialize(
  57. LPWSTR wszUser,
  58. LONG lFlags,
  59. LPWSTR wszNamespace,
  60. LPWSTR wszLocale,
  61. IWbemServices __RPC_FAR *pNamespace,
  62. IWbemContext __RPC_FAR *pCtx,
  63. IWbemProviderInitSink __RPC_FAR *pInitSink) ;
  64. //***************************************************************************
  65. //
  66. // CLDAPClassProvider :: CreateClassEnumAsync
  67. //
  68. // Purpose: Enumerates the classes
  69. //
  70. // Parameters:
  71. // Standard parmaters as described by the IWbemServices interface
  72. //
  73. //
  74. // Return Value: As described by the IWbemServices interface
  75. //
  76. //***************************************************************************
  77. HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  78. const BSTR strSuperclass,
  79. long lFlags,
  80. IWbemContext __RPC_FAR *pCtx,
  81. IWbemObjectSink __RPC_FAR *pResponseHandler);
  82. protected:
  83. //***************************************************************************
  84. //
  85. // CLDAPClassProvider::InitializeLDAPProvider
  86. //
  87. // Purpose: A helper function to do the ADSI LDAP provider specific initialization.
  88. //
  89. // Parameters:
  90. // pCtx The context object used in this call initialization
  91. //
  92. // Return Value: TRUE if the function successfully finishes the initializaion. FALSE
  93. // otherwise
  94. //***************************************************************************
  95. BOOLEAN InitializeLDAPProvider(IWbemContext *pCtx);
  96. ////////////////////////////////////////////////////////
  97. // Functions for interacting with the LDAP ADSI provider
  98. ////////////////////////////////////////////////////////
  99. //***************************************************************************
  100. //
  101. // CLDAPClassProvider::GetADSIClass
  102. //
  103. // Purpose : To Create a CADSIClass from an ADSI classSchema object
  104. // Parameters:
  105. // lpszWBEMClassName : The WBEM Name of the class to be fetched.
  106. // ppADSIClass : The address where the pointer to the CADSIClass will be stored.
  107. // It is the caller's responsibility to Release() the object when done with it
  108. //
  109. // Return Value: The COM status value indicating the status of the request.
  110. //***************************************************************************
  111. HRESULT GetADSIClass(
  112. LPCWSTR lpszClassName,
  113. CADSIClass ** ppADSIClass);
  114. //***************************************************************************
  115. //
  116. // CLDAPClassProvider::GetADSIProperty
  117. //
  118. // Purpose : To create an CADSIProperty object from an LDAP AttributeSchema object
  119. // Parameters:
  120. // lpszPropertyName : The LDAPDisplayName of the LDAP property to be fetched.
  121. // ppADSIProperty : The address where the pointer to the IDirectoryObject interface will be stored
  122. // It is the caller's responsibility to Release() the interface when done with it
  123. //
  124. // Return Value: The COM status value indicating the status of the request
  125. //***************************************************************************
  126. HRESULT GetADSIProperty(
  127. LPCWSTR lpszPropertyName,
  128. CADSIProperty **ppADSIProperty);
  129. //***************************************************************************
  130. //
  131. // CLDAPClassProvider::GetWBEMBaseClassName
  132. //
  133. // Purpose : Returns the name of the class that is the base class of all classes
  134. // provided by this provider.
  135. //
  136. // Parameters:
  137. // None
  138. //
  139. // Return Value: The name of the base class. NULL if such a class doesnt exist.
  140. //***************************************************************************
  141. const BSTR GetWBEMBaseClassName();
  142. //***************************************************************************
  143. //
  144. // CLDAPClassProvider::GetWBEMBaseClass
  145. //
  146. // Purpose : Returns a pointer to the class that is the base class of all classes
  147. // provided by this provider.
  148. //
  149. // Parameters:
  150. // None
  151. //
  152. // Return Value: The IWbemClassObject pointer to the base class. It is the duty of
  153. // user to release the class when done with using it.
  154. //***************************************************************************
  155. IWbemClassObject * GetWBEMBaseClass();
  156. //***************************************************************************
  157. //
  158. // CLDAPClassProvider::GetWBEMProviderName
  159. //
  160. // Purpose : Returns the name of the provider. This should be the same as the
  161. // value of the field Name in the __Win32Provider instance used for registration
  162. // of the provider
  163. //
  164. // Parameters:
  165. // None
  166. //
  167. // Return Value: The name of the provider
  168. //***************************************************************************
  169. const BSTR GetWBEMProviderName();
  170. //***************************************************************************
  171. //
  172. // CLDAPClassProvider::IsUnProvidedClass
  173. //
  174. // Purpose : To check whether a class is one that the provider does not provide
  175. //
  176. // Parameters:
  177. // lpszClassName : The WBEM Name of the class to be checked
  178. //
  179. //
  180. // Return Value: TRUE is this is one of the classes not provided by the provider
  181. //***************************************************************************
  182. BOOLEAN IsUnProvidedClass(LPCWSTR lpszClassName);
  183. ////////////////////////////////////////////////////////
  184. // Functions for handling a Get()
  185. ////////////////////////////////////////////////////////
  186. //***************************************************************************
  187. //
  188. // CLDAPClassProvider::GetClassFromADSI
  189. //
  190. // Purpose : To create a WBEM class from an ADSI Class
  191. //
  192. // Parameters:
  193. // lpszClassName : The WBEM Name of the class to be retreived
  194. // pCtx : A pointer to the context object that was used in this call. This
  195. // may be used by this function to make calls to CIMOM
  196. // ppWbemClass : The resulting WBEM Class. This has to be released once the
  197. // user is done with it.
  198. //
  199. //
  200. // Return Value: The COM result representing the status.
  201. //***************************************************************************
  202. HRESULT GetClassFromADSI(
  203. LPCWSTR lpszClassName,
  204. IWbemContext *pCtx,
  205. IWbemClassObject ** ppWbemClass
  206. );
  207. //***************************************************************************
  208. //
  209. // CDSClassProvider::CreateWBEMClass
  210. //
  211. // Purpose: Creates WBEM Class corresponding an ADSI Class
  212. //
  213. // Parameters:
  214. // pADSIClass : A pointer to a CADSI class object that is to be mapped to WBEM.
  215. // ppWbemClass : The WBEM class object retrieved. This is created by this function.
  216. // The caller should release it when done
  217. // pCtx : The context object that was used in this provider call
  218. //
  219. // Return Value: The COM value representing the return status
  220. //
  221. //***************************************************************************
  222. virtual HRESULT CreateWBEMClass (CADSIClass *pADSIClass, int iCaseNumber, IWbemClassObject **ppWbemClass, IWbemContext *pCtx);
  223. //***************************************************************************
  224. //
  225. // CDSClassProvider::MapClassSystemProperties
  226. //
  227. // Purpose: Creates an appropriately derived WBEM class and names it (__CLASS)
  228. //
  229. // Parameters:
  230. // pADSIClass : The ADSI class that is being mapped
  231. // ppWbemClass : The WBEM class object retrieved. This is created by this function.
  232. // The caller should release it when done
  233. // pCtx : The context object that was used in this provider call
  234. //
  235. // Return Value: The COM value representing the return status
  236. //
  237. //***************************************************************************
  238. virtual HRESULT MapClassSystemProperties(CADSIClass *pADSIClass, int iCaseNumber, IWbemClassObject **ppWbemClass, IWbemContext *pCtx);
  239. //***************************************************************************
  240. //
  241. // CDSClassProvider :: MapClassQualifiersToWBEM
  242. //
  243. // Purpose: Creates the class qualifiers for a WBEM class from the ADSI class
  244. //
  245. // Parameters:
  246. // pADSIClass : The LDAP class that is being mapped
  247. // pWbemClass : The WBEM class object being created. T
  248. // pCtx : The context object that was used in this provider call
  249. //
  250. // Return Value: The COM value representing the return status
  251. //
  252. //***************************************************************************
  253. virtual HRESULT MapClassQualifiersToWBEM(CADSIClass *pADSIClass, int iCaseNumber, IWbemClassObject *pWbemClass, IWbemContext *pCtx);
  254. //***************************************************************************
  255. //
  256. // CDSClassProvider :: MapClassPropertiesToWBEM
  257. //
  258. // Purpose: Creates the class properties for a WBEM class from the ADSI class
  259. //
  260. // Parameters:
  261. // pADSIClass : The LDAP class that is being mapped
  262. // pWbemClass : The WBEM class object being created.
  263. // pCtx : The context object that was used in this provider call
  264. //
  265. // Return Value: The COM value representing the return status
  266. //
  267. //***************************************************************************
  268. virtual HRESULT MapClassPropertiesToWBEM(CADSIClass *pADSIClass, IWbemClassObject *pWbemClass, IWbemContext *pCtx);
  269. //***************************************************************************
  270. //
  271. // CLDAPClassProvider :: MapPropertyListToWBEM
  272. //
  273. // Purpose: Maps a list of class properties for a WBEM class from the ADSI class
  274. //
  275. // Parameters:
  276. // pWbemClass : The WBEM class object being created.
  277. // lppszPropertyList : A list of propery names
  278. // dwCOunt : The number of items in the above list
  279. // bMapSystemQualifier : Whether the "system" qualifier should be mapped
  280. // bMapNotNullQualifier: Whether the "notNull" qualifier should be mapped
  281. //
  282. // Return Value: The COM value representing the return status
  283. //
  284. //***************************************************************************
  285. HRESULT MapPropertyListToWBEM(IWbemClassObject *pWbemClass,
  286. LPCWSTR *lppszPropertyList,
  287. DWORD dwCount,
  288. BOOLEAN bMapSystemQualifier,
  289. BOOLEAN bMapNotNullQualifier);
  290. //***************************************************************************
  291. //
  292. // CLDAPClassProvider :: CreateWBEMProperty
  293. //
  294. // Purpose: Creates a WBEM property from an LDAP property
  295. //
  296. // Parameters:
  297. // pWbemClass : The WBEM class in which the property is created
  298. // ppQualiferSet : The address of the pointer to IWbemQualiferSet where the qualifier set
  299. // of this property will be placed
  300. // pADSIProperty : The ADSI Property object that is being mapped to the property being created
  301. //
  302. // Return Value: The COM value representing the return status
  303. //
  304. //***************************************************************************
  305. HRESULT CreateWBEMProperty(IWbemClassObject *pWbemClass, IWbemQualifierSet **ppQualifierSet, CADSIProperty *pNextProperty);
  306. //***************************************************************************
  307. //
  308. // CLDAPClassProvider :: MapLDAPSyntaxToWBEM
  309. //
  310. // Purpose: Maps the LDAP Syntax to WBEM
  311. //
  312. // Parameters:
  313. // pADSIProperty = Pointer to the CADSIProperty object representing this attribute
  314. //
  315. // Return Value: The CIMTYPE value representing the WBEM Syntax for the LDAP Syntax. If
  316. // the syntax is unmappable, then CIM_STRING or CIM_STRING | CIM_FLAG_ARRAY is returned
  317. //
  318. //***************************************************************************
  319. CIMTYPE MapLDAPSyntaxToWBEM(CADSIProperty *pADSIProperty, BSTR *pstrCimTypeQualifier);
  320. /////////////////////////////////////
  321. /// Functions for Enumeration
  322. //////////////////////////////////////
  323. //***************************************************************************
  324. //
  325. // CLDAPClassProvider :: GetOneLevelDeep
  326. //
  327. // Purpose: Enumerates the sub classes of a superclass non-recursively
  328. //
  329. // Parameters:
  330. //
  331. // lpszSuperClass : The super class name
  332. // pResponseHandler : The interface where the resulting classes are put
  333. //
  334. //
  335. // Return Value: As described by the IWbemServices interface
  336. //
  337. //***************************************************************************
  338. HRESULT GetOneLevelDeep(
  339. LPCWSTR lpszWBEMSuperclass,
  340. BOOLEAN bArtificialClass,
  341. LPWSTR ** pppADSIClasses,
  342. DWORD *pdwNumClasses,
  343. IWbemContext *pCtx);
  344. //***************************************************************************
  345. //
  346. // CLDAPClassProvider :: HandleRecursiveEnumeration
  347. //
  348. // Purpose: Enumerates the sub classes of a superclass recursively
  349. //
  350. // Parameters:
  351. //
  352. // lpszSuperClass : The super class name
  353. // pResponseHandler : The interface where the resulting classes are put
  354. //
  355. //
  356. // Return Value: As described by the IWbemServices interface
  357. //
  358. //***************************************************************************
  359. HRESULT HandleRecursiveEnumeration(
  360. LPCWSTR lpszSuperclass,
  361. IWbemContext *pCtx,
  362. IWbemObjectSink *pResponseHandler);
  363. //***************************************************************************
  364. //
  365. // CLDAPClassProvider :: WrapUpEnumeration
  366. //
  367. // Purpose: Creates WBEM classes from ADSI classes
  368. //
  369. // Parameters:
  370. //
  371. // lpszSuperClass : The super class name
  372. // pResponseHandler : The interface where the resulting classes are put
  373. //
  374. //
  375. // Return Value: As described by the IWbemServices interface
  376. //
  377. //***************************************************************************
  378. HRESULT WrapUpEnumeration(
  379. LPWSTR *ppADSIClasses,
  380. DWORD dwNumClasses,
  381. IWbemContext *pCtx,
  382. IWbemObjectSink *pResponseHandler);
  383. //***************************************************************************
  384. //
  385. // CLDAPClassProvider :: IsConcreteClass
  386. //
  387. // Purpose: Find out whether a WBEM class is concrete. First checks in the WBEM Cache and then calls GetClassFromCacheorADSI()
  388. //
  389. // Parameters:
  390. //
  391. // pszWBEMName : The class name
  392. //
  393. //
  394. // Return Value: As described by the IWbemServices interface
  395. //
  396. //***************************************************************************
  397. HRESULT IsConcreteClass(
  398. LPCWSTR pszWBEMName,
  399. IWbemContext *pCtx);
  400. // Convert all characters to lower case
  401. void SanitizedClassName(LPWSTR lpszClassName);
  402. private:
  403. // LDAP Class attribute names
  404. static BSTR COMMON_NAME_ATTR_BSTR;
  405. static BSTR LDAP_DISPLAY_NAME_ATTR_BSTR;
  406. static BSTR GOVERNS_ID_ATTR_BSTR;
  407. static BSTR SCHEMA_ID_GUID_ATTR_BSTR;
  408. static BSTR MAPI_DISPLAY_TYPE_ATTR_BSTR;
  409. static BSTR RDN_ATT_ID_ATTR_BSTR;
  410. static BSTR SYSTEM_MUST_CONTAIN_ATTR_BSTR;
  411. static BSTR MUST_CONTAIN_ATTR_BSTR;
  412. static BSTR SYSTEM_MAY_CONTAIN_ATTR_BSTR;
  413. static BSTR MAY_CONTAIN_ATTR_BSTR;
  414. static BSTR SYSTEM_POSS_SUPERIORS_ATTR_BSTR;
  415. static BSTR POSS_SUPERIORS_ATTR_BSTR;
  416. static BSTR SYSTEM_AUXILIARY_CLASS_ATTR_BSTR;
  417. static BSTR AUXILIARY_CLASS_ATTR_BSTR;
  418. static BSTR DEFAULT_SECURITY_DESCRP_ATTR_BSTR;
  419. static BSTR OBJECT_CLASS_CATEGORY_ATTR_BSTR;
  420. static BSTR SYSTEM_ONLY_ATTR_BSTR;
  421. static BSTR NT_SECURITY_DESCRIPTOR_ATTR_BSTR;
  422. static BSTR DEFAULT_OBJECTCATEGORY_ATTR_BSTR;
  423. // Provider specific literals
  424. static BSTR LDAP_BASE_CLASS_STR;
  425. static BSTR LDAP_CLASS_PROVIDER_NAME;
  426. static BSTR LDAP_INSTANCE_PROVIDER_NAME;
  427. // WBEM Class Qualifier names
  428. static BSTR DYNAMIC_BSTR;
  429. static BSTR PROVIDER_BSTR;
  430. static BSTR ABSTRACT_BSTR;
  431. // WBEM Property Qualifier names
  432. static BSTR SYSTEM_BSTR;
  433. static BSTR NOT_NULL_BSTR;
  434. static BSTR INDEXED_BSTR;
  435. static BSTR ATTRIBUTE_SYNTAX_ATTR_BSTR;
  436. static BSTR ATTRIBUTE_ID_ATTR_BSTR;
  437. static BSTR MAPI_ID_ATTR_BSTR;
  438. static BSTR OM_SYNTAX_ATTR_BSTR;
  439. static BSTR RANGE_LOWER_ATTR_BSTR;
  440. static BSTR RANGE_UPPER_ATTR_BSTR;
  441. // Qualifiers for embedded objects
  442. static BSTR CIMTYPE_STR;
  443. static BSTR EMBED_UINT8ARRAY;
  444. static BSTR EMBED_DN_WITH_STRING;
  445. static BSTR EMBED_DN_WITH_BINARY;
  446. // WBEM Property names
  447. static BSTR DYNASTY_BSTR;
  448. // The default flavor for qualifiers
  449. static LONG DEFAULT_QUALIFIER_FLAVOUR;
  450. // These are the search preferences often used
  451. ADS_SEARCHPREF_INFO m_searchInfo1;
  452. // The LDAP property cache
  453. static CLDAPCache *s_pLDAPCache;
  454. // The base class of all the LDAP Provider Classes.
  455. IWbemClassObject *m_pLDAPBaseClass;
  456. };
  457. #endif // LDAP_CLASS_PROVIDER_H