Hi there,
I have a problem with System.DirectoryServices.DirectorySearcher . I have a VB.Net Web Application containing a web form which has on it a text box, a list box and a button.
The form loads, user types part of a name into the text box and upon clicking the button fills the list box with AD usernames.
This works fine if I call the page from the web server, but if I call the page from a client machine (logged on as same user) when the button is clicked I recieve 'An operations error has occured' with one line highlighted.
Code snippet below, the line highlighted is the For Each... line.
The site is set up for windows authentication and the page initially loads, it is only when the button is pressed to do the search it fails.
Ideas anyone?
Thanks in advance.
Dim ADsrc As DirectorySearcher
Dim ADsrcResult As SearchResult
Dim ADsearchString As String = "(&(objectClass=user)(anr=" & txtSearchText.Text & "*))"
ADsrc = New DirectorySearcher(ADsearchString)
lstUsersFound.Items.Clear()
For Each ADsrcResult In ADsrc.FindAll()
Dim newitem As New ListItem
newitem.Text = ADsrcResult.Properties("Name")(0)
newitem.Value = ADsrcResult.Properties("samaccountName")(0)
lstUsersFound.Items.Add(newitem)
--------------------------------
IT Grunt
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>doJahhK5KE2DficSSLSgVA==</Id>