Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateMailbox() won't work 1

Status
Not open for further replies.

Jerrycurl

Programmer
Aug 4, 1999
85
US
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.
 
Just out of curiosity... how did you get the CDOEMX.DLL to load as a reference in your .Net app? I'm having the same problem as you, I can create an AD account but the exchange creation doesn't work.
 
Yikes! That was almost 3 years ago. I can't find any .Net source code for this, so I think I must have ended up doing it in VB6. Sorry.
 
LOL! Well... I did figure out the problem with your code.

After the objmailbox.CreateMailbox(strUrL) line insert this:

n.SetInfo()

It worked for me... :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top