VBSCRIPT - Creating a mailbox in the same store as another named user's mailbox

I already have a script that creates a new AD user, enables it, sets the password and then copies the group membership from another named user.

I now want to create a mailbox in the same mailstore as that named user. This is so that I can use this on a range of different servers and as long as I have an existing user to copy, it will work without too many parameters having to be filled in.

I therefore want to find the LDAP string of the mailbox of this existing user and then use it to create the mailbox for my new user.

namedUser = WScript.Arguments(0) ' my existing userID

' I need to find the details below for the namedUser

strStore = strStore & "CN=" & strStoreName
strStore = strStore & ",CN=" & strStorageGroup
strStore = strStore & ",CN=InformationStore"
strStore = strStore & ",CN=" & strServer
strStore = strStore & ",CN=Servers"
strStore = strStore & ",CN=" & strAdminGroup
strStore = strStore & ",CN=Administrative Groups"
strStore = strStore & ",CN=" & strExchangeOrg
strStore = strStore & ",CN=Microsoft Exchange"
strStore = strStore & ",CN=Services"
strStore = strStore & objRootLDAP.Get("configurationNamingContext")


'*************************************************
'Create and enable my new user - objUser - this already works
'*************************************************

' Create a Mailbox for the User

objUser.CreateMailbox strStore
objUser.SetInfo

Open in new window


Regards,

Simon
leapconsultingAsked:
Who is Participating?
 
Erik PittiCommented:

It's much easier than you think.

'Get Message Store DN for existing user
strStore = existingUser.Get("homeMDB")

' Create a Mailbox for the new User

objUser.CreateMailbox strStore
objUser.SetInfo

Open in new window

0
 
leapconsultingAuthor Commented:
That's great - thank you for your help!

Works perfectly on Windows Server 2003 - doesn't seem to work on 2008. Is there any way of making that work? I want to keep the same solution for both types of server if possible, therefore not Powershell for 2008.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.