May 152011

I have recently come across a situation where I need to determine whether an account is locked or not.
Conveniently, the IADsUser interface provides a property that is exactly what I need !.
This little code block will return a true or false depending on whether the account is locked or not, with true representing a locked account.

var objUser = GetObject("LDAP://cn=user,ou=users,dc=example,dc=com");
var boolUsrLocked = objUser.isAccountLocked;
return boolUsrLocked;


  2 Responses to “Active Directory With JScript : How to Determine if an Account is Locked.”

  1. This code has a small typo.
    the object is created as objUsr (without e) and later referred to as objUser (with e)

    var objUsr = GetObject(“LDAP://cn=user,ou=users,dc=example,dc=com”);
    var boolUsrLocked = objUser.isAccountLocked;
    return boolUsrLocked;

    anyway, thanks for your site !.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



This site uses Akismet to reduce spam. Learn how your comment data is processed.