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.

109 lines
2.9 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // acctinfo.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the class AccountInfo.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 10/21/1998 Original version.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef _ACCTINFO_H_
  19. #define _ACCTINFO_H_
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif
  23. class LockoutKey;
  24. ///////////////////////////////////////////////////////////////////////////////
  25. //
  26. // CLASS
  27. //
  28. // AccountInfo
  29. //
  30. // DESCRIPTION
  31. //
  32. //
  33. //
  34. ///////////////////////////////////////////////////////////////////////////////
  35. class AccountInfo
  36. {
  37. public:
  38. // Open the AccountInfo object for a user.
  39. // Returns NULL if the lockout feature is disabled.
  40. static AccountInfo* open(PCWSTR domain, PCWSTR username) throw ();
  41. // Close an AccountInfo object; 'info' may be NULL.
  42. static void close(AccountInfo* info) throw ();
  43. // Accessors for user's domain and username.
  44. PCWSTR getDomain() const throw ()
  45. { return identity; }
  46. PCWSTR getUserName() const throw ()
  47. { return delim + 1; }
  48. // Increment the denial count.
  49. void incrementDenials() throw ()
  50. { ++denials; persist(); }
  51. // Reset the denial count.
  52. void reset() throw ()
  53. { denials = 0; persist(); }
  54. // Returns 'true' if the denial count is zero.
  55. bool isClean() const throw ()
  56. { return denials == 0; }
  57. // Returns 'true' if the account is currently locked out.
  58. bool isLockedOut() const throw ();
  59. // Signals that the account's dial-in privilege has been revoked. This
  60. // should be called after the privilege has been successfully revoked in
  61. // the user's account database.
  62. void revoke() throw ()
  63. { denials = DIALIN_REVOKED; persist(); }
  64. // Returns 'true' if the account's dial-in privilege has been revoked.
  65. bool isRevoked() const throw ()
  66. { return denials == DIALIN_REVOKED; }
  67. // API lifecycle.
  68. static void initialize() throw ();
  69. static void finalize() throw ();
  70. protected:
  71. AccountInfo(PCWSTR domain, PCWSTR username) throw ();
  72. ~AccountInfo() throw ();
  73. // Persists the account data to the registry.
  74. void persist() throw ();
  75. enum {
  76. // Magic denial value that indicates dialin privilege has been revoked.
  77. DIALIN_REVOKED = MAXDWORD
  78. };
  79. private:
  80. HKEY hKey; // Registry key for the account (if any).
  81. DWORD denials; // Number of denials recorded.
  82. PWCHAR delim; // Pointer to the delimeter in identity.
  83. WCHAR identity[1]; // Identity of the account.
  84. // Shared LockoutKey object.
  85. static LockoutKey root;
  86. // Not implemented.
  87. AccountInfo(const AccountInfo&);
  88. AccountInfo& operator=(const AccountInfo&);
  89. };
  90. #endif // _ACCTINFO_H_