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

VB.NET LDAP QUERY PROBLEM

Status
Not open for further replies.

Voyager18

Technical User
Mar 17, 2005
2
GB
Hello,
I am having problems with the following code. I think the namespace has been 'defunked', does anyone know the new route?

The following classes are not defined;
- DirectorySearcher
- SearchResultCollection
- SearchResult



<%@ Page Language="VB" debug="true" %>
<%@ Import namespace="System.directoryservices.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "
<script runat="server">
Public Function GetLDAPUsers(ByVal ldapServerName As String, ByVal pFindWhat As String) As ArrayList
Dim oSearcher As New DirectorySearcher
Dim oResults As SearchResultCollection
Dim oResult As SearchResult
Dim RetArray As New ArrayList
Dim mCount As Integer
Dim mIdx As Integer
Dim mLDAPRecord As String
Dim ResultFields() As String = {"securityEquals", "cn"}
Try
With oSearcher
.SearchRoot = New DirectoryEntry("LDAP://" & ldapServerName & "/dc=expotel,dc=org")
.PropertiesToLoad.AddRange(ResultFields)
.Filter = "cn=" & pFindWhat & "*"
oResults = .FindAll()
End With
mCount = oResults.Count
If mCount > 0 Then
For Each oResult In oResults
mLDAPRecord = oResult.GetDirectoryEntry().Properties("cn").Value & " " & oResult.GetDirectoryEntry().Properties("mail").Value
RetArray.Add(mLDAPRecord)
Next
End If
Catch e As Exception
MsgBox("Error is " & e.Message)
Return RetArray
End Try
Return RetArray
End Function

Protected Sub SearchLDAPbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
GetLDAPUsers(servername.Text, search.Text)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top