Solved

LDAP Query Assistance

Posted on 2010-09-09
9
351 Views
Last Modified: 2012-05-10
I need to create an LDAP query that is kciking my butt...

I need to find all users whose employeeID begins with:

1
5
Con-
Temp-

(that part I can make work)

But I also do NOT want to retuen any users whose samAccountName begins with 0 or 1.

Any help appreciated.




0
Comment
Question by:DonYoung
9 Comments
 
LVL 5

Expert Comment

by:swap_101982
Comment Utility
You can run dsquery command to get the required information, in dsquery if you omit -samid it will not look for samid
0
 
LVL 57

Accepted Solution

by:
Mike Kline earned 250 total points
Comment Utility
So right now I don't have time to fully create some test accounts
If you have the first part down if you don't want samaccountnames that start with those try
(|(!samaccountname=0*)(!samaccountname=1*))
that | is an OR
and the ! is a NOT
Thanks
Mike
0
 
LVL 2

Author Comment

by:DonYoung
Comment Utility
dsquery is not what I need.  This needs to be an LDAP Query (for use in an application)
0
 
LVL 2

Author Comment

by:DonYoung
Comment Utility
(|(!samaccountname=0*)(!samaccountname=1*)) returns errors...

This seems to work for the samAccount name part:  (|(!(samaccountname=0*))(!(samaccountname=1*)))

Where to place the AND and ORs is where I am confused...

Does this say:  Give me all employees with an empoloyeeID starting with a 1, a 5, con-, temp-, UNLESS the samAccountname starts with a 0 or a 1?

(&(!(samaccountname=0*))(!(samaccountname=1*))(|(employeeID=1*)(|(employeeID=5*)(|(employeeID=Temp*)(|(employeeID=Con-*))))))
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 14

Assisted Solution

by:Shabarinath Ramadasan
Shabarinath Ramadasan earned 250 total points
Comment Utility
(&(objectcategory=user)(|(samaccountname=1*)(samaccountname=5*)(samaccountname=con*)(samaccountname=temp*)(!samaccountname=0*)))
0
 
LVL 14

Expert Comment

by:Shabarinath Ramadasan
Comment Utility
Question is a bit confusing.

You asked for all accounts starting with 1, 5, con and temp.

Then again, you say that you dont want any account starting with 1.
"But I also do NOT want to retuen any users whose samAccountName begins with 0 or 1."

Please clarify.
Thanks
Shaba
0
 
LVL 2

Author Comment

by:DonYoung
Comment Utility
No I need employeeIDs starting with 1, 5, con- or temp- UNLESS the samAccountName starts with a 0 or a 1.
0
 
LVL 2

Author Comment

by:DonYoung
Comment Utility
OK I got it:

(&(objectcategory=user)(!(samaccountname=0*))(!(samaccountname=1*))(|(employeeID=1*)(|(employeeID=5*)(|(employeeID=Temp*)(|(employeeID=Con-*))))))

Thanks.  I shall split the points.
0
 
LVL 14

Expert Comment

by:Shabarinath Ramadasan
Comment Utility
Oh.. Got it..

(&(objectcategory=user)(|(employeeid=1*)(employeeid=5*)(employeeid=con*)(employeeid=temp*)(!samaccountname=0*)(!samaccountname=1*)))

Good luck
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Join & Write a Comment

Companies that have implemented Microsoft’s Active Directory need to ensure that the Active Directory is configured and operating properly. If there are issues found and not resolved, it eventually leads the components to fail or stop working and fi…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

772 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

11 Experts available now in Live!

Get 1:1 Help Now