2

LDAP エラー コード 19 (パスワード ポリシー エラー) の原因をインスタンスで特定しようとしているInvalidAttributeValueExceptionので、UI に有益なエラー メッセージを表示できます。

私が現在使用している LDAP サービスは openLDAP (アプリケーションに組み込まれた LDAP として) であり、表示するのに十分な情報を提供するメッセージ (つまり"[LDAP: error code 19 - Password fails quality checking policy]"& "[LDAP: error code 19 - Password is in history of old passwords]")を提供します。

しかし今、私はActive Directoryと他のLDAPプロバイダー(外部になる)をサポートしたいと思っています.rfc2251や他のさまざまなソースで見たものから-すべての実装は独自の例外メッセージを出し、唯一の標準的なものはエラーコード19です.InvalidAttributeValueException 特定の問題へのマッピングとそうでないマッピング。

エラー コード 19 のさまざまな原因を区別するための解決策 (部分的なものであっても) はありますか? InvalidAttributeValueExceptionインスタンスを指定して、その質問に対する回答を LDAP に照会する方法はありますか?

ありがとう

4

2 に答える 2

2

上記の私のコメントは一般的な LDAP API に適用されますが、重要なことを忘れていました。https://datatracker.ietf.org/doc/html/draft-behera-ldap-password-policy-10で指定されているリクエストとレスポンスの制御を調査する必要があります。これは OpenLDAP で機能しますが、Active Directory でサポートされているかどうかはわかりません。私はそれをサポートする Java JNDI コードを持っています。PasswordPolicyResponseControl は次を返すことができます。

/** Warning codes. */
public enum Warning
{
    /** Password expiration warning.*/
    timeBeforeExpiration,
    /** Grace logins warning.*/
    graceAuthNsRemaining,
    none;
}

/** Error codes. */
public enum Error
{
    /** The password has expired.*/
    passwordExpired,
    /**
     * The account has been locked, either by an administrator
     * or as a result of too many failed login attempts.
     */
    accountLocked,
    /**
     * The password has been reset by an administrator and must be changed immediately.
     */
    changeAfterReset,
    /**
     * The password policy does not permit the user to change his password.
     */
    passwordModNotAllowed,
    /**
     * The password policy requires the old password to be supplied
     * when changing passwords.
     * This indicates a programming error in the client.
     */
    mustSupplyOldPassword,
    /**
     * The new password has failed the quality check.
     */
    insufficientPasswordQuality,
    /**
     * The new password is too short.
     */
    passwordTooShort,
    /**
     * The current password is too new to change yet.
     */
    passwordTooYoung,
    /**
     * The password policy specifies keeping a password history
     * and the new password is already in it.
     */
    passwordInHistory,
    /**
     * Error parsing the response control.
     * This indicates a programming error either in this
     * class or in the LDAP server.
     */
    unparseableResponseControl,
    /**
     * No additional information.
     * This can be seen e.g. when the user simply logs
     * in with the wrong password.
     */
    none;
};
于 2012-02-28T00:17:11.267 に答える
0

特定の例外の仕様を見ると、次のことがわかります。

  • 実装によって異なる原因は、コンストラクターのバリアントに示されています

InvalidAttributeValueException(String explanation)

  • それを呼び出すメソッドがあります:

exception.getExplanation()

これは、コンストラクターで入れられた値を提供します。

コンストラクターは値を列挙型ではなく文字列として受け取るため、さまざまなソリューションをコーディングするときに、各コーダーがこの値に設定した値のリストを取得しようとするのは不可能な場合があります。だから、あなたが知ったように、誰もが自分が適切だと思うものを書いています。

スペック上はそう言えます。

于 2012-02-25T16:40:01.753 に答える