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.

134 lines
3.6 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:adsiinst.cpp $
  11. //
  12. // $Modtime: 6/11/98 11:21a $
  13. // $Revision: 1 $
  14. // $Nokeywords: $
  15. //
  16. //
  17. // Description: Contains the implementation of the CADSIInstance which encapsulates an ADSI instance
  18. //
  19. //***************************************************************************
  20. #include "precomp.h"
  21. //***************************************************************************
  22. //
  23. // CADSIInstance::CADSIInstance
  24. //
  25. // Purpose : Constructor
  26. //
  27. // Parameters:
  28. // lpszADSIPath : The ADSI Path to the object
  29. //***************************************************************************
  30. CADSIInstance :: CADSIInstance(LPCWSTR lpszADSIPath, IDirectoryObject *pDirectoryObject)
  31. : CRefCountedObject(lpszADSIPath)
  32. {
  33. m_pAttributes = NULL;
  34. m_dwNumAttributes = 0;
  35. m_pObjectInfo = NULL;
  36. m_pDirectoryObject = pDirectoryObject;
  37. m_pDirectoryObject->AddRef();
  38. }
  39. //***************************************************************************
  40. //
  41. // CADSIInstance :: ~CADSIInstance
  42. //
  43. // Purpose : Destructor
  44. //***************************************************************************
  45. CADSIInstance :: ~CADSIInstance()
  46. {
  47. // Free the attributes
  48. if(m_pAttributes)
  49. FreeADsMem((LPVOID *) m_pAttributes);
  50. if(m_pObjectInfo)
  51. FreeADsMem((LPVOID *) m_pObjectInfo);
  52. if(m_pDirectoryObject)
  53. m_pDirectoryObject->Release();
  54. }
  55. IDirectoryObject *CADSIInstance :: GetDirectoryObject()
  56. {
  57. m_pDirectoryObject->AddRef();
  58. return m_pDirectoryObject;
  59. }
  60. //***************************************************************************
  61. //
  62. // CADSIInstance :: GetAttributes
  63. //
  64. // Purpose : See header for details
  65. //***************************************************************************
  66. PADS_ATTR_INFO CADSIInstance :: GetAttributes(DWORD *pdwNumAttributes)
  67. {
  68. *pdwNumAttributes = m_dwNumAttributes;
  69. return m_pAttributes;
  70. }
  71. //***************************************************************************
  72. //
  73. // CADSIInstance :: SetAttributes
  74. //
  75. // Purpose : See header for details
  76. //***************************************************************************
  77. void CADSIInstance :: SetAttributes(PADS_ATTR_INFO pAttributes, DWORD dwNumAttributes)
  78. {
  79. // Go thru the attributes and release them
  80. if(m_pAttributes)
  81. FreeADsMem((LPVOID *) m_pAttributes);
  82. m_pAttributes = pAttributes;
  83. m_dwNumAttributes = dwNumAttributes;
  84. }
  85. //***************************************************************************
  86. //
  87. // CADSIInstance :: GetObjectInfo
  88. //
  89. // Purpose : See header for details
  90. //***************************************************************************
  91. PADS_OBJECT_INFO CADSIInstance :: GetObjectInfo()
  92. {
  93. return m_pObjectInfo;
  94. }
  95. //***************************************************************************
  96. //
  97. // CADSIInstance :: SetObjectInfo
  98. //
  99. // Purpose : See header for details
  100. //***************************************************************************
  101. void CADSIInstance :: SetObjectInfo(PADS_OBJECT_INFO pObjectInfo)
  102. {
  103. // Go thru the attributes and release them
  104. if(m_pObjectInfo)
  105. FreeADsMem((LPVOID *) m_pObjectInfo);
  106. m_pObjectInfo = pObjectInfo;
  107. }
  108. //***************************************************************************
  109. //
  110. // CADSIInstance :: GetADSIClassName
  111. //
  112. // Purpose : See header for details
  113. //***************************************************************************
  114. LPCWSTR CADSIInstance :: GetADSIClassName()
  115. {
  116. if(m_pObjectInfo)
  117. return m_pObjectInfo->pszClassName;
  118. return NULL;
  119. }