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.

127 lines
3.1 KiB

  1. /* ----------------------------------------------------------------------
  2. Module: ULS.DLL (Service Provider)
  3. File: spconn.h
  4. Content: This file contains the ldap connection object definition.
  5. History:
  6. 10/15/96 Chu, Lon-Chan [lonchanc]
  7. Created.
  8. Copyright (c) Microsoft Corporation 1996-1997
  9. ---------------------------------------------------------------------- */
  10. #ifndef _ILS_SP_CONNECT_H_
  11. #define _ILS_SP_CONNECT_H_
  12. #include <pshpack8.h>
  13. extern ULONG g_uResponseTimeout;
  14. #define LDAP_CONN_SIGNATURE ((DWORD) 0xF9369606)
  15. #define MAX_LDAP_DN 256
  16. #ifdef USE_DEFAULT_COUNTRY
  17. extern const TCHAR c_szDefC[];
  18. #endif
  19. extern const TCHAR c_szDefO[];
  20. extern const TCHAR c_szRTPerson[];
  21. extern const TCHAR c_szRTConf[];
  22. extern const TCHAR c_szDefClientBaseDN[];
  23. extern const TCHAR c_szDefMtgBaseDN[];
  24. extern const TCHAR c_szEmptyString[];
  25. #define STR_DEF_CLIENT_BASE_DN ((TCHAR *) &c_szDefClientBaseDN[0])
  26. #define STR_DEF_MTG_BASE_DN ((TCHAR *) &c_szDefMtgBaseDN[0])
  27. #define STR_EMPTY ((TCHAR *) &c_szEmptyString[0])
  28. class SP_CSession
  29. {
  30. friend class SP_CSessionContainer;
  31. public:
  32. SP_CSession ( VOID );
  33. ~SP_CSession ( VOID );
  34. // session management
  35. LDAP *GetLd ( VOID ) { return m_ld; }
  36. HRESULT Disconnect ( VOID );
  37. // server timeout
  38. ULONG GetServerTimeoutInSecond ( VOID )
  39. {
  40. return ((m_ServerInfo.uTimeoutInSecond != 0) ?
  41. m_ServerInfo.uTimeoutInSecond :
  42. g_uResponseTimeout / 1000);
  43. }
  44. ULONG GetServerTimeoutInTickCount ( VOID )
  45. {
  46. return ((m_ServerInfo.uTimeoutInSecond != 0) ?
  47. m_ServerInfo.uTimeoutInSecond * 1000 :
  48. g_uResponseTimeout);
  49. }
  50. protected:
  51. // session management
  52. HRESULT Connect ( SERVER_INFO *pInfo, ULONG cConns, BOOL fAbortable );
  53. BOOL SameServerInfo ( SERVER_INFO *pInfo ) { return IlsSameServerInfo (&m_ServerInfo, pInfo); }
  54. // array management
  55. BOOL IsUsed ( VOID ) { return m_fUsed; }
  56. VOID SetUsed ( VOID ) { m_fUsed = TRUE; }
  57. VOID ClearUsed ( VOID ) { m_fUsed = FALSE; }
  58. private:
  59. VOID FillAuthIdentity ( SEC_WINNT_AUTH_IDENTITY *pai );
  60. HRESULT Bind ( BOOL fAbortable );
  61. VOID InternalCleanup ( VOID );
  62. DWORD m_dwSignature;
  63. SERVER_INFO m_ServerInfo;
  64. LONG m_cRefs;
  65. LDAP *m_ld;
  66. BOOL m_fUsed;
  67. };
  68. class SP_CSessionContainer
  69. {
  70. public:
  71. SP_CSessionContainer ( VOID );
  72. ~SP_CSessionContainer ( VOID );
  73. HRESULT Initialize ( ULONG cEntries, SP_CSession *ConnArr );
  74. HRESULT GetSession ( SP_CSession **ppConn, SERVER_INFO *pInfo, ULONG cConns, BOOL fAbortable );
  75. HRESULT GetSession ( SP_CSession **ppConn, SERVER_INFO *pInfo, BOOL fAbortable ) { return GetSession (ppConn, pInfo, 1, fAbortable); }
  76. HRESULT GetSession ( SP_CSession **ppConn, SERVER_INFO *pInfo ) { return GetSession (ppConn, pInfo, 1, TRUE); }
  77. protected:
  78. private:
  79. VOID ReadLock ( VOID ) { EnterCriticalSection (&m_csSessContainer); }
  80. VOID ReadUnlock ( VOID ) { LeaveCriticalSection (&m_csSessContainer); }
  81. VOID WriteLock ( VOID ) { ReadLock (); }
  82. VOID WriteUnlock ( VOID ) { ReadUnlock (); }
  83. ULONG m_cEntries;
  84. SP_CSession *m_aConns;
  85. CRITICAL_SECTION m_csSessContainer;
  86. };
  87. extern SP_CSessionContainer *g_pSessionContainer;
  88. #include <poppack.h>
  89. #endif // _ILS_SP_CONNECT_H_