Solved

Running custom LDAP query in AD

Posted on 2011-02-23
4
725 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 2012 R2 Server -- SERIVCES checklist ? 4 92
Issue with server 2012 R2 and access to folders 20 38
edit user account 1 29
Cloud to Hybrid 4 14
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
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 tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now