Re: Active Directory Query for Enabled Users

Tech-Archive recommends: Fix windows errors by optimizing your registry



All one line

adfind -b OU_DN -bit -dn -f "&(objectcategory=person)(objectclass=user)(!(useraccountcontrol:AND:=2))"

Note that since this uses a NOT query (only way to do it) it is possible you can get false positives in the event that you don't have access to read the userAccountControl value. If that occurs you can use this longer but more accurate filter

"&(objectcategory=person)(objectclass=user)(useraccountcontrol=*)(!(useraccountcontrol:AND:=2))"

That will only return values that you have the permission to read the useraccountcontrol and the useraccountcontrol doesn't have the disabled bit set.

joe

--
Joe Richards Microsoft MVP Windows Server Directory Services
Author of O'Reilly Active Directory Third Edition
www.joeware.net


---O'Reilly Active Directory Third Edition now available---

http://www.joeware.net/win/ad3e.htm


jdh201 wrote:
This seems kind of simple considering that finding the disabled users requires a check box to be turned on, but I need the oposite. I need a way to list all of the users in and OU that are enabled. I may be missing something really simple, but could someone please help me?
.



Relevant Pages

  • Re: How to expire passwd in active directory?
    ... In AD using LDAP mechanisms to display useraccountcontrol it won't. ... Joe Richards Microsoft MVP Windows Server Directory Services ... Himanshu wrote:> Joe, ...
    (microsoft.public.win2000.active_directory)
  • Re: AD Delagation
    ... The enable/disable setting is one flag of userAccountControl. ... Once you delegate it, there are other things the person can do, not just enable/disable. ... Joe Richards Microsoft MVP Windows Server Directory Services ...
    (microsoft.public.windows.server.active_directory)