|
-
Jul 31st, 2007, 11:11 AM
#1
Thread Starter
Addicted Member
[2005] Create Exchange 2003 Mailbox
Hello All,
I am trying to write a function that will create an Exchange 2003 mailbox. I got this chunk of code off of the MSDN, but I can't get it to work. I keep getting a conversion error (see comments below):
Code:
CreateUserAndMailbox(ByVal UserName As String, ByVal UserFullName As String, ByVal UserTempPassword As String, ByVal strAuthUser As String, ByVal strPassword As String) As Boolean
'TODO: Change these items to values for your domain or organization.
Dim defaultNC As String = "DC=avtron,DC=corp"
Dim [alias] As String = UserName
Dim fullName As String = UserFullName
Dim password As String = UserTempPassword
Dim domainName As String = "avtron.corp"
Dim homeMDB As String = "CN=Exchange1,CN=First Storage Group,CN=InformationStore,CN=ExchangeServer1,CN=Servers,CN=HomeTown,CN=Administrative Groups,CN=Avtron,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=avtron,DC=corp"
Dim container As DirectoryEntry, user As DirectoryEntry
Dim mailbox As CDOEXM.IMailboxStore
'This creates the new user in the "users" container.
'Set the sAMAccountName and the password
container = New DirectoryEntry("LDAP://cn=users," + defaultNC)
user = container.Children.Add("cn=" + fullName, "user")
user.Properties("sAMAccountName").Add([alias])
user.CommitChanges()
user.Invoke("SetPassword", New Object() {password})
'This enables the new user.
user.Properties("userAccountControl").Value = 512
'ADS_UF_NORMAL_ACCOUNT
user.CommitChanges()
'Obtain the IMailboxStore interface, create the mailbox, and commit the changes.
'****** Conversion Error happens here *******
mailbox = CType(user.NativeObject, IMailboxStore)
mailbox.CreateMailbox(homeMDB)
user.CommitChanges()
Return True
End Function
I have the Exchange Management tools installed on my dev machine and still can't get it to work. Any help would be greatly appreciated.
Thanks,
Jim P.
Last edited by jpiller; Aug 1st, 2007 at 11:51 AM.
"The Force will be with you, always."
--Ben Kenobi--
-
Aug 1st, 2007, 07:35 AM
#2
Thread Starter
Addicted Member
Re: [2005] Create Exchange 2003 Mailbox
No one has any ideas about this at all? C'mon...I know you geniuses have something to offer on this subject...please????
"The Force will be with you, always."
--Ben Kenobi--
-
Aug 1st, 2007, 11:13 AM
#3
Re: [2005] Create Exchange 2003 Mailbox
It helps to know the exact conversion error. And the link where you got it from.
-
Aug 8th, 2007, 12:59 PM
#4
Thread Starter
Addicted Member
Re: [2005] Create Exchange 2003 Mailbox
Ok, I know it's been a week, but I've come back around to this problem. Here is the exact error that I'm getting:
Unable to cast COM object of type'System._ComObject' to interface type 'CDOEXM.IMailboxStore'. This operation failed because the QueryInterface call on the COM component for the interface with IID... failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I hope that helps point someone in the right direction of an answer!
Thanks,
Jim P.
"The Force will be with you, always."
--Ben Kenobi--
-
Aug 8th, 2007, 01:29 PM
#5
Thread Starter
Addicted Member
Re: [2005] Create Exchange 2003 Mailbox
Ok, I installed the Exchange Management tools on the web server and that seems to have solved the problem described above, but now I'm getting a different exception error:
Code:
An operations error occurred. (Exception from HRESULT: 0x80072020)
I'm not sure, but this looks like one of those "an error occurred" errors that doesn't really point to any specific problem. I have tried googling without too much luck, so any help is appreciated. The line that is failing is this one:
Code:
Dim homeMDB As String = "CN=Exchange1,CN=First Storage Group,CN=InformationStore,CN=ExchangeServer1,CN=Servers,CN=HomeTown,CN=Administrative Groups,CN=Avtron,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=avtron,DC=corp"
mailbox.CreateMailbox(homeMDB)
Thanks,
Jim P.
"The Force will be with you, always."
--Ben Kenobi--
-
Aug 10th, 2007, 01:15 PM
#6
Thread Starter
Addicted Member
Re: [2005] Create Exchange 2003 Mailbox
anyone have any ideas at all?
"The Force will be with you, always."
--Ben Kenobi--
-
Aug 13th, 2007, 10:05 AM
#7
Re: [2005] Create Exchange 2003 Mailbox
OK, I'm not a guru when it comes to those connection strings, but shouldn't you specify a server name in there? Or if you don't have to, can you?
LDAP://10.55.48.48:2389/CN=Exchange1,CN=First Storage Group,CN=InformationStore,CN=ExchangeServer1,CN=Servers,CN=HomeTown,CN=Administrative Groups,CN=Avtron,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=avtron,DC=corp
Once you create that string, go to start > run > and paste it in there, and it should open up in Address Book for you...
-
Aug 13th, 2007, 12:06 PM
#8
Thread Starter
Addicted Member
Re: [2005] Create Exchange 2003 Mailbox
Thanks for the idea...I'll try it and get back with you!
"The Force will be with you, always."
--Ben Kenobi--
-
Jul 21st, 2008, 09:47 AM
#9
New Member
Re: [2005] Create Exchange 2003 Mailbox
Did you ever resolve this problem? We are receiving the same COM registration Cast exceptions on one of our BizTalk servers regarding our exchange 2003 automation components that we built. We have been unable to figure out why out of the blue we would get the following error on only one of our BizTalk servers and not the otehr when they are maintained the same with security updates.
Message: Create Mailbox Failed: FAILED: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'CDOEXM.IMailboxStore'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{25150F41-5734-11D2-A593-00C04F990D8A}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
We are thinking about re-installing the Exchange 2003 management tools but it seems the system management tools seem to be unaffected because we are able to manually administer the environment with it.
-Brian
-
Jul 21st, 2008, 10:56 AM
#10
Thread Starter
Addicted Member
Re: [2005] Create Exchange 2003 Mailbox
Brian,
I never did find a solution to this issue...i just kind of gave up on it.
Sorry,
Jim P.
"The Force will be with you, always."
--Ben Kenobi--
-
Jul 21st, 2008, 11:05 AM
#11
New Member
Re: [2005] Create Exchange 2003 Mailbox
Give up?? .... you can't give up!
Well unfortunely, lol, we can't give up on it.
On your problem are you sure you have the proper AD delegation to do what you want?
-Brian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|