Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2004, 10:45 AM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create ADSI User and Exchange Mailbox

Hello,
       I am trying to automate the account creation process for Active Directory and Exchange 2000 using ADSI and CDOEXM.

Using samples from MSDN an AD user is created however when it fails when I try to create the Exchange mailbox - either with
1) Type mismatch on the 'Set oMailbox = oUser' line
or
2) 'Object doesn't support this property or method' on the 'CreateMailbox' line if the vars are not explicitly declared.

Any comments or suggestions would be most welcome.

Best Regards,

Steven


Code stub:
----------
Private Sub cmdCreate_Click()
    Dim oUser As IADsUser
    Dim ou As IADsContainer
    Dim oMailbox As CDOEXM.IMailboxStore
    Dim sLog As String, sMBXStoreDN As String
    Dim sLDAPDomain
    On Error GoTo errHandler

    sLog = "0"
    sLDAPDomain = "DC=T,DC=net"
   ' Create AD User in correct OU
    Set ou = GetObject("LDAP://OU=IT,OU=Userids," & sLDAPDomain)
    sLog = "1"

    Set oUser = ou.Create("user", "CN=" & "s_test1")
    sLog = "2"
    ' Set properties
    oUser.Put "samAccountName", "s_test1"
    oUser.Put "userPrincipalName", "s_test1"
    oUser.SetInfo

    ' Set password and enable account
    oUser.SetPassword "testing123"
    oUser.AccountDisabled = False
    oUser.SetInfo
    sLog = "2b"

    ' Create Exchange Mailbox
    sLog = "3"
    Set oMailbox = oUser

    sLog = "4"
    szStoreName = "Mailbox Store (EXCHANGE1)"
    szStorageGroup = "First Storage Group"
    szServerName = "EXCHANGE1"
    szAdminGroup = "First Administrative Group"
    szExchangeOrg = "TNET"
    sMBXStoreDN = "LDAP://CN=" & szStoreName & _
                            ",CN=" & szStorageGroup & _
                            ",CN=InformationStore" & _
                            ",CN=" & szServerName & _
                            ",CN=Servers" & _
                            ",CN=" & szAdminGroup & _
                            ",CN=Administrative Groups" & _
                            ",CN=" & szExchangeOrg & _
                            ",CN=Microsoft
Exchange,CN=Services,CN=Configuration," & _
                            sLDAPDomain

   ' MsgBox sMBXStoreDN
   ' MsgBox oMailbox.HomeMDB
    oMailbox.CreateMailbox sMBXStoreDN
    sLog = "4b"
    oUser.SetInfo

    sLog = "5"

Exiting:
    Set ou = Nothing
    Set oUser = Nothing
    Set oMailbox = Nothing
    Exit Sub
errHandler:
    MsgBox Err.Description & " log:" & sLog
    GoTo Exiting
End Sub





 
Old May 5th, 2004, 02:16 PM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Follow up,
      There is nothing wrong with the code. The problem is with the machine it is running on. But I still would like to get it working on the original server. Is there something that needs to be running? The dll's for cdoexm.dll and activeds.tlb are the same.

Steven

 
Old May 26th, 2004, 04:40 PM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Were you able to resolve the issue? I am facing the same problem with my code.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Exchange Mailbox tclancey Pro Visual Basic 2005 4 April 16th, 2007 09:31 AM
Exchange create mailbox arjen1984 C# 0 March 16th, 2007 05:17 AM
Create/delete Exchange 5.5 Mailbox with VB.Net DennisTh VB How-To 7 August 5th, 2004 08:52 PM
How to create a mailbox in exchange 2003 using ASP nobreferreira Classic ASP Basics 0 March 22nd, 2004 01:45 PM
c#, ADSI, DirectoryService and Exchange 5.5 georgeh C# 1 October 9th, 2003 04:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.