Results 1 to 11 of 11

Thread: [2005] Create Exchange 2003 Mailbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Cleveland, Ohio
    Posts
    185

    Exclamation [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--

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Cleveland, Ohio
    Posts
    185

    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--

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Create Exchange 2003 Mailbox

    It helps to know the exact conversion error. And the link where you got it from.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Cleveland, Ohio
    Posts
    185

    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--

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Cleveland, Ohio
    Posts
    185

    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--

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Cleveland, Ohio
    Posts
    185

    Re: [2005] Create Exchange 2003 Mailbox

    anyone have any ideas at all?
    "The Force will be with you, always."

    --Ben Kenobi--

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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...

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Cleveland, Ohio
    Posts
    185

    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--

  9. #9
    New Member
    Join Date
    Jul 2008
    Posts
    2

    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

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Cleveland, Ohio
    Posts
    185

    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--

  11. #11
    New Member
    Join Date
    Jul 2008
    Posts
    2

    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
  •  



Click Here to Expand Forum to Full Width