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.

379 lines
9.4 KiB

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