473,387 Members | 1,535 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,387 software developers and data experts.

Populate ComboBox from AD Query

I'm trying to populate a ComboBox on Form.load with a list of the OU's pulled
from AD. Here is the code that does not work:

Dim rootdir As New System.DirectoryServices.DirectoryEntry _
("LDAP://dc=corp,dc=abc,dc=com")
Dim rootsearch As New
System.DirectoryServices.DirectorySearcher(rootdir )
Dim result As System.DirectoryServices.SearchResult
rootsearch.SearchScope = DirectoryServices.SearchScope.Subtree
rootsearch.Filter = ("(objectClass = organizational Unit)")
For Each result In rootsearch.FindAll()
ComboBox2.Items.Add(result.GetDirectoryEntry)
Next

Any help would be greatly appreciated.....

Thanks

Nov 21 '05 #1
1 2197
Did you try with objectClass=organizationalUnit (no space between
organizational and Unit)?

"Primera" <Pr*****@discussions.microsoft.com> wrote in message
news:8D**********************************@microsof t.com...
I'm trying to populate a ComboBox on Form.load with a list of the OU's
pulled
from AD. Here is the code that does not work:

Dim rootdir As New System.DirectoryServices.DirectoryEntry _
("LDAP://dc=corp,dc=abc,dc=com")
Dim rootsearch As New
System.DirectoryServices.DirectorySearcher(rootdir )
Dim result As System.DirectoryServices.SearchResult
rootsearch.SearchScope = DirectoryServices.SearchScope.Subtree
rootsearch.Filter = ("(objectClass = organizational Unit)")
For Each result In rootsearch.FindAll()
ComboBox2.Items.Add(result.GetDirectoryEntry)
Next

Any help would be greatly appreciated.....

Thanks
Nov 21 '05 #2

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

Similar topics

1
by: raj | last post by:
I have a combo box that I want to populate from a SELECT query How to do this?
1
by: John | last post by:
I have two fields on a form. Once called School, the second called SchoolZip I want the users to be able to go to the ComboBox field called School, select the school they want, and have it auto...
4
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be...
11
by: DSR | last post by:
Help Please... I would like to populate a combo box on a form with a query that compares data from two tables. Any record that is unique in table1 should continue to populate my combobox. The...
16
by: agrawal.solutions | last post by:
Hello Friends I am asking a very silly question but i dont find any solution fo this.. I am selectiong a recordset and want to populate a combobox where id would be inviseble and the content...
5
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
1
by: freekedoutfish | last post by:
Hi. New member here Im sat at work, pounding my head off the desk because this tiny bit of simple code refuses to work. The sub is intended to pull data from the "companyname" column in the...
3
by: David | last post by:
I am trying to use Dlookup to populate a text box on a form, but haven't had any good luck so far. I've looked here at the posts and have used the Access help for examples. Northwind is way over...
2
by: mpmason14 | last post by:
i know there is a way to populate one combobox based on another, but i've never done it myself and am looking for some help. i have a table that has SwitchNo and NumberofPorts as two columns. i...
1
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
This actually stemmed from anther post I created. But, I have two combo boxes. ComboBox1 is populated by a list of Systems (DataSet from Oracle Query). Now, I want to take Combobox2, and when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.