Click or drag to resize
MimeKit

AccessControl Class

An Access Control.
Inheritance Hierarchy
SystemObject
  MailKitAccessControl

Namespace: MailKit
Assembly: MailKit (in MailKit.dll) Version: 4.3.0
Syntax
C#
public class AccessControl

The AccessControl type exposes the following members.

Constructors
 NameDescription
Public methodAccessControl(String) Initializes a new instance of the AccessControl class.
Public methodAccessControl(String, IEnumerableAccessRight) Initializes a new instance of the AccessControl class.
Public methodAccessControl(String, String) Initializes a new instance of the AccessControl class.
Top
Properties
 NameDescription
Public propertyCode exampleName The identifier name for the access control.
Public propertyCode exampleRights Get the access rights.
Top
Methods
 NameDescription
Public methodEquals
(Inherited from Object)
Protected methodFinalize
(Inherited from Object)
Public methodGetHashCode
(Inherited from Object)
Public methodGetType
(Inherited from Object)
Protected methodMemberwiseClone
(Inherited from Object)
Public methodToString
(Inherited from Object)
Top
Remarks
An Access Control is a set of permissions available for a particular identity, controlling whether or not that identity has the ability to perform various tasks.
Example
C#
public static void Capabilities ()
{
    using (var client = new ImapClient ()) {
        client.Connect ("imap.gmail.com", 993, SecureSocketOptions.SslOnConnect);

        var mechanisms = string.Join (", ", client.AuthenticationMechanisms);
        Console.WriteLine ("The IMAP server supports the following SASL authentication mechanisms: {0}", mechanisms);

        client.Authenticate ("username", "password");

        if (client.Capabilities.HasFlag (ImapCapabilities.Id)) {
            var clientImplementation = new ImapImplementation { Name = "MailKit", Version = "1.0" };
            var serverImplementation = client.Identify (clientImplementation);

            Console.WriteLine ("Server implementation details:");
            foreach (var property in serverImplementation.Properties)
                Console.WriteLine ("  {0} = {1}", property.Key, property.Value);
        }

        if (client.Capabilities.HasFlag (ImapCapabilities.Acl)) {
            Console.WriteLine ("The IMAP server supports Access Control Lists.");

            Console.WriteLine ("The IMAP server supports the following access rights: {0}", client.Rights);

            Console.WriteLine ("The Inbox has the following access controls:");
            var acl = client.Inbox.GetAccessControlList ();
            foreach (var ac in acl)
                Console.WriteLine ("  {0} = {1}", ac.Name, ac.Rights);

            var myRights = client.Inbox.GetMyAccessRights ();
            Console.WriteLine ("Your current rights for the Inbox folder are: {0}", myRights);
        }

        if (client.Capabilities.HasFlag (ImapCapabilities.Quota)) {
            Console.WriteLine ("The IMAP server supports quotas.");

            Console.WriteLine ("The current quota for the Inbox is:");
            var quota = client.Inbox.GetQuota ();

            if (quota.StorageLimit.HasValue)
                Console.WriteLine ("  Limited by storage space. Using {0} out of {1} bytes.", quota.CurrentStorageSize.Value, quota.StorageLimit.Value);

            if (quota.MessageLimit.HasValue)
                Console.WriteLine ("  Limited by the number of messages. Using {0} out of {1} bytes.", quota.CurrentMessageCount.Value, quota.MessageLimit.Value);

            Console.WriteLine ("The quota root is: {0}", quota.QuotaRoot);
        }

        if (client.Capabilities.HasFlag (ImapCapabilities.Thread)) {
            if (client.ThreadingAlgorithms.Contains (ThreadingAlgorithm.OrderedSubject))
                Console.WriteLine ("The IMAP server supports threading by subject.");
            if (client.ThreadingAlgorithms.Contains (ThreadingAlgorithm.References))
                Console.WriteLine ("The IMAP server supports threading by references.");
        }

        client.Disconnect (true);
    }
}
See Also