myerit
asked on
Create Exchange 2003 mailbox
I am working on an app to simplify and standardize domain account creation and deletion. I am using ADSI to create and delete domain accounts, change passwords, etc. However, I want to be able to create mailboxes for the users too. I have looked all over the web and found numerous articles that are similar, but haven't found the jackpot yet.
The problem occurs on the createmailbox line. I get the following error:
Run-time error '438':
Object doesn't support this property or method
Can someone please help?
Thanks
I am using the following:
ADSICreateMailBoxEnabledUs er "Mailbox Store (EXCHANGE2003)", "First Storage Group", "EXchange2003", _
"First Administrative Group", "ABC Company", "abcdomain.com", _
"testuser6", "Test", "User6"
Sub ADSICreateMailBoxEnabledUs er _
(MDBName, storageGroup, Server, adminGroup, Organization, DomainName, emailname, firstName, lastName)
'split the domain name to get the directory name for it
domainDN = "dc=" & Replace(DomainName, ".", ",dc=")
recip = "CN=" & emailname
' get the container
Set objContainer = GetObject("LDAP://CN=users ," & domainDN)
' 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 "12345"
objUser.AccountDisabled = False
Set objMailbox = objUser
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," & domainDN
objUser.SetInfo
End Sub
The problem occurs on the createmailbox line. I get the following error:
Run-time error '438':
Object doesn't support this property or method
Can someone please help?
Thanks
I am using the following:
ADSICreateMailBoxEnabledUs
"First Administrative Group", "ABC Company", "abcdomain.com", _
"testuser6", "Test", "User6"
Sub ADSICreateMailBoxEnabledUs
(MDBName, storageGroup, Server, adminGroup, Organization, DomainName, emailname, firstName, lastName)
'split the domain name to get the directory name for it
domainDN = "dc=" & Replace(DomainName, ".", ",dc=")
recip = "CN=" & emailname
' get the container
Set objContainer = GetObject("LDAP://CN=users
' create a recipient
Set objUser = objContainer.Create("User"
objUser.Put "samAccountName", emailname
objUser.Put "sn", lastName
objUser.Put "givenName", firstName
objUser.Put "userPrincipalName", emailname
objUser.SetInfo
objUser.SetPassword "12345"
objUser.AccountDisabled = False
Set objMailbox = objUser
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," & domainDN
objUser.SetInfo
End Sub
Disregard, that is for setting up accounts a local machine...
ASKER
J.,
That may be true, however, it seems from the articles I am finding that it is possible. I believe I am simply doing something wrong.
Thanks
That may be true, however, it seems from the articles I am finding that it is possible. I believe I am simply doing something wrong.
Thanks
http://www.codecomments.com/Windows_Server_Scripting/message171717.html has an example. Why have you chosen to set objMailbox = objUser. I think you may be better off with just objUser.CreateMailbox...
J.
J.
If you haven't done so already, I would start by inspecting the values of your variables:
debug.print MDBName
debug.print storageGroup
debug.print Server
debug.print adminGroup
debug.print Organization
debug.print domainDN
debug.print MDBName
debug.print storageGroup
debug.print Server
debug.print adminGroup
debug.print Organization
debug.print domainDN
Do the debug.prints just before the CreateMailbox code.
Your code seems to mimick the example on this page:
http://www.internetaccessmonitor.com/eng/products/articles/Scripting_Exchange_Using_VBScript_and_ADSI_Part_2/Scripting_Exchange_Using_VBScript_and_ADSI_Part_2.php
Which has the objMailbox = objUser
Preece
Your code seems to mimick the example on this page:
http://www.internetaccessmonitor.com/eng/products/articles/Scripting_Exchange_Using_VBScript_and_ADSI_Part_2/Scripting_Exchange_Using_VBScript_and_ADSI_Part_2.php
Which has the objMailbox = objUser
Preece
ASKER
Using objuser.createmailbox raises the same error.
ASKER
Right, this code snippet is all over the web. I am attempting to make it work, but with no luck.
Hmmmm....are you variables properly populated?
Preece
Preece
ASKER
As best I can tell, they are all correct.
I believe the problem is rather related to not having a reference included because the method is not being recognized.
I believe the problem is rather related to not having a reference included because the method is not being recognized.
Duh, I just saw the call:
ADSICreateMailBoxEnabledUs er "Mailbox Store (EXCHANGE2003)", "First Storage Group", "EXchange2003", _
"First Administrative Group", "ABC Company", "abcdomain.com", _
"testuser6", "Test", "User6"
So, your variables are being set properly. I am suprised that data types are not declared, but this is VBS and I mostly do VB.
In VB, the sub could be declared as:
Sub ADSICreateMailBoxEnabledUs er _
(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)
If you are not seeing the method, then maybe the requisite libraries are not loaded. Must you have Exchange installed on the pc attempting to execute this code?
Preece
ADSICreateMailBoxEnabledUs
"First Administrative Group", "ABC Company", "abcdomain.com", _
"testuser6", "Test", "User6"
So, your variables are being set properly. I am suprised that data types are not declared, but this is VBS and I mostly do VB.
In VB, the sub could be declared as:
Sub ADSICreateMailBoxEnabledUs
(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)
If you are not seeing the method, then maybe the requisite libraries are not loaded. Must you have Exchange installed on the pc attempting to execute this code?
Preece
ASKER
I agree. The question is, what libraries should be loaded.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
preece,
I am still working on this. So far no luck.
Thanks
I am still working on this. So far no luck.
Thanks
HTH
J.