Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


DirectorySearcher and Active Directory

Posted on 2004-10-28
Medium Priority
Last Modified: 2010-04-24
Using DirectorySearcher for VB.NET and Active Directory how do I search subdirectories for a single users account?

Dim adEntry As New DirectoryEntry("LDAP://domain/OU=X,DC=X,DC=X", user, pass)
Dim adSearch As New DirectorySearcher(adEntry)
adSearch.Filter = "(SAMAccountName=" + user + ")"
Dim adResult As SearchResult = adSearch.FindOne()

When I try the above it doesn't return anything because OU has like 20 subdirectories with users in each. But if I specify "LDAP://domain/OU=Y,OU=X,DC=X,DC=X" it now will only search OU=Y and not all subfolders of OU=X...

A complete example would be appreciated.
Question by:sman003
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 18

Accepted Solution

armoghan earned 1440 total points
ID: 12441218

Author Comment

ID: 12444427
yep actually did, though is the filter "(anr="+ username +")" the correct filter for searching by windows login name?
LVL 18

Expert Comment

ID: 12460641
I think this is the way for getting things under windows login name
see other discussions from google

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question