syncserv.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* --- BEGIN COPYRIGHT BLOCK ---
  2. * Copyright (C) 2005 Red Hat, Inc.
  3. * All rights reserved.
  4. * --- END COPYRIGHT BLOCK --- */
  5. // Created: 2-8-2005
  6. // Author(s): Scott Bridges
  7. #ifndef _SYNCSERV_H_
  8. #define _SYNCSERV_H_
  9. #include <stdio.h>
  10. #include "ldap.h"
  11. #include "ldap_ssl.h"
  12. #include "ldappr.h"
  13. #include "ntservice.h"
  14. #include "../passhand.h"
  15. #define SYNCSERV_BUF_SIZE 256
  16. #define SYNCSERV_TIMEOUT 10000
  17. #define SYNCSERV_ALLOW_MULTI_MOD false
  18. #define SYNCSERV_MAX_BACKOFF_COUNT 4
  19. #define SYNCSERV_BASE_BACKOFF_LEN 1000
  20. class PassSyncService : public CNTService
  21. {
  22. public:
  23. PassSyncService(const TCHAR* serviceName);
  24. ~PassSyncService();
  25. void OnStop();
  26. void OnShutdown();
  27. void Run();
  28. int SyncPasswords();
  29. private:
  30. int Connect(LDAP** connection, char* dn, char* auth);
  31. int Disconnect(LDAP** connection);
  32. int QueryUsername(char* username);
  33. char* GetDN();
  34. bool CanBind(char* dn, char* password);
  35. int ModifyPassword(char* dn, char* password);
  36. void ResetBackoff();
  37. void EndBackoff();
  38. bool Backoff();
  39. PASS_INFO_LIST passInfoList;
  40. HANDLE passhookEventHandle;
  41. // LDAP variables
  42. LDAP* mainLdapConnection;
  43. LDAPMessage* results;
  44. LDAPMessage* currentResult;
  45. int lastLdapError;
  46. char certPath[SYNCSERV_BUF_SIZE];
  47. char logPath[SYNCSERV_BUF_SIZE];
  48. // Config variables
  49. char installPath[SYNCSERV_BUF_SIZE];
  50. char dataFilename[SYNCSERV_BUF_SIZE];
  51. char ldapHostName[SYNCSERV_BUF_SIZE];
  52. char ldapHostPort[SYNCSERV_BUF_SIZE];
  53. char ldapAuthUsername[SYNCSERV_BUF_SIZE];
  54. char ldapAuthPassword[SYNCSERV_BUF_SIZE];
  55. char ldapSearchBase[SYNCSERV_BUF_SIZE];
  56. char ldapUsernameField[SYNCSERV_BUF_SIZE];
  57. char ldapPasswordField[SYNCSERV_BUF_SIZE];
  58. bool multipleModify;
  59. bool isRunning;
  60. int backoffCount;
  61. fstream outLog;
  62. };
  63. #endif