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.

114 lines
2.9 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // FILE
  4. //
  5. // ntdomain.h
  6. //
  7. // SYNOPSIS
  8. //
  9. // Declares the class NTDomain.
  10. //
  11. // MODIFICATION HISTORY
  12. //
  13. // 05/07/1998 Original version.
  14. // 08/25/1998 Removed RootDSE attributes from the domain.
  15. // 02/24/1999 Add force flag to findServer.
  16. // 03/12/1999 Added isObsolete method.
  17. // 04/14/1999 Specify domain and server when opening a connection.
  18. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20. #ifndef _NTDOMAIN_H_
  21. #define _NTDOMAIN_H_
  22. #if _MSC_VER >= 1000
  23. #pragma once
  24. #endif
  25. #include <guard.h>
  26. #include <nocopy.h>
  27. class LDAPConnection;
  28. ///////////////////////////////////////////////////////////////////////////////
  29. //
  30. // CLASS
  31. //
  32. // NTDomain
  33. //
  34. // DESCRIPTION
  35. //
  36. // This class maintains state information about an NT domain.
  37. //
  38. ///////////////////////////////////////////////////////////////////////////////
  39. class NTDomain
  40. : Guardable, NonCopyable
  41. {
  42. public:
  43. enum Mode
  44. {
  45. MODE_UNKNOWN,
  46. MODE_NT4,
  47. MODE_MIXED,
  48. MODE_NATIVE
  49. };
  50. void AddRef() throw ()
  51. { InterlockedIncrement(&refCount); }
  52. void Release() throw ();
  53. PCWSTR getDomainName() const throw ()
  54. { return name; }
  55. DWORDLONG getExpiry() const throw ()
  56. { return expiry; }
  57. // Returns a connection to the domain. The client is responsible for
  58. // releasing the connection when done.
  59. DWORD getConnection(LDAPConnection** cxn) throw ();
  60. Mode getMode() throw ();
  61. BOOL isObsolete(DWORDLONG now) const throw ()
  62. { return (status && now >= expiry); }
  63. static NTDomain* createInstance(PCWSTR name) throw ();
  64. static DWORDLONG pollInterval;
  65. static DWORDLONG retryInterval;
  66. protected:
  67. NTDomain(PWSTR domainName) throw ();
  68. ~NTDomain() throw ();
  69. // Returns TRUE if the current state has expired.
  70. BOOL isExpired() throw ();
  71. // Open a new connection to the given DC.
  72. void openConnection(
  73. PCWSTR domain,
  74. PCWSTR server
  75. ) throw ();
  76. // Returns TRUE if we have a connection to a DC for the domain.
  77. BOOL isConnected() throw ();
  78. // Close the current connection (if any).
  79. void closeConnection() throw ();
  80. // Finds a server for the domain.
  81. void findServer() throw ();
  82. // Reads the domain mode (i.e., mixed vs native).
  83. void readDomainMode() throw ();
  84. private:
  85. LONG refCount; // Reference count.
  86. PWSTR name; // Name of the domain.
  87. Mode mode; // Mode of the domain.
  88. LDAPConnection* connection; // Cached DC for the domain (if any).
  89. DWORD status; // Current status of the domain.
  90. DWORDLONG expiry; // Time when current state expires.
  91. };
  92. #endif // _NTDOMAIN_H_