Disk quota

xiaoxiao2021-03-06  99

Using system;

USING DISKQUOTATYPELIBRARY;

Namespace ex3cut3.libraries {///

///// public class quotaclass {private diskquotacontrolclass _diskquotacontrol;

// this path as to be in this format or // else is going to give an error of invalid path private const string filesharevolume = @ "// server / c $ /"; private const Int mbtobytes = 1048576;

public DiskQuotaControlClass DiskQuotaControl {get {if (this._diskQuotaControl == null) {this._diskQuotaControl = new DiskQuotaControlClass (); // Initializes the control to the specified path this._diskQuotaControl.Initialize (FILESHAREVOLUME, true);} return this._diskQuotaControl }}

Public quotaclass () {}

///

/// ads a user to the quota entries of the volume /// /// The name of the user to add // / The domain what used Uses to logon /// The quota limit of this user public void add (String Username, String userDomain, int quotaLimit) {DIDiskQuotaUser dskuser = null; // In some cases if you use name resolution, // the application will give an error this.DiskQuotaControl.UserNameResolution = UserNameResolutionConstants.dqResolveNone;. // Here we had the user to the QUOTAS ENTRYS OF // THE VOLUME, We use user@domain.net the logon name of the user. // You can use the domain / user or just the user, // But in Like this works Faster dskuser = this.diskquotacontrol. AddUser (User.SAMACCOUNTNAME "@" User.d Omain); // Here We set the limited of the quota, this is // prepared to received MB SO i convert it to bytes dskuser.quotalimit = (int) quotalimit * mbtobytes; // Here is the set of the warning limited DSKUSER .Quotathrest / 1.2) * MbTobytes; dskuser = null;}

///

/// Removes the user form the quota entries list /// public void remove (String username) {// hERE We just use the the user, and infoke // the method this.diskquotacontrol.deleteuseuser (this.getuser (username));} /// /// a private function to return the user object // / /// The user name /// a didiskquotause Object /// of the specified user private didiskquotauser getUser {// invokes the method to find a user in a quota entry list return this.diskquotacontrol.finduser (username);

///

/// Gets the quota of the user /// /// The user name /// a formated string of THE quota /// limited of the user private string getquota (String Username) {// Here We return the text of the quota limit //0.0 bytes, 0.0 kb, 0.0 mb etc Return this.getuser (UserName) .Quotalimittext;

///

/// Gets the quota currently use by the user /// /// The user name /// a formated string of the quota /// used by the user private string GetQuotaUsed (string userName) {return this.GetUser (userName) .QuotaUsedText;} /// /// Change the quota of a specified user /// /// The user name /// The new quota limit of the user Private vid ChangeQuota (string userName, int quotaLimit) {DIDiskQuotaUser dskuser = this.GetUser (userName); dskuser.QuotaLimit = quotaLimit * Support.Constants.CONVERTBTOMB; dskuser.QuotaThreshold = (quotaLimit / 1.2) * Support.Constants.CONVERTBTOMB;}}}

转载请注明原文地址:https://www.9cbs.com/read-104339.html

New Post(0)