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.

155 lines
4.6 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // dsobject.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file declares the class DSObject.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/20/1998 Original version.
  16. // 06/09/1998 Added dirty flag.
  17. // 02/11/1999 Keep downlevel parameters in sync.
  18. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20. #ifndef _DSOBJECT_H_
  21. #define _DSOBJECT_H_
  22. #include <activeds.h>
  23. #include <downlevel.h>
  24. #include <dsproperty.h>
  25. #include <dstorex.h>
  26. #include <iasdebug.h>
  27. //////////
  28. // 'Secret' UUID used to cast an interface to the implementing DSObject.
  29. //////////
  30. class __declspec(uuid("FD97280A-AA56-11D1-BB27-00C04FC2E20D")) DSObject;
  31. ///////////////////////////////////////////////////////////////////////////////
  32. //
  33. // CLASS
  34. //
  35. // DSObject
  36. //
  37. // DESCRIPTION
  38. //
  39. // This class implements an object in an Active Directory namespace.
  40. //
  41. ///////////////////////////////////////////////////////////////////////////////
  42. class DSObject
  43. : public CComObjectRootEx< CComMultiThreadModel >,
  44. public IDispatchImpl< IDataStoreObjectEx,
  45. &__uuidof(IDataStoreObject),
  46. &__uuidof(DataStore2Lib) >,
  47. public IDispatchImpl< IDataStoreContainerEx,
  48. &__uuidof(IDataStoreContainer),
  49. &__uuidof(DataStore2Lib) >
  50. {
  51. public:
  52. // An ADSI property.
  53. typedef DSProperty<&__uuidof(DataStore2Lib)> MyProperty;
  54. // A list of properties.
  55. typedef CComQIPtr< IADsPropertyList,
  56. &__uuidof(IADsPropertyList) > MyProperties;
  57. DECLARE_NO_REGISTRY()
  58. DECLARE_TRACELIFE(DSObject);
  59. BEGIN_COM_MAP(DSObject)
  60. COM_INTERFACE_ENTRY_IID(__uuidof(DSObject), DSObject)
  61. COM_INTERFACE_ENTRY(IDataStoreObject)
  62. COM_INTERFACE_ENTRY_FUNC(__uuidof(IDataStoreContainer), 0, getContainer)
  63. COM_INTERFACE_ENTRY2(IDispatch, IDataStoreObject)
  64. END_COM_MAP()
  65. DSObject(IUnknown* subject);
  66. ~DSObject() throw ();
  67. // Create a child DSObject.
  68. IDataStoreObject* spawn(IUnknown* subject);
  69. //////////
  70. // IUnknown
  71. // I did not use CComObject<> because I need to deal with DSObject's directly.
  72. //////////
  73. STDMETHOD_(ULONG, AddRef)();
  74. STDMETHOD_(ULONG, Release)();
  75. STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
  76. //////////
  77. // IDataStoreObject
  78. //////////
  79. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR* pVal);
  80. STDMETHOD(get_Class)(/*[out, retval]*/ BSTR* pVal);
  81. STDMETHOD(get_GUID)(/*[out, retval]*/ BSTR* pVal);
  82. STDMETHOD(get_Container)(/*[out, retval]*/ IDataStoreContainer** pVal);
  83. STDMETHOD(GetValue)(/*[in]*/ BSTR bstrName, /*[out, retval]*/ VARIANT* pVal);
  84. STDMETHOD(GetValueEx)(/*[in]*/ BSTR bstrName,
  85. /*[out, retval]*/ VARIANT* pVal);
  86. STDMETHOD(PutValue)(/*[in]*/ BSTR bstrName, /*[in]*/ VARIANT* pVal);
  87. STDMETHOD(Update)();
  88. STDMETHOD(Restore)();
  89. STDMETHOD(Item)(BSTR bstrName, IDataStoreProperty** pVal);
  90. //////////
  91. // IDataStoreObjectEx
  92. //////////
  93. STDMETHOD(get_PropertyCount)(long* pVal);
  94. STDMETHOD(get_NewPropertyEnum)(IUnknown** pVal);
  95. //////////
  96. // IDataStoreContainer
  97. //////////
  98. STDMETHOD(Item)(/*[in]*/ BSTR bstrName,
  99. /*[out, retval]*/ IDataStoreObject** ppObject);
  100. STDMETHOD(Create)(/*[in]*/ BSTR bstrClass,
  101. /*[in]*/ BSTR bstrName,
  102. /*[out, retval]*/ IDataStoreObject** ppObject);
  103. STDMETHOD(MoveHere)(/*[in]*/ IDataStoreObject* pObject,
  104. /*[in]*/ BSTR bstrNewName);
  105. STDMETHOD(Remove)(/*[in]*/ BSTR bstrClass, /*[in]*/ BSTR bstrName);
  106. //////////
  107. // IDataStoreContainerEx
  108. //////////
  109. STDMETHOD(get_ChildCount)(/*[out, retval]*/ long *pVal);
  110. STDMETHOD(get_NewChildEnum)(/*[out, retval]*/ IUnknown** pVal);
  111. protected:
  112. // Narrows a COM Interface to the implementing DSObject.
  113. static DSObject* narrow(IUnknown* p);
  114. // Used to QI for IDataStoreContainer.
  115. static HRESULT WINAPI getContainer(void* pv, REFIID, LPVOID* ppv, DWORD_PTR)
  116. throw ();
  117. // Different representations of the subject.
  118. CComPtr<IADs> leaf;
  119. CComPtr<IADsContainer> node;
  120. // TRUE if the object has been modified since the last GetInfo.
  121. BOOL dirty;
  122. // The downlevel attributes.
  123. BSTR oldParms;
  124. DownlevelUser downlevel;
  125. // The prefix added to all RDN's.
  126. static _bstr_t thePrefix;
  127. // Well-known property names.
  128. static _bstr_t theNameProperty;
  129. static _bstr_t theUserParametersProperty;
  130. };
  131. #endif // _DSOBJECT_H_