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

Need Active Directory custom search to find account that do not expire

I need to find which of my AD users are not expiring.
I found something that looks like it but doesn't work when cutting and pasting it in a custom search:

"(&(objectCategory=person)(objectClass=user)" _
    & "(|(accountExpires=9223372036854775807)(accountExpires=0)))"

I have also found this:
strFilter = "(&(objectCategory=person)(objectClass=user)" _
& "(userAccountControl:1.2.840.113556.1.4.803:=65536))"

But they don't work, can you tell me what is the EXACT semantic I can just cut and paste in the "Enter LDAP query"  field.
2 Solutions
Sorry I not sure I understand what you're after... do you want a list of accounts whose password is set never to expire?

If so, cut and paste this:


I tried this on my AD and it worked fine.  Make sure you check your Query Root is set correctly too to include the containers you want the search to apply to.
Mike KlineCommented:
Archonaus has the right query there
another really good tool for this is adfind by MVP Joe Richards
you can certainly use the longer LDAP filter in adfind but Joe also has some really nice shortcuts
adfind -sc users_noexpire samaccountname
That will dump users that have passwords set to never expire and output the samaccountname
some other useful and similar shortcuts

   -sc users_disabled      Dump disabled users.
   -sc users_noexpire      Dump non-expiring users.
   -sc users_accexpired    Dump accounts that are expired (NOT password expiration).
   -sc users_pwdnotreqd    Dump users set with password not required.
   -sc computers_disabled  Dump computers that are disabled.
   -sc computers_pwdnotreqd Dump computers set with password not required.
   -sc computers_active    Dump computers that are enabled and password last
SigSupportAuthor Commented:
With these answers I will get exactly what I need.
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

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.

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