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.

427 lines
12 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:adsiprop.cpp $
  11. //
  12. // $Modtime: 6/11/98 11:21a $
  13. // $Revision: 1 $
  14. // $Nokeywords: $
  15. //
  16. //
  17. // Description: Contains the implementation of the CADSIProperty which encapsulates an ADSI property
  18. //
  19. //***************************************************************************
  20. #include "precomp.h"
  21. //***************************************************************************
  22. //
  23. // CADSIProperty::CADSIProperty
  24. //
  25. // Purpose : Constructor
  26. //
  27. // Parameters:
  28. // None
  29. //***************************************************************************
  30. CADSIProperty :: CADSIProperty()
  31. : CRefCountedObject(),
  32. m_lpszWBEMPropertyName ( NULL ),
  33. m_lpszSyntaxOID ( NULL ),
  34. m_bMultiValued ( FALSE ),
  35. m_lpszAttributeID ( NULL ),
  36. m_lpszCommonName ( NULL ),
  37. m_bSystemOnly ( FALSE ),
  38. m_pDirectoryObject ( NULL ),
  39. m_bORName ( FALSE )
  40. {
  41. }
  42. //***************************************************************************
  43. //
  44. // CADSIProperty::CADSIProperty
  45. //
  46. // Purpose : Constructor
  47. //
  48. // Parameters:
  49. // lpszWBEMPropertyName : The WBEM name of the property being created. A copy of this is made
  50. // lpszADSIPropertyName : The ADSI name of the property being created. A copy of this is made
  51. //***************************************************************************
  52. CADSIProperty :: CADSIProperty(LPCWSTR lpszWBEMPropertyName, LPCWSTR lpszADSIPropertyName)
  53. : CRefCountedObject(lpszADSIPropertyName),
  54. m_lpszWBEMPropertyName ( NULL ),
  55. m_lpszSyntaxOID ( NULL ),
  56. m_bMultiValued ( FALSE ),
  57. m_lpszAttributeID ( NULL ),
  58. m_lpszCommonName ( NULL ),
  59. m_bSystemOnly ( FALSE ),
  60. m_pDirectoryObject ( NULL ),
  61. m_bORName ( FALSE )
  62. {
  63. m_lpszWBEMPropertyName = new WCHAR[wcslen(lpszWBEMPropertyName) + 1];
  64. wcscpy(m_lpszWBEMPropertyName, lpszWBEMPropertyName);
  65. }
  66. //***************************************************************************
  67. //
  68. // CADSIProperty :: ~CADSIProperty
  69. //
  70. // Purpose : Destructor
  71. //***************************************************************************
  72. CADSIProperty :: ~CADSIProperty()
  73. {
  74. if (m_lpszWBEMPropertyName)
  75. {
  76. delete [] m_lpszWBEMPropertyName;
  77. }
  78. if (m_lpszSyntaxOID)
  79. {
  80. delete [] m_lpszSyntaxOID;
  81. }
  82. if (m_lpszAttributeID)
  83. {
  84. delete [] m_lpszAttributeID;
  85. }
  86. if (m_lpszCommonName)
  87. {
  88. delete [] m_lpszCommonName;
  89. }
  90. if(m_pDirectoryObject)
  91. m_pDirectoryObject->Release();
  92. }
  93. //***************************************************************************
  94. //
  95. // CADSIProperty :: GetWBEMPropertyName
  96. //
  97. // Purpose : Returns the WBEM property name of this property
  98. //***************************************************************************
  99. LPCWSTR CADSIProperty :: GetWBEMPropertyName()
  100. {
  101. return m_lpszWBEMPropertyName;
  102. }
  103. //***************************************************************************
  104. //
  105. // CADSIProperty :: SetWBEMPropertyName
  106. //
  107. // Purpose : Sets the WBEM name of this property
  108. //***************************************************************************
  109. void CADSIProperty :: SetWBEMPropertyName(LPCWSTR lpszWBEMName)
  110. {
  111. if (m_lpszWBEMPropertyName)
  112. {
  113. delete [] m_lpszWBEMPropertyName;
  114. m_lpszWBEMPropertyName = NULL;
  115. }
  116. if(lpszWBEMName)
  117. {
  118. m_lpszWBEMPropertyName = new WCHAR[wcslen(lpszWBEMName) + 1];
  119. wcscpy(m_lpszWBEMPropertyName, lpszWBEMName);
  120. }
  121. }
  122. //***************************************************************************
  123. //
  124. // CADSIProperty :: GetADSIPropertyName
  125. //
  126. // Purpose : Returns the ADSI property name of this property
  127. //***************************************************************************
  128. LPCWSTR CADSIProperty :: GetADSIPropertyName()
  129. {
  130. return GetName();
  131. }
  132. //***************************************************************************
  133. //
  134. // CADSIProperty :: SetADSIPropertyName
  135. //
  136. // Purpose : Sets the ADSI name of this property
  137. //***************************************************************************
  138. void CADSIProperty :: SetADSIPropertyName(LPCWSTR lpszADSIName)
  139. {
  140. SetName(lpszADSIName);
  141. }
  142. //***************************************************************************
  143. //
  144. // CADSIProperty :: GetSyntaxOID
  145. //
  146. // Purpose : Returns the ADSI Syntax OID of this property
  147. //***************************************************************************
  148. LPCWSTR CADSIProperty :: GetSyntaxOID()
  149. {
  150. return m_lpszSyntaxOID;
  151. }
  152. //***************************************************************************
  153. //
  154. // CADSIProperty :: SetSyntaxOID
  155. //
  156. // Purpose : Sets the ADSI Syntax OID of this property
  157. //***************************************************************************
  158. void CADSIProperty :: SetSyntaxOID(LPCWSTR lpszSyntaxOID)
  159. {
  160. if (m_lpszSyntaxOID)
  161. {
  162. delete [] m_lpszSyntaxOID;
  163. m_lpszSyntaxOID = NULL;
  164. }
  165. if(lpszSyntaxOID)
  166. {
  167. m_lpszSyntaxOID = new WCHAR[wcslen(lpszSyntaxOID) + 1];
  168. wcscpy(m_lpszSyntaxOID, lpszSyntaxOID);
  169. }
  170. }
  171. //***************************************************************************
  172. //
  173. // CADSIProperty :: IsORName
  174. //
  175. // Purpose : Returns whether the property is m_bORName
  176. //***************************************************************************
  177. BOOLEAN CADSIProperty :: IsORName()
  178. {
  179. return m_bORName;
  180. }
  181. //***************************************************************************
  182. //
  183. // CADSIProperty :: SetORName
  184. //
  185. // Purpose : Sets the m_bORName property of this property
  186. //***************************************************************************
  187. void CADSIProperty :: SetORName(BOOLEAN bORName)
  188. {
  189. m_bORName = bORName;
  190. }
  191. //***************************************************************************
  192. //
  193. // CADSIProperty :: IsMultiValued
  194. //
  195. // Purpose : Returns whether the property is multi valued
  196. //***************************************************************************
  197. BOOLEAN CADSIProperty :: IsMultiValued()
  198. {
  199. return m_bMultiValued;
  200. }
  201. //***************************************************************************
  202. //
  203. // CADSIProperty :: SetMultiValued
  204. //
  205. // Purpose : Sets the multi-valued property of this property
  206. //***************************************************************************
  207. void CADSIProperty :: SetMultiValued(BOOLEAN bMultiValued)
  208. {
  209. m_bMultiValued = bMultiValued;
  210. }
  211. //***************************************************************************
  212. //
  213. // CADSIProperty :: IsSystemOnly
  214. //
  215. // Purpose : Returns whether the property is SystemOnly
  216. //***************************************************************************
  217. BOOLEAN CADSIProperty :: IsSystemOnly()
  218. {
  219. return m_bSystemOnly;
  220. }
  221. //***************************************************************************
  222. //
  223. // CADSIProperty :: SetSystemOnly
  224. //
  225. // Purpose : Sets the SystemOnly property of this property
  226. //***************************************************************************
  227. void CADSIProperty :: SetSystemOnly(BOOLEAN bSystemOnly)
  228. {
  229. m_bSystemOnly = bSystemOnly;
  230. }
  231. //***************************************************************************
  232. //
  233. // CADSIProperty :: GetSearchFlags
  234. //
  235. // Purpose : Returns the SearchFlags property of the property
  236. //***************************************************************************
  237. DWORD CADSIProperty :: GetSearchFlags()
  238. {
  239. return m_dwSearchFlags;
  240. }
  241. //***************************************************************************
  242. //
  243. // CADSIProperty :: SetSearchFlags
  244. //
  245. // Purpose : Sets the SearchFlags property of this property
  246. //***************************************************************************
  247. void CADSIProperty :: SetSearchFlags(DWORD dwSearchFlags)
  248. {
  249. m_dwSearchFlags = dwSearchFlags;
  250. }
  251. //***************************************************************************
  252. //
  253. // CADSIProperty :: GetOMSyntax
  254. //
  255. // Purpose : Returns the OMSyntax property of the property
  256. //***************************************************************************
  257. DWORD CADSIProperty :: GetOMSyntax()
  258. {
  259. return m_dwOMSyntax;
  260. }
  261. //***************************************************************************
  262. //
  263. // CADSIProperty :: SetOMSyntax
  264. //
  265. // Purpose : Sets the OMSyntax property of this property
  266. //***************************************************************************
  267. void CADSIProperty :: SetOMSyntax(DWORD dwOMSyntax)
  268. {
  269. m_dwOMSyntax = dwOMSyntax;
  270. }
  271. //***************************************************************************
  272. //
  273. // CADSIProperty :: GetMAPI_ID
  274. //
  275. // Purpose : Returns the MAPI_ID property of the property
  276. //***************************************************************************
  277. DWORD CADSIProperty :: GetMAPI_ID()
  278. {
  279. return m_dwMAPI_ID;
  280. }
  281. //***************************************************************************
  282. //
  283. // CADSIProperty :: SetMAPI_ID
  284. //
  285. // Purpose : Sets the MAPI_ID property of this property
  286. //***************************************************************************
  287. void CADSIProperty :: SetMAPI_ID(DWORD dwMAPI_ID)
  288. {
  289. m_dwMAPI_ID = dwMAPI_ID;
  290. }
  291. //***************************************************************************
  292. //
  293. // CADSIProperty :: GetAttributeID
  294. //
  295. // Purpose : Returns the Attribute ID of this property
  296. //***************************************************************************
  297. LPCWSTR CADSIProperty :: GetAttributeID()
  298. {
  299. return m_lpszAttributeID;
  300. }
  301. //***************************************************************************
  302. //
  303. // CADSIProperty :: SetAttributeID
  304. //
  305. // Purpose : Sets the Attribute ID of this property
  306. //***************************************************************************
  307. void CADSIProperty :: SetAttributeID(LPCWSTR lpszAttributeID)
  308. {
  309. if ( m_lpszAttributeID )
  310. {
  311. delete [] m_lpszAttributeID;
  312. m_lpszAttributeID = NULL;
  313. }
  314. if(lpszAttributeID)
  315. {
  316. m_lpszAttributeID = new WCHAR[wcslen(lpszAttributeID) + 1];
  317. wcscpy(m_lpszAttributeID, lpszAttributeID);
  318. }
  319. }
  320. //***************************************************************************
  321. //
  322. // CADSIProperty :: GetCommonName
  323. //
  324. // Purpose : Returns the Common Name of this property
  325. //***************************************************************************
  326. LPCWSTR CADSIProperty :: GetCommonName()
  327. {
  328. return m_lpszCommonName;
  329. }
  330. //***************************************************************************
  331. //
  332. // CADSIProperty :: SetCommonName
  333. //
  334. // Purpose : Sets the CommonName of this property
  335. //***************************************************************************
  336. void CADSIProperty :: SetCommonName(LPCWSTR lpszCommonName)
  337. {
  338. if (m_lpszCommonName)
  339. {
  340. delete [] m_lpszCommonName;
  341. m_lpszCommonName = NULL;
  342. }
  343. if(lpszCommonName)
  344. {
  345. m_lpszCommonName = new WCHAR[wcslen(lpszCommonName) + 1];
  346. wcscpy(m_lpszCommonName, lpszCommonName);
  347. }
  348. }
  349. //***************************************************************************
  350. //
  351. // CADSIProperty :: GetDirectoryObject
  352. //
  353. // Purpose : Returns the ADSI object pertaining to this property
  354. // It is the user's duty to release it when done
  355. //
  356. // Parameters:
  357. // None
  358. //
  359. // Return Value:
  360. // The ADSI object interface pertaining to this property
  361. //***************************************************************************
  362. IDirectoryObject *CADSIProperty :: GetDirectoryObject()
  363. {
  364. if(m_pDirectoryObject)
  365. m_pDirectoryObject->AddRef();
  366. return m_pDirectoryObject;
  367. }
  368. //***************************************************************************
  369. //
  370. // CADSIProperty :: SetDirectoryObject
  371. //
  372. // Purpose : Sets the ADSI object pertaining to this property
  373. //
  374. // Parameter : The directory object pertaining to this property
  375. //***************************************************************************
  376. void CADSIProperty :: SetDirectoryObject(IDirectoryObject * pDirectoryObject)
  377. {
  378. if(m_pDirectoryObject)
  379. m_pDirectoryObject->Release();
  380. m_pDirectoryObject = pDirectoryObject;
  381. m_pDirectoryObject->AddRef();
  382. }