Solved

Exchange ADSi

Posted on 2002-05-02
5
597 Views
Last Modified: 2008-03-17
I am trying to create a mailnox using EXCDO

I get the following error

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'objMailbox.CreateMailbox'

when I do this

Set objMailbox = Usr
               objMailbox.CreateMailbox "LDAP://"&homeDB
              usr.SetInfo
               Set objMailbox = Nothing

works on a test system just not on production, same permissions and everything any ideas.

0
Comment
Question by:Joshuap
  • 3
5 Comments
 
LVL 1

Expert Comment

by:ramani_gr
ID: 6988370
Hope this function helps you.


Function CreateMailboxCDOPerson(strFirstName As String, _
                                   strLastName As String, _
                                   strHomeMDBUrl As String) As Boolean
'strHomeMDBUrl should look like this
'strHomeMDBUrl = "CN=Mailbox Store (MYSTORE),CN=First Storage Group,
'                 CN=InformationStore,CN=MYSTORE,CN=Servers,
'                 CN=First Administrative Group,CN=Administrative Groups,
'                 CN=IASI,CN=Microsoft Exchange,CN=Services,CN=Configuration,
'                 DC=mydomain,DC=extest,DC=microsoft,DC=com"

    Dim oPerson         As New CDO.Person
    Dim oMailbox        As CDOEXM.IMailboxStore
    Dim strUserName     As String
    Dim strURL          As String
    Dim strContainerName As String
    Dim Result       As Boolean
   
    Result = True
   
    strUserName = strFirstName & strLastName
   
    strContainerName = "Users"
    ' Create URL for the user
    Result = Result And CreateUserURL(strURL, strContainerName, False, strUserName)
   
    oPerson.FirstName = strFirstName
    oPerson.LastName = strLastName
   
    oPerson.DataSource.SaveTo strURL
    Result = Result And CheckError("SaveTo " & strURL)
   
    Set oPerson = New CDO.Person
    ' Bind
    oPerson.DataSource.Open strURL
    Result = Result And CheckError("Bind to CDO User " & strUserName)
   
    ' Create Mailbox
    Set oMailbox = oPerson
    oMailbox.CreateMailbox strHomeMDBUrl
    Result = Result And CheckError("Create Mailbox for CDO User " & strUserName)
   
    ' Save
    oPerson.DataSource.Save
    Result = Result And CheckError("Save CDO User " & strUserName)
       
    'CleanUp
    Set oPerson = Nothing
    Set oMailbox = Nothing
   
    CreateMailboxCDOPerson = Result
End Function
0
 
LVL 1

Accepted Solution

by:
ramani_gr earned 100 total points
ID: 6988375
One more using ADSI

Function ADSICreateMailBoxRecipient(ServerName As String, _
                                    DomainName As String, _
                                    emailname As String, _
                                    FirstName As String, _
                                    LastName As String) As Integer

'ServerName is something like "MyServer6"
'DomainName is something like "DC=MYDOMAIN3,DC=microsoft,DC=com"
'emailname is something like "jamessmith"

'this assumes the MDB to be "Private MDB"


Dim objUser As IADsUser
Dim objContainer As IADsContainer
Dim objMailbox As CDOEXM.IMailboxStore
Dim recipname As String, recip As String

recip = "CN=" & emailname

' get the container
Set objContainer = GetObject("LDAP://" + ServerName + "/" + _
                            "CN=users," + DomainName)

' 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 "password"  'let user change it later
objUser.AccountDisabled = False

Set objMailbox = objUser

'Create a mailbox for the recipient
'You cannot create a mailbox using ADSI, so use CDOEXM
objMailbox.CreateMailbox "LDAP://" + ServerName + _
                         "/CN=Private MDB" + _
                         ",CN=First Storage Group,CN=InformationStore,CN=" + _
                         ServerName + _
                         ",CN=Servers,CN=First Administrative Group," + _
                         "CN=Administrative Groups,CN=First Organization," + _
                         "CN=Microsoft Exchange,CN=Services," + _
                         "CN=Configuration," + DomainName
objUser.SetInfo

End Function
0
 
LVL 1

Expert Comment

by:ramani_gr
ID: 6988378
and check whether the Exchange services are running.
0
 
LVL 15

Expert Comment

by:gladxml
ID: 8795680
No comment has been added lately and it seems that this question have been abandoned. So it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question or invite a Moderator to close this question if there's no reply from you after seven days.

In the absence of responses, I will recommend the following:

To accept the comment and points awarded to ramani_gr

** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **


Just trying to help for the cleanup...
gladxml
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS Question.. 3 78
toggle checkboxes when a checkbox is checked 16 52
Hide row when retrieving data from database 6 53
Select2 jquery help 9 74
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now