I'm writing code to add a user to the Active Directory and create an Exchange mailbox for that user. Here's what I have:
Try
Dim de As New DirectoryEntry("LDAP://server.domain.net/cn=users,dc=domain,dc=net", "administrator", "password"
Dim UsrName As String = txtLogon.Text
Dim NewUser As System.DirectoryServices.DirectoryEntry
NewUser = de.Children.Add("CN=" & UsrName, "user"
Dim n As ActiveDs.IADsUser = NewUser.NativeObject
With NewUser
.Properties("sAMAccountName"
.Value = UsrName
.CommitChanges()
With n '.NativeObject
.AccountDisabled = False
.FirstName = txtFirstName.Text
.LastName = txtLastName.Text
.FullName = txtFirstName.Text & " " & txtLastName.Text
.SetInfo()
.SetPassword(txtPassword.Text)
End With
NewUser.CommitChanges()
End With
Dim objmailbox As CDOEXM.IMailboxStore = n
Dim strUrL As String
strUrL = "LDAP://server.domain.net/CN=Mailbox Store (SERVER),CN=First Storage Group,CN=InformationStore,CN=SERVER,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=PHRACK,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=domain,DC=net"
objmailbox.CreateMailbox(strUrL)
Catch ex As Exception
Console.WriteLine(ex.Message)
Console.ReadLine()
MsgBox(ex.ToString)
End Try
The user gets added to Active Directory fine, but at objmailbox.CreateMailbox(strURL), I get the error "The authentication mechanism is unknown." The strURL is cut and pasted directly out of ADSIEdit, so I know there are no typos there. This is driving me nuts. Has anyone run into this before, or does anyone have any ideas? Thanks.
Try
Dim de As New DirectoryEntry("LDAP://server.domain.net/cn=users,dc=domain,dc=net", "administrator", "password"
Dim UsrName As String = txtLogon.Text
Dim NewUser As System.DirectoryServices.DirectoryEntry
NewUser = de.Children.Add("CN=" & UsrName, "user"
Dim n As ActiveDs.IADsUser = NewUser.NativeObject
With NewUser
.Properties("sAMAccountName"
.CommitChanges()
With n '.NativeObject
.AccountDisabled = False
.FirstName = txtFirstName.Text
.LastName = txtLastName.Text
.FullName = txtFirstName.Text & " " & txtLastName.Text
.SetInfo()
.SetPassword(txtPassword.Text)
End With
NewUser.CommitChanges()
End With
Dim objmailbox As CDOEXM.IMailboxStore = n
Dim strUrL As String
strUrL = "LDAP://server.domain.net/CN=Mailbox Store (SERVER),CN=First Storage Group,CN=InformationStore,CN=SERVER,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=PHRACK,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=domain,DC=net"
objmailbox.CreateMailbox(strUrL)
Catch ex As Exception
Console.WriteLine(ex.Message)
Console.ReadLine()
MsgBox(ex.ToString)
End Try
The user gets added to Active Directory fine, but at objmailbox.CreateMailbox(strURL), I get the error "The authentication mechanism is unknown." The strURL is cut and pasted directly out of ADSIEdit, so I know there are no typos there. This is driving me nuts. Has anyone run into this before, or does anyone have any ideas? Thanks.