4

JNDIを使用してLDAPサーバーにエントリを追加しようとしています。LDAPサーバーからエントリを正常に読み取ることができました。しかし、新しいエントリを追加しようとすると、エラーが発生します。いろいろチェックしましたが失敗しました。

    private String getUserAttribs (String searchAttribValue) throws NamingException{
    SearchControls ctls = new SearchControls();
    ctls.setSearchScope(SearchControls.OBJECT_SCOPE);

    Attributes matchAttrs = new BasicAttributes(true);
    matchAttrs.put(new BasicAttribute("uid", searchAttribValue));
    NamingEnumeration answer = ctx.search("ou=People,ou=ABCLdapRealm,dc=abcdomain",matchAttrs);

    SearchResult item =(SearchResult) answer.next();
    // uid userpassword description objectclass wlsmemberof sn cn
    return item.toString();
}

これは正しく機能しました。

次に、一歩前進して、エントリを追加しようとしました。コードは次のとおりです。

    public static void bindEntry(DirContext dirContext)throws Exception{
    Attributes matchAttrs = new BasicAttributes(true);
    // uid userpassword description objectclass wlsmemberof sn cn
    matchAttrs.put(new BasicAttribute("uid", "defaultuser"));
    matchAttrs.put(new BasicAttribute("userpassword", "password"));
    matchAttrs.put(new BasicAttribute("description", "defaultuser"));
    matchAttrs.put(new BasicAttribute("cn", "defaultuser"));
    matchAttrs.put(new BasicAttribute("sn", "defaultuser"));

    matchAttrs.put(new BasicAttribute("objectclass", "top"));
    matchAttrs.put(new BasicAttribute("objectclass", "person"));
    matchAttrs.put(new BasicAttribute("objectclass", "organizationalPerson"));
    matchAttrs.put(new BasicAttribute("objectclass","inetorgperson"));
    matchAttrs.put(new BasicAttribute("objectclass", "wlsUser"));
    String name="uid=defaultuser";
    InitialDirContext iniDirContext = (InitialDirContext)dirContext;
    iniDirContext.bind(name,dirContext,matchAttrs);
}

しかし、これで私は例外を取得しています。

Exception in thread "main" javax.naming.OperationNotSupportedException: [LDAP: error code 53 - Unwilling To Perform]; remaining name 'uid=defaultuser'

間違いなく私は何かに違反しています。これについて何か考えはありますか?

4

3 に答える 3

4

LDAP 53、不本意な実行は、通常、それが言うことを意味します。LDAP サーバーの観点から「違法」なことをしようとしました。

最初の推測ではありそうにありませんが、eDirectory を指しているのですか? その場合、eDirectory のスキーマでは、作成時に姓の値を提供することが必須であるため、sn を追加することが重要です。その場合、おそらく 608 または 611 エラーのようなわずかに異なるエラーが発生します。

第二に、あなたは Active Directory を指しています。この場合、fullName は必須属性です。ただし、その場合、通常はわずかに異なる結果コードも得られます。エラーにはもっとあるはずです。(ただし、これは私が使用しているツールに対する JNDI のリターンかもしれません)。

3 番目の推測では、他の誰かの LDAP サーバーを指していて、スキーマに必須の属性がありません。

実際、オブジェクト クラスの問題である可能性があります。wlsUser は補助クラスですか、それとも実際のクラスですか? ディレクトリ内の inetorgperson は実際のクラスですか (このタイプのクラスの名前は伏せていますが、補助クラス、構造クラス、その他のクラスがあります)。

私の基本的な推測では、必須属性を見逃していて、ターゲット ディレクトリのスキーマに違反している可能性があります。上記の必須属性が欠落している可能性のある例が役立つことを願っています。

于 2009-07-02T11:42:05.943 に答える
2

こんにちは、以下のコードを使用して、jndiプログラムからldapに人を挿入することができます

Attributes attributes=new BasicAttributes();
Attribute objectClass=new BasicAttribute("objectClass");
objectClass.add("inetOrgPerson");
attributes.put(objectClass);

Attribute sn=new BasicAttribute("sn");
Attribute cn=new BasicAttribute("cn");

sn.add("sahul");
cn.add("vetcha");

attributes.put(sn);
attributes.put(cn);
attributes.put("title","software engg")
ctx.createSubcontext("uid=sahul,ou=some organization7,o=some company7,ou=system",attributes);
于 2009-08-20T09:51:34.327 に答える
2

これは、非 SSL 接続を介して Active Directory でパスワードを設定しようとしたときに発生するエラーです。パスワード行なしでコードを再試行してください。

于 2009-07-02T13:47:03.397 に答える