Solved

Running custom LDAP query in AD

Posted on 2011-02-23
4
730 Views
Last Modified: 2013-12-24
Hi

We're running AD 2008 with 2008 Server member servers too. For some users we have a custom application that sets special AD attributes, these attributes are named

"customSync" - possible values YES, NO, SP1
"customEmail" - possible values PARTNER, SMTP1, SMTP2

What I'd like to do is run a query in AD to find users with some of these values, as below:

1. customSync=SP1
2. customEmail = SMTP1
3. customSync=YES *and* customEmail=SMTP2
4. customSync=YES *or& customEmail=SMTP2

I'd like to use ADUC to do this. I guess I can create a query within there, but after that I'm lost? All I can see is how to set queries for existing attributes (e.g. display name).

Could someone advise? I guess I need to run some sort of Custom Query but am not sure of which one and also the syntax to use for the four situations above.


0
Comment
Question by:kam_uk
  • 3
4 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 34964435
You would need to create a custum Query. Do this by selecting new query and when you define the query select Custom search from the drop down.

the query should be

(&(objectcategory=person)(objectclass=user)(customSync=SP1))

(&(objectcategory=person)(objectclass=user)(customEMail=SMTP1))

(&(objectcategory=person)(objectclass=user)(customSync=YES)(customEMail=SMTP2))

(&(objectcategory=person)(objectclass=user)(|(customSync=YES)(customEMail=SMTP2)))
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34964461
Also here is a link that explains the queries

http://technet.microsoft.com/en-us/library/aa996205(EXCHG.65).aspx
0
 
LVL 3

Author Comment

by:kam_uk
ID: 34964488
Thanks!

And, instead of users only, I just wanted all objects returned for those results I wanted, would it be:

1. (customSync=SP1)
2. (customEMail=SMTP1)
3. (&(customSync=YES)(customEMail=SMTP2))
4. ??

or for #1, #2 can I omit the brackets? [the link you gave me does always have brackets though)
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34964535
Depending on how many objects you have in your AD these will not be effecient searches becuase I am assuming these attributes are not indexed. You could run them as you have listed but understand this could put some overhead on your DC when running the query.
1 & 2 need to have the ()
4 wound be
(|(customSync=YES)(customEMail=SMTP2))
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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.

803 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