Howto handle locked users in AD
======================================

date:	07/13/2010
rev:	01

A user in Active directory got the attribute userAcountControl.

This difference between a normal user account and a locked user is the following:
-userAccountControl: 514
+userAccountControl: 512

This attribute holds many different flags.
Microsoft has an article on that:

http://support.microsoft.com/?scid=kb%3Ben-us%3B305144&x=15&y=14

You may do an ldap search in those bit fields like this:
http://www.selfadsi.de/ldap-filter.htm#BitAndOr

Users, that are locked, can be found like this:

ldapsearch -x -W -H ldap://172.16.200.61 -D
"cn=administrator,ou=linotp,dc=linotp-test,dc=local" -b
"ou=linotp,dc=linotp-test,dc=local" 
"(&(SAMAccountName=*)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2))"

Users, that are not locked, can be found like this:

 ldapsearch -x -W -H ldap://172.16.200.61 -D
"cn=administrator,ou=linotp,dc=linotp-test,dc=local" -b
"ou=linotp,dc=linotp-test,dc=local" 
'(&(SAMAccountName=*)(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))'

This search pattern can be used in the user filter of linotp, so that locked users will not be found for authenticating and thus will not be able to authenticate.
