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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query LDAP directory (non-AD) using System.DirectoryServices

Status
Not open for further replies.

g33man

Programmer
Dec 22, 2006
50
CA
I am trying to query a public LDAP in my VB.NET application. The LDAP is not Active Directory. I found an example on the net, which makes no reference to AD. My test is based on that example. When I run this sample, an exception occurs, and I get the error "An operations error occurred.".
Suggestions are welcome.

Code:
Dim oRoot As DirectoryEntry = New DirectoryEntry("LDAP://123.12.12.1/ou=MYORG,ou=EXTERN,o=MO,c=CA") 'not the real IP
Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
Dim oResults As SearchResultCollection

Try
    oSearcher.PropertiesToLoad.Add("cn")
    oResults = oSearcher.FindAll
    MsgBox(oResults.Count)
Catch e As Exception
    MsgBox("Error is [" & e.Message & "]")
End Try
 

Which line causes the error?

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
The exception is raised by the line:
oResults = oSearcher.FindAll

If I take out the exception handler, my program just stalls at this line, and does not return.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top