473,414 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

AD Datasource for DropDown box

I am trying to populate a drop down box with the query of users from Active
Directory. The query is working fine but the data that shows up in the
dropdown box is "System.DirectoryServices.Searchreult". Here is the code:
Anys suggestions anyone?

Protected Sub btnFindUser_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnFindUser.Click
Dim objRootDSE As New DirectoryEntry("LDAP://RootDSE")
Dim rootString As New String("LDAP://" +
objRootDSE.Properties("defaultNamingContext").Valu e)
Dim root As New DirectoryEntry(rootString)
Dim objSearch As New DirectorySearcher(root)
Dim oResults As SearchResultCollection
Dim oresult As SearchResult

Try
objSearch.Filter = "(&(objectCategory=Person)(sn=" +
txtLastName.Text + "))"
objSearch.PropertiesToLoad.Add("ADsPath")
objSearch.PropertiesToLoad.Add("displayName")
oResults = objSearch.FindAll()
lblresultsCount.Text = oResults.Count

drpUsersFound.DataSource = oResults
drpUsersFound.DataBind()

For Each oresult In oResults
If Not oresult.GetDirectoryEntry().Properties("cn").Value =
"" Then
drpUsersFound.DataValueField =
oresult.GetDirectoryEntry().Properties("adspath"). Value
Dim temp1 As String = oresult.Properties("adsPath")(0)
Dim temp2 As String = oresult.Properties("displayName")(0)
drpUsersFound.DataTextField =
oresult.GetDirectoryEntry().Properties("displaynam e").Value
lblName.Text =
oresult.GetDirectoryEntry().Properties("displaynam e").Value

End If
Next
drpUsersFound.Visible = True
Label2.Visible = True

Catch ex As Exception
Console.WriteLine("the error is " + ex.ToString())
End Try
End Sub

End Class

--
Lorenzo Gonzalez
ACS/Spherion
Lead Technical System Engineer
Nov 15 '06 #1
0 819

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: John Spiegel | last post by:
Hi all, I think I've stared at it until it's made me stupid(er?). What am I missing about setting the list of the dropdown to display data pulled from a table? //......
2
by: Jake S | last post by:
Hi all, Is it possibele to set the datasource of a dropdown list to a datareader? When I try to the only column I receive is a column populated by the datasource name repeated the amount of...
4
by: Merdaad | last post by:
Hi, In my dropdown I bind to a datasource. After that I try to do one of the following: 1. Add an Item to the dropdown using dd.Items.Add(newe ListItem("textstr")); 2. Change the text of an...
20
by: John Spiegel | last post by:
Hi all, I think I've stared at it until it's made me stupid(er?). What am I missing about setting the list of the dropdown to display data pulled from a table? //......
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I used the Data Sources window to drop a custom object onto the designer surface. It created a BindingSource and BindingNavigator as a result. When I open the Properties window...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.