WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI LDAP CDO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Create an AD User and an Exchange 2k Mailbox

Keywords: active directoy exchange 2000 2K account mailbox mail box user


Create an AD user and an exchange 2k mailbox for that user.

You'll need to run this from a machine that has CDOEXM registered.

;Untested/Undebugged code
;Change these to fit your domain... 
strMBPath = "LDAP://CN=Mailbox Store (SERVERNAME),CN=First Storage Group,CN=InformationStore,CN=SERVERNAME,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Org,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=domain,DC=com" 
strDomain = "DOMAIN" 

strCN = "User" 
strSAM = "User" 
strPass = "Password123" 
oRoot = ObjectGet( StrCat( "LDAP://" , strDomain , "/rootDSE" ) ) 
oContainer = GetObject( StrCat( "LDAP://cn=users," , oRoot.Get( "defaultNamingContext" ) ) ) 
oNewUser = oContainer.Create( StrCat("user","cn=" , strCN ) ) 
oNewUser.SamAccountName = strSAM
oNewUser.SetInfo( ) 
oNewUser.SetPassword( strPass ) 
oNewUser.AccountDisabled = @False 
oNewUser.CreateMailbox( strMBPath ) 
oNewUser.SetInfo( ) 
oNewUser = 0
oContainer = 0
oRoot = 0
Message( "Done", "Finished creating an AD user and an exchange 2k mailbox")
exit 
--
Article ID:   W17119
File Created: 2007:07:03:14:28:22
Last Updated: 2007:07:03:14:28:22