LDAP & DirectoryEntry problem

richee

New member
Joined
Jun 10, 2005
Messages
2
Programming Experience
Beginner
Hi all,

I`m trying to access an LDAP server using the System.DirectoryServices.DirectoryEntry but i just cant get it to bind for some reason.

Has anyone got any idea what I`m doing wrong? Am I missing some reference or something?

Here is the code I`m using.

Sub Main()
Dim strServerDNS As String = "ldap.exco.com:389"
Dim strSearchBaseDN As String = "ou=People,o=exco.com"
Dim strLDAPPath As String = "LDAP://" & strServerDNS & "/" & strSearchBaseDN
Dim objDirEntry As New
System.DirectoryServices.DirectoryEntry(strLDAPPath)
Dim searcher As New
System.DirectoryServices.DirectorySearcher(objDirEntry)
searcher.Filter = "(uid=" & "richee@exco.com" & ")"
searcher.PropertiesToLoad.Add("manager")
searcher.PropertiesToLoad.Add("telephoneNumber")
searcher.PropertiesToLoad.Add("BusinessGroup")
searcher.PropertiesToLoad.Add("Name")
Dim results As System.DirectoryServices.SearchResultCollection
Try
results = searcher.FindAll()
Catch ex As System.Exception
Console.WriteLine(ex.Message)
End Try
Dim result As System.DirectoryServices.SearchResult
For Each result In results
Console.WriteLine(result.Properties("manager")(0))
Console.WriteLine(result.Properties("telephoneNumber")(0))
Console.WriteLine(result.Properties("BusinessGroup")(0))
Console.WriteLine(result.Properties("Name")(0))
Next result
End Sub

I always get <Exception of type: '{System.Runtime.InteropServices.COMException}' occurred> errors...

I`m new to .NET and pretty sure its a setup error rather than a coding error. I`m using VS 2005 beta 2 by the way.

Thanks a million!

Richee.
 
Hi,

I've the same problems with VS2005 while in VS2003 all works well !

Any idea ?

I use OID (Oracle Internet Directory)
 
Back
Top