Enabling Immediate Logon for New Recipients
Enabling Immediate Logon for New Recipients
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
When an application creates a mail recipient using Collaboration Data Objects (CDO) or Active Directory® Service Interfaces (ADSI), there will be a delay before the new recipient can log on to the system. This delay is caused by the normal latency of the Microsoft® Exchange Recipient Update Service, and may be from 2 to 30 minutes, depending on server configuration and load.
To enable immediate logon for new recipients, your application can set the msExchUserAccountControl Microsoft Active Directory® object on the user object. Set the object value to 0 to enable the user logon. This is the same object and value set by the Recipient Update Service. Setting the msExchUserAccountControl object value to 2 disables the account and prevents the user from logging on.
If you are creating a new recipient and a new mailbox, first create the recipient without msExchUserAccountControl, and then create the mailbox. Enable the user for immediate logon only after both the recipient and mailbox have been successfully created.
You can set this using the IPerson.Fields property, or you can use ADSI. The following example uses ADSI.
Visual Basic
Sub ADSICreateMailBoxRecipientImmediateLogon(MDBName As String, _ StorageGroup As String, _ Server As String, _ AdminGroup As String, _ Organization As String, _ DomainName As String, _ emailname As String, _ FirstName As String, _ LastName As String) 'MDBName is something like "MyMDB6" 'DomainName is something like "DC=MYDOMAIN3,DC=example,DC=com" 'emailname is something like "jamessmith" 'this assumes the MDB to be a mailbox store. Dim objUser As IADsUser Dim objContainer As IADsContainer Dim objMailbox As CDOEXM.IMailboxStore Dim recipname As String, recip As String recip = "CN=" & emailname ' get the container Set objContainer = GetObject("LDAP://CN=users," + DomainName) ' create a recipient Set objUser = objContainer.Create("User", recip) objUser.Put "samAccountName", emailname objUser.Put "sn", LastName objUser.Put "givenName", FirstName objUser.Put "userPrincipalName", emailname objUser.SetInfo objUser.SetPassword "password" 'let user change it later objUser.AccountDisabled = False Set objMailbox = objUser 'Create a mailbox for the recipient 'You cannot create a mailbox using ADSI, so use CDOEXM objMailbox.CreateMailbox "LDAP://CN=" + MDBName + _ ",CN=" + StorageGroup + _ ",CN=InformationStore" + _ ",CN=" + Server + _ ",CN=Servers" + _ ",CN=" + AdminGroup + _ ",CN=Administrative Groups" + _ ",CN=" + Organization + _ ",CN=Microsoft Exchange,CN=Services" + _ ",CN=Configuration," + DomainName objUser.SetInfo ' enable immediate-logon for the user objUser.Put "msExchUserAccountControl", 0 objUser.SetInfo End Sub
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
This topic last updated: September 2003
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.