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:

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.




LVL 2
DonYoungSr. Enterprise ArchitectAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Mike KlineConnect With a Mentor Commented:
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
 
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
0
 
DonYoungSr. Enterprise ArchitectAuthor Commented:
dsquery is not what I need.  This needs to be an LDAP Query (for use in an application)
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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?

(&(!(samaccountname=0*))(!(samaccountname=1*))(|(employeeID=1*)(|(employeeID=5*)(|(employeeID=Temp*)(|(employeeID=Con-*))))))
0
 
Shabarinath RamadasanConnect With a Mentor Infrastructure ArchitectCommented:
(&(objectcategory=user)(|(samaccountname=1*)(samaccountname=5*)(samaccountname=con*)(samaccountname=temp*)(!samaccountname=0*)))
0
 
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.
Thanks
Shaba
0
 
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.
0
 
DonYoungSr. Enterprise ArchitectAuthor Commented:
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
 
Shabarinath RamadasanInfrastructure ArchitectCommented:
Oh.. Got it..

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

Good luck
0
All Courses

From novice to tech pro — start learning today.