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.

207 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. rndnt.h
  5. Abstract:
  6. Definitions for CNTDirectory class that handles NTDS access.
  7. Author:
  8. Mu Han (muhan) 12-5-1997
  9. --*/
  10. #ifndef __RNDNT_H
  11. #define __RNDNT_H
  12. #pragma once
  13. #include "rndcommc.h"
  14. #include "rndobjsf.h"
  15. #include "rndutil.h"
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CNTDirectory
  18. /////////////////////////////////////////////////////////////////////////////
  19. const WCHAR DEFAULT_DS_SERVER[] = L"";
  20. const WCHAR DS_USER_FILTER_FORMAT[] = L"(&(SamAccountName=%s)(objectclass=user)(!(objectclass=computer)))";
  21. // The following are no longer used:
  22. // const WCHAR USERS_CONTAINER[] = L"cn=Users,";
  23. // const WCHAR MEETINGSS_CONTAINER[] = L"cn=Meetings,cn=System,";
  24. // const WCHAR DS_CONF_DN_FORMAT[] = L"cn=%s,cn=Meetings,cn=system,%s";
  25. const WORD GLOBAL_CATALOG_PORT = 3268;
  26. class CNTDirectory :
  27. public CComDualImpl<ITDirectory, &IID_ITDirectory, &LIBID_RENDLib>,
  28. public CComObjectRootEx<CComObjectThreadModel>,
  29. public CObjectSafeImpl
  30. {
  31. DECLARE_GET_CONTROLLING_UNKNOWN()
  32. public:
  33. BEGIN_COM_MAP(CNTDirectory)
  34. COM_INTERFACE_ENTRY(IDispatch)
  35. COM_INTERFACE_ENTRY(ITDirectory)
  36. COM_INTERFACE_ENTRY(IObjectSafety)
  37. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  38. END_COM_MAP()
  39. //DECLARE_NOT_AGGREGATABLE(CNTDirectory)
  40. // Remove the comment from the line above if you don't want your object to
  41. // support aggregation.
  42. // ITDirectory
  43. STDMETHOD (get_DirectoryType) (
  44. OUT DIRECTORY_TYPE * pDirectoryType
  45. );
  46. STDMETHOD (get_DisplayName) (
  47. OUT BSTR *ppName
  48. );
  49. STDMETHOD (get_IsDynamic) (
  50. OUT VARIANT_BOOL *pfDynamic
  51. );
  52. STDMETHOD (get_DefaultObjectTTL) (
  53. OUT long *pTTL // in seconds
  54. );
  55. STDMETHOD (put_DefaultObjectTTL) (
  56. IN long TTL // in sechods
  57. );
  58. STDMETHOD (EnableAutoRefresh) (
  59. IN VARIANT_BOOL fEnable
  60. );
  61. STDMETHOD (Connect) (
  62. IN VARIANT_BOOL fSecure
  63. );
  64. STDMETHOD (Bind) (
  65. IN BSTR pDomainName,
  66. IN BSTR pUserName,
  67. IN BSTR pPassword,
  68. IN long lFlags
  69. );
  70. STDMETHOD (AddDirectoryObject) (
  71. IN ITDirectoryObject *pDirectoryObject
  72. );
  73. STDMETHOD (ModifyDirectoryObject) (
  74. IN ITDirectoryObject *pDirectoryObject
  75. );
  76. STDMETHOD (RefreshDirectoryObject) (
  77. IN ITDirectoryObject *pDirectoryObject
  78. );
  79. STDMETHOD (DeleteDirectoryObject) (
  80. IN ITDirectoryObject *pDirectoryObject
  81. );
  82. STDMETHOD (get_DirectoryObjects) (
  83. IN DIRECTORY_OBJECT_TYPE DirectoryObjectType,
  84. IN BSTR pName,
  85. OUT VARIANT * pVariant
  86. );
  87. STDMETHOD (EnumerateDirectoryObjects) (
  88. IN DIRECTORY_OBJECT_TYPE DirectoryObjectType,
  89. IN BSTR pName,
  90. OUT IEnumDirectoryObject ** ppEnumObject
  91. );
  92. public:
  93. CNTDirectory()
  94. : m_Type(DT_NTDS),
  95. m_ldap(NULL),
  96. m_ldapNonGC(NULL),
  97. m_NamingContext(NULL),
  98. m_IsSsl(FALSE),
  99. m_wPort(GLOBAL_CATALOG_PORT),
  100. m_pFTM(NULL)
  101. {}
  102. ~CNTDirectory()
  103. {
  104. if ( m_ldap )
  105. {
  106. ldap_unbind(m_ldap);
  107. }
  108. if ( m_ldapNonGC )
  109. {
  110. ldap_unbind(m_ldapNonGC);
  111. }
  112. if ( m_pFTM )
  113. {
  114. m_pFTM->Release();
  115. }
  116. delete m_NamingContext;
  117. }
  118. HRESULT FinalConstruct(void);
  119. protected:
  120. HRESULT LdapSearchUser(
  121. IN TCHAR * pName,
  122. OUT LDAPMessage ** ppLdapMsg
  123. );
  124. HRESULT MakeUserDNs(
  125. IN TCHAR * pName,
  126. OUT TCHAR *** pppDNs,
  127. OUT DWORD * pdwNumDNs
  128. );
  129. HRESULT AddUserIPPhone(
  130. IN ITDirectoryObject * pDirectoryObject
  131. );
  132. HRESULT DeleteUserIPPhone(
  133. IN ITDirectoryObject * pDirectoryObject
  134. );
  135. HRESULT CreateUser(
  136. IN LDAPMessage * pEntry,
  137. IN ITDirectoryObject ** ppObject
  138. );
  139. HRESULT SearchUser(
  140. IN BSTR pName,
  141. OUT ITDirectoryObject *** pppDirectoryObject,
  142. OUT DWORD * pdwSize
  143. );
  144. private:
  145. CCritSection m_lock;
  146. DIRECTORY_TYPE m_Type;
  147. LDAP * m_ldap;
  148. LDAP * m_ldapNonGC;
  149. TCHAR * m_NamingContext;
  150. BOOL m_IsSsl;
  151. WORD m_wPort;
  152. IUnknown * m_pFTM; // pointer to the free threaded marshaler
  153. };
  154. #endif