1

UnboundID LDAP Java SDK を使用して、Groovy/Grails アプリケーションを Active Directory に接続しています。私が使用している接続オプションは次のとおりです。

  LDAPConnectionOptions options = new LDAPConnectionOptions()
  options.connectTimeoutMillis = 60000 // 1 minute
  options.followReferrals = true
  options.referralHopLimit = 10
  options.responseTimeoutMillis = 60000 // 1 minute
  options.useSynchronousMode = true

ただし、結果コード 10 の LDAPSearchExceptions が引き続き発生します。これは、サーバーが紹介を送信したことを意味します。referralHopLimit をより高い数値に変更しても役に立たないため、ライブラリが紹介に従っていないことは明らかです。

これまでのところ、LDAPConnection.getEntry メソッドを使用して DN で指定された特定のエントリをロードする場合にのみ、この問題が発生するようです。検索してもまだ届いていません。したがって、getEntry メソッドが紹介に従うべきではないのではないかと考えています。その場合、手動で紹介をフォローしたり、その動作を変更したりするための最良の方法は何ですか?

4

1 に答える 1

2

getEntry メソッドは裏で検索を使用するため、検索が機能する場合は getEntry も機能するはずです。簡単なテストを実行したところ、うまくいきました。最新の LDAP SDK リリース (2.3.6) と次のコードを使用すると、参照に従って、予想されるエントリを取得できます。「opts.setFollowReferrals(true)」行をコメントアウトすると、参照例外が発生します。

import com.unboundid.ldap.listener.*;
import com.unboundid.ldap.sdk.*;



public class ReferralTest
{
  public static void main(final String... args)
         throws Exception
  {
    final InMemoryDirectoryServerConfig cfg =
         new InMemoryDirectoryServerConfig("dc=example,dc=com");
    final InMemoryDirectoryServer ds1 = new InMemoryDirectoryServer(cfg);
    final InMemoryDirectoryServer ds2 = new InMemoryDirectoryServer(cfg);

    ds1.startListening();
    ds2.startListening();

    final LDAPConnectionOptions opts = new LDAPConnectionOptions();
    opts.setFollowReferrals(true);

    final LDAPConnection conn1 = ds1.getConnection(opts);
    final LDAPConnection conn2 = ds2.getConnection(opts);

    conn1.add(
         "dn: dc=example,dc=com",
         "objectClass: top",
         "objectClass: domain",
         "dc: example");
    conn1.add(
         "dn: ou=Referral Entry,dc=example,dc=com",
         "objectClass: top",
         "objectClass: organizationalUnit",
         "ou: Referral Entry",
         "description: This is a referral entry");

    conn2.add(
         "dn: dc=example,dc=com",
         "objectClass: top",
         "objectClass: domain",
         "dc: example");
    conn2.add(
         "dn: ou=Referral Entry,dc=example,dc=com",
         "objectClass: top",
         "objectClass: referral",
         "objectClass: extensibleObject",
         "ou: Referral Entry",
         "ref: ldap://127.0.0.1:" + ds1.getListenPort() +
              "/ou=Referral Entry,dc=example,dc=com");

    final Entry e = conn2.getEntry("ou=Referral Entry,dc=example,dc=com");
    System.out.println(e.toLDIFString());

    conn1.close();
    conn2.close();

    ds1.shutDown(true);
    ds2.shutDown(true);
  }
}
于 2014-06-09T20:52:51.937 に答える