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.

156 lines
4.2 KiB

  1. #ifndef _INC_DSKQUOTA_SIDNAME_H
  2. #define _INC_DSKQUOTA_SIDNAME_H
  3. ///////////////////////////////////////////////////////////////////////////////
  4. /* File: sidname.h
  5. Description: Declarations for SID/Name resolver. See sidname.cpp for
  6. details of operation.
  7. Revision History:
  8. Date Description Programmer
  9. -------- --------------------------------------------------- ----------
  10. 06/12/96 Initial creation. BrianAu
  11. 03/18/98 Replaced "domain", "name" and "full name" with BrianAu
  12. "container", "logon name" and "display name" to
  13. better match the actual contents. This was in
  14. reponse to making the quota UI DS-aware. The
  15. "logon name" is now a unique key as it contains
  16. both account name and domain-like information.
  17. i.e. "REDMOND\brianau" or "[email protected]".
  18. */
  19. ///////////////////////////////////////////////////////////////////////////////
  20. #ifndef _INC_DSKQUOTA_H
  21. # include "dskquota.h"
  22. #endif
  23. #ifndef _INC_DSKQUOTA_SIDCACHE_H
  24. # include "sidcache.h"
  25. #endif
  26. #ifndef _INC_DSKQUOTA_USER_H
  27. # include "user.h"
  28. #endif
  29. //
  30. // This is a PRIVATE interface. That's why it's here and not in dskquota.h
  31. //
  32. #undef INTERFACE
  33. #define INTERFACE ISidNameResolver
  34. DECLARE_INTERFACE_(ISidNameResolver, IUnknown)
  35. {
  36. //
  37. // ISidNameResolver methods.
  38. //
  39. STDMETHOD(Initialize)(THIS) PURE;
  40. STDMETHOD(FindUserName)(THIS_ PDISKQUOTA_USER) PURE;
  41. STDMETHOD(FindUserNameAsync)(THIS_ PDISKQUOTA_USER) PURE;
  42. STDMETHOD(Shutdown)(THIS_ BOOL) PURE;
  43. STDMETHOD(PromoteUserToQueueHead)(THIS_ PDISKQUOTA_USER) PURE;
  44. };
  45. typedef ISidNameResolver SID_NAME_RESOLVER, *PSID_NAME_RESOLVER;
  46. class DiskQuotaControl; // Fwd reference.
  47. class SidNameResolver : public ISidNameResolver
  48. {
  49. private:
  50. LONG m_cRef;
  51. DiskQuotaControl& m_rQuotaController;
  52. HANDLE m_hsemQueueNotEmpty;
  53. HANDLE m_hMutex;
  54. HANDLE m_hResolverThread;
  55. HANDLE m_heventResolverThreadReady;
  56. DWORD m_dwResolverThreadId;
  57. CQueueAsArray<PDISKQUOTA_USER> m_UserQueue;
  58. //
  59. // Prevent copying.
  60. //
  61. SidNameResolver(const SidNameResolver& );
  62. operator = (const SidNameResolver& );
  63. HRESULT
  64. ResolveSidToName(PDISKQUOTA_USER pUser);
  65. static DWORD ThreadProc(LPVOID dwParam);
  66. HRESULT
  67. CreateResolverThread(
  68. PHANDLE phThread,
  69. LPDWORD pdwThreadId);
  70. HRESULT
  71. ThreadOnQueueNotEmpty(VOID);
  72. HRESULT
  73. ClearInputQueue(VOID);
  74. HRESULT
  75. FindCachedUserName(
  76. PDISKQUOTA_USER);
  77. HRESULT
  78. GetUserSid(PDISKQUOTA_USER pUser, PSID *ppSid);
  79. HRESULT
  80. RemoveUserFromResolverQueue(PDISKQUOTA_USER *ppUser);
  81. HRESULT
  82. AddUserToResolverQueue(PDISKQUOTA_USER pUser);
  83. void Lock(void)
  84. { WaitForSingleObject(m_hMutex, INFINITE); }
  85. void ReleaseLock(void)
  86. { ReleaseMutex(m_hMutex); }
  87. public:
  88. SidNameResolver(DiskQuotaControl& rQuotaController);
  89. ~SidNameResolver(void);
  90. //
  91. // IUnknown methods.
  92. //
  93. STDMETHODIMP
  94. QueryInterface(
  95. REFIID,
  96. LPVOID *);
  97. STDMETHODIMP_(ULONG)
  98. AddRef(
  99. VOID);
  100. STDMETHODIMP_(ULONG)
  101. Release(
  102. VOID);
  103. //
  104. // ISidNameResolver methods.
  105. //
  106. STDMETHODIMP
  107. Initialize(
  108. VOID);
  109. STDMETHODIMP
  110. FindUserName(
  111. PDISKQUOTA_USER);
  112. STDMETHODIMP
  113. FindUserNameAsync(
  114. PDISKQUOTA_USER);
  115. STDMETHODIMP
  116. Shutdown(
  117. BOOL bWait);
  118. STDMETHODIMP
  119. PromoteUserToQueueHead(
  120. PDISKQUOTA_USER);
  121. };
  122. #endif // _INC_DSKQUOTA_SIDNAME_H