Introduction to System.DirectoryServices, Part 1
Subject:   Good article, but I have a problem
Date:   2004-08-04 01:49:12
From:   ITGrunt
Excellent and interesting article. However I have tried this code in a VB.Net web app and have a problem. I have a button that fills a text box with AD usernames based on some text entered in a text box. This runs OK if I open a browser on the server, but fails on a client(logged in as same user), when I click the button. The error is 'An operations error has occured' and highlights the For Each statement. Code snippet below. Any ideas?
Thanks in advance.

Dim ADsrc As DirectorySearcher
Dim ADsrcResult As SearchResult
Dim ADsearchString As String = "(&(objectClass=user)(anr=" & txtSearchText.Text & "*))"
ADsrc = New DirectorySearcher(ADsearchString)
For Each ADsrcResult In ADsrc.FindAll()
Dim newitem As New ListItem
newitem.Text = ADsrcResult.Properties("Name")(0)
newitem.Value = ADsrcResult.Properties("samaccountName")(0)

1 to 1 of 1
  1. Good article, but I have a problem
    2004-08-05 03:54:00  Robbie Allen | O'Reilly AuthorO'Reilly Blogger [View]

1 to 1 of 1