• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

LDAP Query Assistance

I need to create an LDAP query that is kciking my butt...

I need to find all users whose employeeID begins with:


(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.

2 Solutions
Swapnil PrajapatiSr. System AdministratorCommented:
You can run dsquery command to get the required information, in dsquery if you omit -samid it will not look for samid
Mike KlineCommented:
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
that | is an OR
and the ! is a NOT
DonYoungSr. Enterprise ArchitectAuthor Commented:
dsquery is not what I need.  This needs to be an LDAP Query (for use in an application)
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

DonYoungSr. Enterprise ArchitectAuthor Commented:
(|(!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?

Shabarinath RamadasanInfrastructure ArchitectCommented:
Shabarinath RamadasanInfrastructure ArchitectCommented:
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.
DonYoungSr. Enterprise ArchitectAuthor Commented:
No I need employeeIDs starting with 1, 5, con- or temp- UNLESS the samAccountName starts with a 0 or a 1.
DonYoungSr. Enterprise ArchitectAuthor Commented:
OK I got it:


Thanks.  I shall split the points.
Shabarinath RamadasanInfrastructure ArchitectCommented:
Oh.. Got it..


Good luck
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now