Hello,
I am a realtive beginner and am trying to create an Exchange mailbox using ASDI and AD but am having problems.
The main problem is with determining the correct LDAP String. Is there a way to browser AD via LDAP to see where to make my changes and to see if the changes have been made.
What I have is
strPath = "LDAP://" & ServerName & "/o=" & OrgName & "/ou=" & SiteName & "/cn=Recipients"
How can I verify this exsists? The problem as well I am not entirely sure what OrgNam and SiteName should be for me (this is why I would like to Browse AD via LDAP, to actually see the positions and changes)
The full code that I am using for anyone interested is as follows..
Thanks in advance
Stefan
----------------------------------------
Public Sub Create(MailboxName As String, ServerName As String, OrgName As String, SiteName As String, UserName As String, DomainName As String, FirstName As String, LastName As String, SMTPDomain As String, X400Domain As String)
Dim vArray As Variant
Dim oArray(100) As Integer
Dim strDomain As String
Dim strUser As String
Dim strPath As String
Dim mntAcct As Object
Dim varSecurityID As Variant
Dim varSecurityDescriptor As Variant
Dim recipcont_obj As Object
Dim recip_obj As Object
On Error GoTo Err_Exit
'Create an instance of AcctCrt.DLL
Set mntAcct = CreateObject("MSExchange.AcctMgmt.1"
strDomain = DomainName
strUser = UserName
'Create the LDAP URL to set the current context
strPath = "LDAP://" & ServerName & "/o=" & OrgName & "/ou=" & SiteName & "/cn=Recipients"
Text1 = strPath
Const gstrNone = ""
' Get the SID and descriptor for the user ID that all mailboxes are associated with
Call mntAcct.GetSidFromName(strDomain, strUser, varSecurityID)
Call mntAcct.GenerateSecDescriptor(strDomain, strUser, varSecurityDescriptor)
' create the mailbox in the DS with ADSI
Set recipcont_obj = GetObject(CStr(strPath))
'LDAP Name...should be same as alias
Set recip_obj = recipcont_obj.Create("organizationalPerson", "cn=" & MailboxName)
recip_obj.Put "mailPreferenceOption", 0
'Last Name
recip_obj.Put "sn", (CVar(LastName))
'Mailbox Name
recip_obj.Put "cn", (CVar(MailboxName))
'First Name
recip_obj.Put "givenName", (CVar(FirstName))
'Alias
recip_obj.Put "uid", (CVar(MailboxName))
recip_obj.Put "Home-MTA", (CVar("cn=Microsoft MTA,cn=" & ServerName & ",cn=Servers,cn=Configuration,ou=" & SiteName & ",o=" & OrgName))
recip_obj.Put "Home-MDB", (CVar("cn=Microsoft Private MDB,cn=" & ServerName & ",cn=Servers,cn=Configuration,ou=" & SiteName & ",o=" & OrgName))
recip_obj.Put "Assoc-NT-Account", (CVar(varSecurityID))
'SMTP Address
recip_obj.Put "mail", (CVar(MailboxName & SMTPDomain))
'X400 Address
recip_obj.Put "textEncodedORaddress", (CVar(X400Domain & "s=" & LastName & ";g=" & FirstName & ";")
recip_obj.setinfo ' commit the contents of the adsi object to the directory
Exit Sub
Err_Exit:
App.LogEvent vbCrLf & vbCrLf & "Description: " & Err.Description & vbCrLf & vbCrLf & "Number: " & Err.Number & vbCrLf & vbCrLf, vbLogEventTypeInformation
End Sub
Private Sub Command1_Click()
Create "TEST", "SOLEIL", "DOMAINEX", "Default-First-Site-Name", "ADMINISTRATOR", "DOMAIN", "fNAME", "lNAME", "@domain.com", "c=US;a= ;p=POSTMAN;o=EXCHANGE;"
I am a realtive beginner and am trying to create an Exchange mailbox using ASDI and AD but am having problems.
The main problem is with determining the correct LDAP String. Is there a way to browser AD via LDAP to see where to make my changes and to see if the changes have been made.
What I have is
strPath = "LDAP://" & ServerName & "/o=" & OrgName & "/ou=" & SiteName & "/cn=Recipients"
How can I verify this exsists? The problem as well I am not entirely sure what OrgNam and SiteName should be for me (this is why I would like to Browse AD via LDAP, to actually see the positions and changes)
The full code that I am using for anyone interested is as follows..
Thanks in advance
Stefan
----------------------------------------
Public Sub Create(MailboxName As String, ServerName As String, OrgName As String, SiteName As String, UserName As String, DomainName As String, FirstName As String, LastName As String, SMTPDomain As String, X400Domain As String)
Dim vArray As Variant
Dim oArray(100) As Integer
Dim strDomain As String
Dim strUser As String
Dim strPath As String
Dim mntAcct As Object
Dim varSecurityID As Variant
Dim varSecurityDescriptor As Variant
Dim recipcont_obj As Object
Dim recip_obj As Object
On Error GoTo Err_Exit
'Create an instance of AcctCrt.DLL
Set mntAcct = CreateObject("MSExchange.AcctMgmt.1"
strDomain = DomainName
strUser = UserName
'Create the LDAP URL to set the current context
strPath = "LDAP://" & ServerName & "/o=" & OrgName & "/ou=" & SiteName & "/cn=Recipients"
Text1 = strPath
Const gstrNone = ""
' Get the SID and descriptor for the user ID that all mailboxes are associated with
Call mntAcct.GetSidFromName(strDomain, strUser, varSecurityID)
Call mntAcct.GenerateSecDescriptor(strDomain, strUser, varSecurityDescriptor)
' create the mailbox in the DS with ADSI
Set recipcont_obj = GetObject(CStr(strPath))
'LDAP Name...should be same as alias
Set recip_obj = recipcont_obj.Create("organizationalPerson", "cn=" & MailboxName)
recip_obj.Put "mailPreferenceOption", 0
'Last Name
recip_obj.Put "sn", (CVar(LastName))
'Mailbox Name
recip_obj.Put "cn", (CVar(MailboxName))
'First Name
recip_obj.Put "givenName", (CVar(FirstName))
'Alias
recip_obj.Put "uid", (CVar(MailboxName))
recip_obj.Put "Home-MTA", (CVar("cn=Microsoft MTA,cn=" & ServerName & ",cn=Servers,cn=Configuration,ou=" & SiteName & ",o=" & OrgName))
recip_obj.Put "Home-MDB", (CVar("cn=Microsoft Private MDB,cn=" & ServerName & ",cn=Servers,cn=Configuration,ou=" & SiteName & ",o=" & OrgName))
recip_obj.Put "Assoc-NT-Account", (CVar(varSecurityID))
'SMTP Address
recip_obj.Put "mail", (CVar(MailboxName & SMTPDomain))
'X400 Address
recip_obj.Put "textEncodedORaddress", (CVar(X400Domain & "s=" & LastName & ";g=" & FirstName & ";")
recip_obj.setinfo ' commit the contents of the adsi object to the directory
Exit Sub
Err_Exit:
App.LogEvent vbCrLf & vbCrLf & "Description: " & Err.Description & vbCrLf & vbCrLf & "Number: " & Err.Number & vbCrLf & vbCrLf, vbLogEventTypeInformation
End Sub
Private Sub Command1_Click()
Create "TEST", "SOLEIL", "DOMAINEX", "Default-First-Site-Name", "ADMINISTRATOR", "DOMAIN", "fNAME", "lNAME", "@domain.com", "c=US;a= ;p=POSTMAN;o=EXCHANGE;"