Solved

ADfind query

Posted on 2008-10-24
3
1,667 Views
Last Modified: 2013-12-24
Hello,
 I'm trying to construct a statement to query Active Directory. Currently, my query returns all active user's information and outputs it as a CSV. What I want to do is also get contacts out of AD in the same query (if possible). As a test, I just tried changing the objectclass to "contact" (which I believe is the right class) but it returned nothing. My current statement is as follows:

adfind -default -bit -f "&(objectcategory=person)(objectclass=user)(useraccountcontrol=*)(!(useraccountcontrol:AND:=2))" displayname givenname sn initials title department physicalDeliveryOfficeName company manager telephoneNumber mobile facsimileTelephoneNumber homephone pager ipphone mail wWWHomePage streetAddress postOfficeBox l st co postalCode -list -nodn -csv . >exports.csv

Any and all help is appreciated!

Thank you,
 - Jeff Miller

EDIT:
 I should have mentioned that I am using joeware's freeware tool "ADFind.exe". It's at http://www.joeware.net/freetools/tools/adfind/index.htm.
0
Comment
Question by:Francoisbouchard
[X]
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
3 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 22802615

Hey Jeff :)

You're absolutely right about the objectClass, but Contacts don't have userAccountControl so &(userAccountControl=*) will be filtering them out. That doesn't really leave much in the filter as you only have the objectClass test :)

HTH

Chris
0
 
LVL 30

Accepted Solution

by:
LauraEHunterMVP earned 500 total points
ID: 22803028
I -think- the query you want will look like this:

(|(&(objectcategory=person)(objectclass=user)(useraccountcontrol=*)(!(useraccountcontrol:AND:=2)))(&(objectcategory=person)(objectclass=contact)))

In English, "Give me all objects that are either [1] user objects whose userAccountControl is configured but not with bit 2 set, or [2] contact objects."

It's a really computationally expensive query if your environment is of any signifigant size, to the point where you might just be better off running 2 separate queries and concatenating the results once you've retrieved them.
0
 

Author Closing Comment

by:Francoisbouchard
ID: 31509777
Thanks very much! The query works perfectly and is actually quite fast. I'm pulling about 360 entries with this with no problem. I will definitely keep the separate query in mind for when our network becomes bigger. Thanks again!
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

628 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