This example shows how to provision a Microsoft Exchange 2000 or Exchange 2003 resource mailbox object with limits on the amount of disk space the user is allocated to store their messages.

Attribute Inclusion List

You must select the following attributes from the Select Attributes property page for your Active Directory Domain Services (AD DS) management agent to provision an Exchange resource mailbox:

  • mailNickname

  • homeMDB

  • mDBStorageQuota

  • mDBOverQuotaLimit

  • mDBOverHardQuotaLimit

  • mDBUseDefaults

  • msExchMailboxSecurityDescriptor

  • msExchMasterAccountSid

  • nTSecurityDescriptor

  • userAccountControl

You can provision an Exchange mailbox with a mailbox store quota that limits the amount of disk space that users are allowed to use to store their e-mail messages. When users exceed their mailbox store quota, they receive an error message warning them about their excessive space usage, but they can still send and receive messages. You can also provision the mailbox with an overflow quota that adds an additional amount of disk space to store their e-mail messages. When the user exceeds the overflow quota, the Exchange server does not allow the user to send e-mail. Finally, you can provision the mailbox with a hard limit on the amount of disk space to store their e-mail messages. If the user exceeds this hard limit, the Exchange server does not allow the user to send or receive e-mail.

The following example shows how to use a rules extension to provision an Exchange resource mailbox. The mailbox is given a quota of disk space based upon the values of the mDBStorageQuota, mDBOverQuotaLimit, and mDBOverHardQuotaLimit attributes. You must add a reference to logging.dll to use the LogException method.

Visual Basic  Copy Code
Public Sub Provision(ByVal mventry As MVEntry) _
	Implements IMVSynchronization.Provision

	Dim adMA As ConnectedMA
	Dim csentry As CSEntry
	Dim nickName, mailboxMDB As String
	Dim dn as ReferenceValue

	' Mailbox limits, in kilobytes.

	' When reached, Exchange Server issues a warning about the mailbox size.
	Dim storeQuota	 As Long

   ' When reached, Exchange Server prohibits sending e-mail
   ' from this mailbox.
	Dim overQuotaLimit As Long

   ' When reached, Exchange Server prohibits sending and receiving e-mail.
	Dim hardLimit	As Long  

	' Security descriptor.
	Dim sidString as String
	Dim sid as byte()

	try
		adMA = mventry.ConnectedMAs("Fabrikam AD MA")

		nickName   = mventry("mailNickname").Value
		mailboxMDB = mventry("homeMDB").Value

		storeQuota	 = mventry("mDBStorageQuota").IntegerValue
		overQuotaLimit = mventry("mDBOverQuotaLimit").IntegerValue
		hardLimit	= mventry("mDBOverHardQuotaLimit").IntegerValue

		sidString  = mventry("msExchMailboxSecurityDescriptor").Value
		sid		= Utils.ConvertStringToSid(sidString)

		' Construct the distinguished name.
		dn = adMA.EscapeDNComponent("CN=" + mventry("cn").Value).Concat("ou=mailboxes,dc=fabrikam,dc=com")

		If 0 = adMA.Connectors.Count then
			csentry = ExchangeUtils.CreateMailbox(adMA, dn, nickName, mailboxMDB, storeQuota, overQuotaLimit, hardLimit, sid)
		End If

		' Log and rethrow any exception.
		Catch ex As Exception
			Logging.Logging.LogException(ex, "Provision", "Caught exception", False)
			Throw
	End Try
End Sub
C#  Copy Code
void IMVSynchronization.Provision (MVEntry mventry)
{
	ConnectedMA adMA;
	CSEntry csentry;
	String nickName, mailboxMDB;
	ReferenceValue dn;

	// Mailbox limits, in kilobytes.

	// When reached, Exchange Server issues a warning about the mailbox size.
	long storeQuota; 

	// When reached, Exchange Server prohibits sending e-mail
	// from this mailbox.
	long overQuotaLimit;

	// When reached, Exchange Server prohibits sending and receiving e-mail.  
	long hardLimit;  

	// Security descriptor.
	string sidString;
	byte[] sid;

	try
	{
		adMA = mventry.ConnectedMAs["Fabrikam AD MA"];

		nickName   = mventry["mailNickname"].Value;
		mailboxMDB = mventry["homeMDB"].Value;

		storeQuota	 = mventry["mDBStorageQuota"].IntegerValue;
		overQuotaLimit = mventry["mDBOverQuotaLimit"].IntegerValue;
		hardLimit	= mventry["mDBOverHardQuotaLimit"].IntegerValue;

		sidString  = mventry["msExchMailboxSecurityDescriptor"].Value;
		sid		= Utils.ConvertStringToSid(sidString);

		// Construct the distinguished name.
		dn = adMA.EscapeDNComponent("CN=" + mventry["cn"].Value).Concat("ou=mailboxes,dc=fabrikam,dc=com");

		if(0 == adMA.Connectors.Count)
		{
			csentry = ExchangeUtils.CreateMailbox(adMA, dn, nickName, mailboxMDB, storeQuota, overQuotaLimit, hardLimit, sid);
	}
}

	// Log and rethrow any exception.
	catch(Exception ex)
	{
		Logging.Logging.LogException(ex, "Provision", "Caught exception", false);
		throw;
}
}

See Also

Reference

CreateMailbox

Concepts

Microsoft Exchange Connected Data Sources