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.

372 lines
10 KiB

  1. #ifndef _INC_DSKQUOTA_CONTROL_H
  2. #define _INC_DSKQUOTA_CONTROL_H
  3. ///////////////////////////////////////////////////////////////////////////////
  4. /* File: control.h
  5. Description: Contains declaration for class DiskQuotaControl.
  6. Revision History:
  7. Date Description Programmer
  8. -------- --------------------------------------------------- ----------
  9. 05/22/96 Initial creation. BrianAu
  10. */
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #ifndef _INC_DSKQUOTA_H
  13. # include "dskquota.h"
  14. #endif
  15. #ifndef _INC_DSKQUOTA_FSOBJECT_H
  16. # include "fsobject.h" // File System object types.
  17. #endif
  18. #ifndef _INC_DSKQUOTA_SIDNAME_H
  19. # include "sidname.h" // Sid Name Resolver.
  20. #endif
  21. #ifndef _INC_DSKQUOTA_NTDS_H
  22. # include "ntds.h" // For DS versions of LookupAccountSid/Name
  23. #endif
  24. #ifndef _INC_DSKQUOTA_DISPATCH_H
  25. # include "dispatch.h" // MIDL-generated header.
  26. #endif
  27. #ifndef _INC_DSKQUOTA_OADISP_H
  28. # include "oadisp.h" // OleAutoDispatch class.
  29. #endif
  30. class DiskQuotaControl : public IDiskQuotaControl
  31. {
  32. private:
  33. LONG m_cRef; // Object ref count.
  34. BOOL m_bInitialized; // Controller initialized?
  35. LONGLONG m_llDefaultQuotaThreshold; // "New User" default threshold.
  36. LONGLONG m_llDefaultQuotaLimit; // "New User" default limit.
  37. FSObject *m_pFSObject; // Volume or directory.
  38. DWORD m_dwFlags; // State of quota system.
  39. PSID_NAME_RESOLVER m_pSidNameResolver; // For getting SID account names.
  40. CMutex m_mutex; // Ensures safe shutdown.
  41. //
  42. // Support for IConnectionPointContainer.
  43. // 1. Static array of supported interface IDs.
  44. // 2. Array of connection pt interface pointers.
  45. // Dynamically grows as clients connect for events.
  46. //
  47. static const IID * const m_rgpIConnPtsSupported[];
  48. PCONNECTIONPOINT *m_rgConnPts; // Array of conn pt object ptrs.
  49. UINT m_cConnPts; // Count of conn pts supported.
  50. //
  51. // Create connection point objects for the supported connection
  52. // point types.
  53. //
  54. HRESULT
  55. InitConnectionPoints(
  56. VOID);
  57. //
  58. // Read quota information from disk to member variables.
  59. //
  60. HRESULT
  61. QueryQuotaInformation(
  62. VOID);
  63. //
  64. // Write quota information from member variables to disk.
  65. //
  66. HRESULT
  67. SetQuotaInformation(
  68. DWORD dwChangeFlags);
  69. HRESULT
  70. GetDefaultQuotaItem(
  71. PLONGLONG pllItem,
  72. PLONGLONG pllValueOut);
  73. //
  74. // Prevent copy construction.
  75. //
  76. DiskQuotaControl(const DiskQuotaControl& control);
  77. void operator = (const DiskQuotaControl& control);
  78. public:
  79. NTDS m_NTDS;
  80. //
  81. // If you add a new connection point type, add a corresponding enumeration
  82. // member that identifies the location of the conn pt IID in
  83. // m_rgpIConnPtsSupported[].
  84. //
  85. enum { ConnPt_iQuotaEvents = 0,
  86. ConnPt_iQuotaEventsDisp = 1, };
  87. DiskQuotaControl(VOID);
  88. ~DiskQuotaControl(VOID);
  89. HRESULT NotifyUserNameChanged(PDISKQUOTA_USER pUser);
  90. FSObject *GetFSObjectPtr(VOID)
  91. { return m_pFSObject; }
  92. //
  93. // IUnknown methods.
  94. //
  95. STDMETHODIMP
  96. QueryInterface(
  97. REFIID riid,
  98. LPVOID *ppvOut);
  99. STDMETHODIMP_(ULONG)
  100. AddRef(
  101. VOID);
  102. STDMETHODIMP_(ULONG)
  103. Release(
  104. VOID);
  105. //
  106. // IConnectionPointContainer methods.
  107. //
  108. STDMETHODIMP
  109. FindConnectionPoint(
  110. REFIID,
  111. PCONNECTIONPOINT *pCP);
  112. STDMETHODIMP
  113. EnumConnectionPoints(
  114. PENUMCONNECTIONPOINTS *pEnumCP);
  115. //
  116. // IDiskQuotaControl methods.
  117. //
  118. STDMETHODIMP
  119. Initialize(
  120. LPCWSTR pszFSObjectName,
  121. BOOL bReadWrite);
  122. STDMETHODIMP
  123. GetQuotaState(
  124. LPDWORD pdwState);
  125. STDMETHODIMP
  126. SetQuotaState(
  127. DWORD dwState);
  128. STDMETHODIMP
  129. SetQuotaLogFlags(
  130. DWORD dwFlags);
  131. STDMETHODIMP
  132. GetQuotaLogFlags(
  133. LPDWORD pdwFlags);
  134. STDMETHODIMP
  135. SetDefaultQuotaThreshold(
  136. LONGLONG llThreshold);
  137. STDMETHODIMP
  138. SetDefaultQuotaLimit(
  139. LONGLONG llLimit);
  140. STDMETHODIMP
  141. GetDefaultQuotaThreshold(
  142. PLONGLONG pllThreshold);
  143. STDMETHODIMP
  144. GetDefaultQuotaThresholdText(
  145. LPWSTR pszText,
  146. DWORD cchText);
  147. STDMETHODIMP
  148. GetDefaultQuotaLimit(
  149. PLONGLONG pllLimit);
  150. STDMETHODIMP
  151. GetDefaultQuotaLimitText(
  152. LPWSTR pszText,
  153. DWORD cchText);
  154. STDMETHODIMP
  155. AddUserSid(
  156. PSID pSid,
  157. DWORD fNameResolution,
  158. PDISKQUOTA_USER *ppUser);
  159. STDMETHODIMP
  160. AddUserName(
  161. LPCWSTR pszLogonName,
  162. DWORD fNameResolution,
  163. PDISKQUOTA_USER *ppUser);
  164. STDMETHODIMP
  165. DeleteUser(
  166. PDISKQUOTA_USER pUser);
  167. STDMETHODIMP
  168. FindUserSid(
  169. PSID pSid,
  170. DWORD fNameResolution,
  171. PDISKQUOTA_USER *ppUser);
  172. STDMETHODIMP
  173. FindUserName(
  174. LPCWSTR pszLogonName,
  175. PDISKQUOTA_USER *ppUser);
  176. STDMETHODIMP
  177. CreateEnumUsers(
  178. PSID *rgpSids,
  179. DWORD cpSids,
  180. DWORD fNameResolution,
  181. PENUM_DISKQUOTA_USERS *ppEnum);
  182. STDMETHODIMP
  183. CreateUserBatch(
  184. PDISKQUOTA_USER_BATCH *ppUserBatch);
  185. STDMETHODIMP
  186. InvalidateSidNameCache(
  187. VOID);
  188. STDMETHODIMP
  189. GiveUserNameResolutionPriority(
  190. PDISKQUOTA_USER pUser);
  191. STDMETHODIMP
  192. ShutdownNameResolution(
  193. VOID);
  194. };
  195. class DiskQuotaControlDisp : public DIDiskQuotaControl
  196. {
  197. public:
  198. DiskQuotaControlDisp(PDISKQUOTA_CONTROL pQC);
  199. ~DiskQuotaControlDisp(VOID);
  200. //
  201. // IUnknown methods.
  202. //
  203. STDMETHODIMP
  204. QueryInterface(
  205. REFIID riid,
  206. LPVOID *ppvOut);
  207. STDMETHODIMP_(ULONG)
  208. AddRef(
  209. VOID);
  210. STDMETHODIMP_(ULONG)
  211. Release(
  212. VOID);
  213. //
  214. // IDispatch methods.
  215. //
  216. STDMETHODIMP
  217. GetIDsOfNames(
  218. REFIID riid,
  219. OLECHAR ** rgszNames,
  220. UINT cNames,
  221. LCID lcid,
  222. DISPID *rgDispId);
  223. STDMETHODIMP
  224. GetTypeInfo(
  225. UINT iTInfo,
  226. LCID lcid,
  227. ITypeInfo **ppTInfo);
  228. STDMETHODIMP
  229. GetTypeInfoCount(
  230. UINT *pctinfo);
  231. STDMETHODIMP
  232. Invoke(
  233. DISPID dispIdMember,
  234. REFIID riid,
  235. LCID lcid,
  236. WORD wFlags,
  237. DISPPARAMS *pDispParams,
  238. VARIANT *pVarResult,
  239. EXCEPINFO *pExcepInfo,
  240. UINT *puArgErr);
  241. //
  242. // Automation Properties.
  243. //
  244. STDMETHODIMP put_QuotaState(QuotaStateConstants State);
  245. STDMETHODIMP get_QuotaState(QuotaStateConstants *pState);
  246. STDMETHODIMP get_QuotaFileIncomplete(VARIANT_BOOL *pbIncomplete);
  247. STDMETHODIMP get_QuotaFileRebuilding(VARIANT_BOOL *pbRebuilding);
  248. STDMETHODIMP put_LogQuotaThreshold(VARIANT_BOOL bLogThreshold);
  249. STDMETHODIMP get_LogQuotaThreshold(VARIANT_BOOL *pbLogThreshold);
  250. STDMETHODIMP put_LogQuotaLimit(VARIANT_BOOL bLogLimit);
  251. STDMETHODIMP get_LogQuotaLimit(VARIANT_BOOL *pbLogLimit);
  252. STDMETHODIMP put_DefaultQuotaThreshold(double Threshold);
  253. STDMETHODIMP get_DefaultQuotaThreshold(double *pThreshold);
  254. STDMETHODIMP get_DefaultQuotaThresholdText(BSTR *pThresholdText);
  255. STDMETHODIMP put_DefaultQuotaLimit(double Limit);
  256. STDMETHODIMP get_DefaultQuotaLimit(double *pLimit);
  257. STDMETHODIMP get_DefaultQuotaLimitText(BSTR *pLimitText);
  258. STDMETHODIMP put_UserNameResolution(UserNameResolutionConstants ResolutionType);
  259. STDMETHODIMP get_UserNameResolution(UserNameResolutionConstants *pResolutionType);
  260. //
  261. // Automation Methods.
  262. //
  263. STDMETHODIMP Initialize(
  264. BSTR path,
  265. VARIANT_BOOL bReadOnly);
  266. STDMETHODIMP AddUser(
  267. BSTR LogonName,
  268. DIDiskQuotaUser **ppUser);
  269. STDMETHODIMP DeleteUser(
  270. DIDiskQuotaUser *pUser);
  271. STDMETHODIMP FindUser(
  272. BSTR LogonName,
  273. DIDiskQuotaUser **ppUser);
  274. STDMETHODIMP TranslateLogonNameToSID(
  275. BSTR LogonName,
  276. BSTR *psid);
  277. STDMETHODIMP
  278. _NewEnum(
  279. IDispatch **ppEnum);
  280. STDMETHODIMP InvalidateSidNameCache(void);
  281. STDMETHODIMP GiveUserNameResolutionPriority(
  282. DIDiskQuotaUser *pUser);
  283. STDMETHODIMP ShutdownNameResolution(void);
  284. private:
  285. LONG m_cRef;
  286. PDISKQUOTA_CONTROL m_pQC; // For delegation
  287. OleAutoDispatch m_Dispatch;
  288. DWORD m_fOleAutoNameResolution;
  289. PENUM_DISKQUOTA_USERS m_pUserEnum;
  290. //
  291. // Prevent copy.
  292. //
  293. DiskQuotaControlDisp(const DiskQuotaControlDisp& rhs);
  294. DiskQuotaControlDisp& operator = (const DiskQuotaControlDisp& rhs);
  295. };
  296. #endif // __DISK_QUOTA_CONTROL_H