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.

87 lines
2.3 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // lockkey.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the class LockoutKey.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 10/21/1998 Original version.
  16. // 01/14/1999 Removed destructor.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #ifndef _LOCKKEY_H_
  20. #define _LOCKKEY_H_
  21. #if _MSC_VER >= 1000
  22. #pragma once
  23. #endif
  24. ///////////////////////////////////////////////////////////////////////////////
  25. //
  26. // CLASS
  27. //
  28. // LockoutKey
  29. //
  30. // DESCRIPTION
  31. //
  32. // Provides a wrapper around the AccountLockout registry key.
  33. //
  34. ///////////////////////////////////////////////////////////////////////////////
  35. class LockoutKey
  36. {
  37. public:
  38. LockoutKey() throw ();
  39. void initialize() throw ();
  40. void finalize() throw ();
  41. // Returns the max. number of denials until a user is locked out.
  42. // If zero, then account lockout is disabled.
  43. DWORD getMaxDenials() const throw ()
  44. { return maxDenials; }
  45. // Create and return a new sub-key.
  46. HKEY createEntry(PCWSTR subKeyName) throw ();
  47. // Open and return an existing sub-key.
  48. HKEY openEntry(PCWSTR subKeyName) throw ();
  49. // Delete a sub-key.
  50. void deleteEntry(PCWSTR subKeyName) throw ()
  51. { RegDeleteKey(hLockout, subKeyName); }
  52. protected:
  53. // Deletes all sub-keys.
  54. void clear() throw ();
  55. // Deletes all expired sub-keys if the collection interval has passed.
  56. void collectGarbage() throw ();
  57. // Read the key's values.
  58. void readValues() throw ();
  59. private:
  60. DWORD maxDenials; // Max. number of denials.
  61. DWORD refCount; // Initialization ref. count.
  62. HKEY hLockout; // Registry key.
  63. HANDLE hChangeEvent; // Change notification event.
  64. HANDLE hRegisterWait; // RTL event registration.
  65. ULONGLONG ttl; // Time-To-Live for sub-keys.
  66. ULONGLONG lastCollection; // Last time we collected garbage.
  67. // Key change notification routine.
  68. static VOID NTAPI onChange(PVOID context, BOOLEAN flag) throw ();
  69. // Not implemented.
  70. LockoutKey(const LockoutKey&);
  71. LockoutKey& operator=(const LockoutKey&);
  72. };
  73. #endif // _LOCKKEY_H_