def valid_credentials?(kind, *credentials)
      return :unsupported unless kind == :user

      username, password = credentials
      return nil unless password && !password.strip.empty?

      with_ldap do |ldap|
        result = find_by_criteria(ldap, :username => username)
        if result.size == 1
          return ldap.authentic?(one_value(result[0], :dn), password) ? create_user(result[0]) : nil
        else
          return nil
        end
      end
    end
def valid_credentials?(kind, *credentials)
      return :unsupported unless kind == :user

      username, password = credentials
      return nil unless password && !password.strip.empty?

      with_ldap do |ldap|
        result = find_by_criteria(ldap, :username => username)
        if result.size == 1
          return ldap.authentic?(one_value(result[0], :dn), password) ? create_user(result[0]) : nil
        else
          return nil
        end
      end
    end
Verifies a username and password using the configured NU LDAP
 server.  Only supports the `:user` credential kind.  There must
 be exactly two credentials.

 @return [User, nil, :unsupported] a complete user record
   if the credentials are valid, `nil` if they aren't valid, and
   `:unsupported` if the first parameter is anything other than
   `:user`