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

Searching a Specific OU...

I have some code that works great, however it returns all
Groups within AD, but I only need it to return Groups that
are in a Specific OU.

I tried setting a filter on the search to that OU's DN, but then
it only returned that DN.

What's the best way using what I currently have?

Here's the basic code...

DirectoryEntry entry = new DirectoryEntry("LDAP://ww.xx.yy.zz","Username",
"Password", AuthenticationTypes.Secure);

DirectorySearcher dSearch = new DirectorySearcher(entry);
dSearch.Filter = "(&(objectClass=group))";

foreach(SearchResult sResultSet in dSearch.FindAll())
{
WHAT TO DO
}

That's the gist of it.

Any pointers would be appreciated.
Jan 29 '07 #1
2 2736
"Joe" <Jo*@discussions.microsoft.comwrote in message
news:41**********************************@microsof t.com...
>I have some code that works great, however it returns all
Groups within AD, but I only need it to return Groups that
are in a Specific OU.

I tried setting a filter on the search to that OU's DN, but then
it only returned that DN.

What's the best way using what I currently have?

Here's the basic code...

DirectoryEntry entry = new DirectoryEntry("LDAP://ww.xx.yy.zz","Username",
"Password", AuthenticationTypes.Secure);

DirectorySearcher dSearch = new DirectorySearcher(entry);
dSearch.Filter = "(&(objectClass=group))";

foreach(SearchResult sResultSet in dSearch.FindAll())
{
WHAT TO DO
}

That's the gist of it.

Any pointers would be appreciated.

Set the OU as root of the object your are binding to ...

DirectoryEntry entry = DirectoryEntry(LDAP://domain/ou=SomeOU, DC=xxx,DC=yyy,DC=zzz", ...;

Willy.

Jan 29 '07 #2
Willy,

Thanks. I had tried that, but was using the wrong format.

Works great.

"Willy Denoyette [MVP]" wrote:
"Joe" <Jo*@discussions.microsoft.comwrote in message
news:41**********************************@microsof t.com...
I have some code that works great, however it returns all
Groups within AD, but I only need it to return Groups that
are in a Specific OU.

I tried setting a filter on the search to that OU's DN, but then
it only returned that DN.

What's the best way using what I currently have?

Here's the basic code...

DirectoryEntry entry = new DirectoryEntry("LDAP://ww.xx.yy.zz","Username",
"Password", AuthenticationTypes.Secure);

DirectorySearcher dSearch = new DirectorySearcher(entry);
dSearch.Filter = "(&(objectClass=group))";

foreach(SearchResult sResultSet in dSearch.FindAll())
{
WHAT TO DO
}

That's the gist of it.

Any pointers would be appreciated.


Set the OU as root of the object your are binding to ...

DirectoryEntry entry = DirectoryEntry(LDAP://domain/ou=SomeOU, DC=xxx,DC=yyy,DC=zzz", ...;

Willy.

Jan 29 '07 #3

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

Similar topics

4
by: Michi | last post by:
I was wondering what the best solution is for making large numbers of TEXT (or BLOB?) fields searchable. For example, if I have a forum, what is the best way to be able to search for specific...
10
by: sffan | last post by:
I am new to database programming and was curious how others solve the problem of storing encrypted in data in db table columns and then subsequently searching for these records. The particular...
14
by: Ludwig77 | last post by:
I read that there are some tags that can be entered in a web page's meta tags in order to prevent web bot searching and indexing of the web page for search engines. What is the tagging that I...
4
by: James | last post by:
We have a need to search through an entire drive for a specific file name. The process is currently written with recursive loops through each directory and the Scripting.FileSystemObject. Problem...
5
by: justobservant | last post by:
When more than one keyword is typed into a search-query, most of the search-results displayed indicate specified keywords scattered throughout an entire website of content i.e., this is shown as...
5
by: robinsiebler | last post by:
I have a batch of files that I am trying to search for specific text in a specific format. Each file contains several items I want to search for. Here is a snippet from the file: .......
11
by: TheDataGuy | last post by:
Using MS ACCESS 2002 I developed a FORM, and within that FORM, I created and added a SEARCH BUTTON, and then I created a SUB-FORM, so that when an the END USER clicks on the FORM it will POP-UP...
5
by: peruron | last post by:
Hello again! I've been discussing the advantages of Python over C-Shell. I was asked if I can replace the use of "grep" in searching for a specific string in a multi-file directory - I have to go...
4
by: moswald | last post by:
I've been searching for a specific article for awhile now. About two years ago (maybe longer) there was an article in the C/C++ User's Journal that compared the performances of various stl...
3
by: Ahmad Jalil Qarshi | last post by:
Hi, I have a text file having size about 2 GB. The text file format is like: Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values For example...
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: 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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.