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.

146 lines
3.1 KiB

  1. // File: ldap.h
  2. #ifndef _CLDAP_H_
  3. #define _CLDAP_H_
  4. #include <winldap.h>
  5. #include "oblist.h"
  6. #include "calv.h"
  7. #define LDAP_PORT_W2K 1002 // Default W2K ldap port (1002)...
  8. #define DEFAULT_LDAP_PORT LDAP_PORT_W2K
  9. #define ALTERNATE_LDAP_PORT LDAP_PORT
  10. // Generic user data
  11. typedef struct {
  12. TCHAR szEmail[CCHMAXSZ_EMAIL];
  13. TCHAR szName[CCHMAXSZ_NAME];
  14. TCHAR szFirst[CCHMAXSZ_FIRSTNAME];
  15. TCHAR szLast[CCHMAXSZ_LASTNAME];
  16. TCHAR szComment[CCHMAXSZ_COMMENT];
  17. TCHAR szVersion[CCHMAXSZ_VERSION];
  18. BOOL fAudioSend;
  19. BOOL fVideoSend;
  20. } LDAPUSERDATA;
  21. typedef struct _dirCache {
  22. LPTSTR pszServer; // the server name
  23. DWORD dwTickExpire; // expiration time
  24. LPBYTE pData; // pointer to linked list of server data
  25. } DIRCACHE;
  26. class CLDAP : public CALV
  27. {
  28. private:
  29. LDAP * m_pLdap;
  30. ULONG m_ulPort;
  31. TCHAR m_szServer[CCHMAXSZ_SERVER];
  32. TCHAR m_szAddress[CCHMAXSZ_SERVER];
  33. HANDLE m_hThread;
  34. ULONG m_msgId;
  35. HWND m_hWnd;
  36. HANDLE m_hSearchMutex;
  37. bool m_bSearchCancelled;
  38. public:
  39. // Constructor and destructor
  40. CLDAP();
  41. ~CLDAP();
  42. VOID SetServer(LPCTSTR pcszServer);
  43. LPCTSTR PszServer(void) {return m_szServer;}
  44. BOOL FLoggedOn(void) {return (NULL != m_pLdap);}
  45. BOOL FOpenServer(void);
  46. VOID CloseServer(void);
  47. HRESULT DoQuery(void);
  48. VOID AddEntries(LDAPMessage * pResult);
  49. BOOL FGetUserData(LDAPUSERDATA * pLdapUserData);
  50. LPTSTR GetNextAttribute(LPCTSTR pszExpect, LPTSTR psz, int cchMax, LPTSTR pszAttrib, LDAPMessage * pEntry, BerElement * pElement);
  51. VOID StopSearch(void);
  52. VOID StartSearch(void);
  53. VOID AsyncSearch(void);
  54. static DWORD CALLBACK _sAsyncSearchThreadFn(LPVOID pv);
  55. VOID EnsureThreadStopped(void);
  56. static DWORD CALLBACK _sAsyncPropertyThreadFn(LPVOID pv);
  57. VOID ShowProperties(void);
  58. // CALV methods
  59. VOID ShowItems(HWND hwnd);
  60. VOID ClearItems(void);
  61. BOOL GetSzAddress(LPTSTR psz, int cchMax, int iItem);
  62. VOID OnCommand(WPARAM wParam, LPARAM lParam);
  63. VOID CmdProperties(void);
  64. VOID CmdAddToWab(void);
  65. virtual RAI * GetAddrInfo(void);
  66. BOOL GetSzName(LPTSTR psz, int cchMax, int iItem);
  67. void
  68. CacheServerData(void);
  69. int GetIconId(LPCTSTR psz);
  70. private:
  71. void
  72. forceSort(void);
  73. int
  74. lvAddItem
  75. (
  76. int item,
  77. int iInCallImage,
  78. int iAudioImage,
  79. int iVideoImage,
  80. LPCTSTR address,
  81. LPCTSTR firstName,
  82. LPCTSTR lastName,
  83. LPCTSTR location,
  84. LPCTSTR comments
  85. );
  86. void
  87. FreeDirCache
  88. (
  89. DIRCACHE * pDirCache
  90. );
  91. void
  92. DirComplete
  93. (
  94. bool fPostUiUpdate
  95. );
  96. POSITION
  97. FindCachedData(void);
  98. void
  99. ClearServerCache(void);
  100. void
  101. DisplayDirectory(void);
  102. private:
  103. int m_uniqueId;
  104. BOOL m_fDirInProgress;
  105. UINT m_cTotalEntries;
  106. UINT m_cEntries;
  107. BOOL m_fHaveRefreshed;
  108. DWORD m_dwTickStart;
  109. BOOL m_fIsCacheable; // Data can be cached
  110. BOOL m_fNeedsRefresh;
  111. BOOL m_fCancelling;
  112. BOOL m_fCacheDirectory; // TRUE if directory data should be cached
  113. DWORD m_cMinutesExpire; // Number of minutes before cached data expires
  114. COBLIST m_listDirCache; // list of cached data (DIRCACHE)
  115. };
  116. #endif /* _CLDAP_H_ */