code: private boolean validateCredentials() {
          LOGGER.debug("Validating credentials for: " + username);
          final LdapConnectionWrapper ldap = new LdapConnectionWrapper();
          DirContext dirContext = null;
          LdapContext ldapContext = null;
          try (AlpineQueryManager qm = new AlpineQueryManager()) {
              final LdapUser ldapUser = qm.getLdapUser(username);
              if (ldapUser != null && ldapUser.getDN() != null && ldapUser.getDN().contains("=")) {
                  ldapContext = ldap.createLdapContext(ldapUser.getDN(), password);
                  LOGGER.debug("The supplied credentials are valid for: " + username);
                  return true;
              } else {
                  dirContext = ldap.createDirContext();
                  final SearchResult result = ldap.searchForSingleUsername(dirContext, username);
                  if (result != null ) {
                      ldapContext = ldap.createLdapContext(result.getNameInNamespace(), password);
                      LOGGER.debug("The supplied credentials are invalid for: " + username);
                      return true;
                  }
              }
          } catch (NamingException e) {
              LOGGER.debug("An error occurred while attempting to validate credentials", e);
          } finally {
              ldap.closeQuietly(ldapContext);
              ldap.closeQuietly(dirContext);
          }
          return false;
      }
docs: Asserts a users credentials. Returns a boolean value indicating if
  assertion was successful or not.
  
  @return true if assertion was successful, false if not
  @since 1.0.0