title: Check account locked status when authenticating with active directory using LDAP
body: <p>I have the following Java code to authenticate to Active Directory via the LDAP method. If authentication fails, an AuthenticationException is thrown. Is it possible to determine whether the authentication failure is due to the user account being locked?</p>
  
  <pre><code>try {
      Hashtable&lt;String, Object&gt; env = new Hashtable&lt;String, Object&gt;();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
      env.put(Context.PROVIDER_URL, url);
      env.put(Context.SECURITY_AUTHENTICATION, "simple");
      env.put(Context.SECURITY_PRINCIPAL, userName);
      env.put(Context.SECURITY_CREDENTIALS, password);
      new InitialDirContext(env);
      return true;
  } catch (AuthenticationException authenticationException) {
      authenticationException.printStackTrace();
      return false;
  } catch (Exception exception) {
      exception.printStackTrace();
      throw exception;
  }
  </code></pre>
  
  <p>Thanks in advance.</p>