Solved

LDAP Query Help

Posted on 2012-04-12
1
282 Views
Last Modified: 2012-05-02
Hi folks,

I need to write a single LDAP query which looks at a couple of OU's and returns only the user account details.  I am running this through custom search in AD as I need to then take the completed query and pass this to an application.

An example of one of the OU's would be:

TestOU\Subdomain.Domain.Internal

Any thoughts,  I have the basics as being:

* (objectCategory=organizationalUnit)(ou=Accounts)) = Which would return any OU's called accounts

* (objectCategory=Person)(objectClass=User) = Which returns any user account.

I need to combine the two (Which I have tried with a number of &'s and such but with no success) to limit the search scope as the domain I am querying is huge and returning over 10000 records (There are 50k accounts, I dont need all of them!)

Any help you could offer would be great.
0
Comment
Question by:Jase_x
1 Comment
 
LVL 57

Accepted Solution

by:
Mike Kline earned 400 total points
ID: 37838366
You can only have one search base

You could use a nice third party (free) tool  like adfind

http://www.joeware.net/freetools/tools/adfind/index.htm

adfind -b "DN of Accounts OU" -f "&(objectcategory=person)(objectclass=user)" samaccountname

adinfo is another nice free tool but it is not command line (has a GUI)   http://www.cjwdev.co.uk/Software/ADReportingTool/Info.html

Thanks

Mike
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
In-place Upgrading Dirsync to Azure AD Connect
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

679 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