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.

363 lines
9.1 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. rndils.h
  5. Abstract:
  6. Definitions for CILSDirectory class that handles ILS access.
  7. --*/
  8. #ifndef __RNDILS_H
  9. #define __RNDILS_H
  10. #pragma once
  11. #include "thread.h"
  12. #include "rndobjsf.h"
  13. //
  14. // Some constants.
  15. //
  16. const WCHAR ILS_IPADDRESS[] = L"ipAddress";
  17. const WCHAR ILS_UIDEQUALS[] = L"uid=";
  18. const WCHAR ILS_CONF_DN_FORMAT[] = L"uid=%s,%s";
  19. const WCHAR ILS_RTCONFERENCE[] = L"RTConference";
  20. const WCHAR ILS_RTPERSON[] = L"RTPerson";
  21. const WCHAR NETMEETING_CONTAINER[] = L"appName=MS-NetMeeting,ou=applications,";
  22. const WCHAR RTAPPLICATIONUSER[] = L"RTApplicationUser";
  23. const WCHAR EMAIL[] = L"rfc822mailbox";
  24. const WCHAR GIVEN_NAME[] = L"givenName"; // vocabulary word: this means "first name"
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CILSDirectory
  27. /////////////////////////////////////////////////////////////////////////////
  28. template <class T>
  29. class ITDirectoryVtbl : public ITDirectory
  30. {
  31. };
  32. template <class T>
  33. class ITILSConfigVtbl : public ITILSConfig
  34. {
  35. };
  36. class CILSDirectory :
  37. public CComDualImpl<ITDirectoryVtbl<CILSDirectory>, &IID_ITDirectory, &LIBID_RENDLib>,
  38. public CComDualImpl<ITILSConfigVtbl<CILSDirectory>, &IID_ITILSConfig, &LIBID_RENDLib>,
  39. public ITDynamicDirectory,
  40. public CComObjectRootEx<CComObjectThreadModel>,
  41. public CObjectSafeImpl
  42. {
  43. /* ZoltanS debugging... */
  44. private:
  45. HRESULT AddConferenceComplete(BOOL fModify,
  46. LDAP * ldap,
  47. TCHAR ** ppDN,
  48. LDAPMod ** mods,
  49. DWORD TTL1,
  50. DWORD TTL2);
  51. public:
  52. BEGIN_COM_MAP(CILSDirectory)
  53. COM_INTERFACE_ENTRY2(IDispatch, ITDirectory)
  54. COM_INTERFACE_ENTRY(ITILSConfig)
  55. COM_INTERFACE_ENTRY(ITDirectory)
  56. COM_INTERFACE_ENTRY(ITDynamicDirectory)
  57. COM_INTERFACE_ENTRY(IObjectSafety)
  58. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  59. END_COM_MAP()
  60. DECLARE_NOT_AGGREGATABLE(CILSDirectory)
  61. DECLARE_GET_CONTROLLING_UNKNOWN()
  62. public:
  63. // ITILSConfig
  64. STDMETHOD (get_Port) (
  65. OUT long *Port
  66. );
  67. STDMETHOD (put_Port) (
  68. IN long Port
  69. );
  70. // ITDirectory
  71. STDMETHOD (get_DirectoryType) (
  72. OUT DIRECTORY_TYPE * pDirectoryType
  73. );
  74. STDMETHOD (get_DisplayName) (
  75. OUT BSTR *ppName
  76. );
  77. STDMETHOD (get_IsDynamic) (
  78. OUT VARIANT_BOOL *pfDynamic
  79. );
  80. STDMETHOD (get_DefaultObjectTTL) (
  81. OUT long *pTTL // in seconds
  82. );
  83. STDMETHOD (put_DefaultObjectTTL) (
  84. IN long TTL // in sechods
  85. );
  86. STDMETHOD (EnableAutoRefresh) (
  87. IN VARIANT_BOOL fEnable
  88. );
  89. STDMETHOD (Connect)(
  90. IN VARIANT_BOOL fSecure
  91. );
  92. STDMETHOD (Bind) (
  93. IN BSTR pDomainName,
  94. IN BSTR pUserName,
  95. IN BSTR pPassword,
  96. IN long lFlags
  97. );
  98. STDMETHOD (AddDirectoryObject) (
  99. IN ITDirectoryObject *pDirectoryObject
  100. );
  101. STDMETHOD (ModifyDirectoryObject) (
  102. IN ITDirectoryObject *pDirectoryObject
  103. );
  104. STDMETHOD (RefreshDirectoryObject) (
  105. IN ITDirectoryObject *pDirectoryObject
  106. );
  107. STDMETHOD (DeleteDirectoryObject) (
  108. IN ITDirectoryObject *pDirectoryObject
  109. );
  110. STDMETHOD (get_DirectoryObjects) (
  111. IN DIRECTORY_OBJECT_TYPE DirectoryObjectType,
  112. IN BSTR pName,
  113. OUT VARIANT * pVariant
  114. );
  115. STDMETHOD (EnumerateDirectoryObjects) (
  116. IN DIRECTORY_OBJECT_TYPE DirectoryObjectType,
  117. IN BSTR pName,
  118. OUT IEnumDirectoryObject ** ppEnumObject
  119. );
  120. //
  121. // IDispatch methods
  122. //
  123. STDMETHOD(GetIDsOfNames)(REFIID riid,
  124. LPOLESTR* rgszNames,
  125. UINT cNames,
  126. LCID lcid,
  127. DISPID* rgdispid
  128. );
  129. STDMETHOD(Invoke)(DISPID dispidMember,
  130. REFIID riid,
  131. LCID lcid,
  132. WORD wFlags,
  133. DISPPARAMS* pdispparams,
  134. VARIANT* pvarResult,
  135. EXCEPINFO* pexcepinfo,
  136. UINT* puArgErr
  137. );
  138. // ITDynamicDirectory
  139. STDMETHOD(Update)(DWORD dwSecondsPassed);
  140. public:
  141. CILSDirectory()
  142. : m_Type(DT_ILS),
  143. m_pServerName(NULL),
  144. m_ldap(NULL),
  145. m_pContainer(NULL),
  146. m_pNMContainer(NULL),
  147. m_IsSsl(FALSE),
  148. m_TTL(ILS_UPDATE_INTERVAL),
  149. m_fAutoRefresh(FALSE),
  150. m_dwInterfaceAddress(0),
  151. m_pFTM(NULL)
  152. {}
  153. virtual HRESULT FinalConstruct(void);
  154. ~CILSDirectory()
  155. {
  156. if ( m_pFTM )
  157. {
  158. m_pFTM->Release();
  159. }
  160. if (m_ldap)
  161. {
  162. ldap_unbind(m_ldap);
  163. }
  164. delete m_pServerName;
  165. delete m_pContainer;
  166. delete m_pNMContainer;
  167. //
  168. // We new'ed the DN strings in the refresh table. The destructor for
  169. // the table will be called after this destructor and will delete
  170. // the array itself.
  171. //
  172. for ( DWORD i = 0; i < m_RefreshTable.size(); i++ )
  173. {
  174. delete m_RefreshTable[i].pDN;
  175. }
  176. }
  177. HRESULT Init(
  178. IN const TCHAR * const strServerName,
  179. IN const WORD wPort
  180. );
  181. static const WCHAR * RTConferenceAttributeName(int attribute)
  182. { return s_RTConferenceAttributes[MeetingAttrIndex(attribute)]; }
  183. static const WCHAR * RTPersonAttributeName(int attribute)
  184. { return s_RTPersonAttributes[UserAttrIndex(attribute)]; }
  185. private:
  186. HRESULT TryServer(
  187. IN WORD Port
  188. );
  189. HRESULT MakeConferenceDN(
  190. IN TCHAR * pName,
  191. OUT TCHAR ** ppDN
  192. );
  193. HRESULT MakeUserCN(
  194. IN TCHAR * pName,
  195. IN TCHAR * pAddress,
  196. OUT TCHAR ** ppCN,
  197. OUT DWORD * pdwIP
  198. );
  199. HRESULT MakeUserDN(
  200. IN TCHAR * pCN,
  201. OUT TCHAR ** ppDNRTPerson,
  202. OUT TCHAR ** ppDNNMPerson
  203. );
  204. HRESULT PublishRTPerson(
  205. IN TCHAR * pCN,
  206. IN TCHAR * pDN,
  207. IN TCHAR * pIPAddress,
  208. IN DWORD dwTTL,
  209. IN BOOL fModify,
  210. IN char * pSD,
  211. IN DWORD dwSDSize
  212. );
  213. HRESULT PublishNMPerson(
  214. IN TCHAR * pCN,
  215. IN TCHAR * pDN,
  216. IN TCHAR * pDNRTPerson,
  217. IN DWORD dwTTL,
  218. IN BOOL fModify,
  219. IN char * pSD,
  220. IN DWORD dwSDSize
  221. );
  222. HRESULT AddConference(
  223. IN ITDirectoryObject *pDirectoryObject,
  224. IN BOOL fModify
  225. );
  226. HRESULT TestAclSafety(
  227. IN char * pSD,
  228. IN DWORD dwSDSize
  229. );
  230. HRESULT AddUser(
  231. IN ITDirectoryObject *pDirectoryObject,
  232. IN BOOL fModify
  233. );
  234. HRESULT DeleteConference(
  235. IN ITDirectoryObject *pDirectoryObject
  236. );
  237. HRESULT DeleteUser(
  238. IN ITDirectoryObject *pDirectoryObject
  239. );
  240. HRESULT RefreshUser(
  241. IN ITDirectoryObject *pDirectoryObject
  242. );
  243. HRESULT CreateConference(
  244. IN LDAPMessage * pEntry,
  245. OUT ITDirectoryObject ** ppObject
  246. );
  247. HRESULT CreateUser(
  248. IN LDAPMessage * pEntry,
  249. IN ITDirectoryObject ** ppObject
  250. );
  251. HRESULT SearchObjects(
  252. IN DIRECTORY_OBJECT_TYPE DirectoryObjectType,
  253. IN BSTR pName,
  254. OUT ITDirectoryObject *** pppDirectoryObject,
  255. OUT DWORD * dwSize
  256. );
  257. HRESULT AddObjectToRefresh(
  258. IN WCHAR *pDN,
  259. IN long TTL
  260. );
  261. HRESULT RemoveObjectToRefresh(
  262. IN WCHAR *pDN
  263. );
  264. HRESULT DiscoverInterface(void);
  265. private:
  266. static const WCHAR * const s_RTConferenceAttributes[];
  267. static const WCHAR * const s_RTPersonAttributes[];
  268. CCritSection m_lock;
  269. DIRECTORY_TYPE m_Type;
  270. TCHAR * m_pServerName;
  271. WORD m_wPort;
  272. LDAP * m_ldap;
  273. TCHAR * m_pContainer;
  274. TCHAR * m_pNMContainer;
  275. BOOL m_IsSsl;
  276. long m_TTL;
  277. BOOL m_fAutoRefresh;
  278. RefreshTable m_RefreshTable;
  279. // the local IP we should use when publishing on this server
  280. // Stored in network byte order.
  281. DWORD m_dwInterfaceAddress;
  282. IUnknown * m_pFTM; // pointer to the free threaded marshaler
  283. };
  284. #endif