[英]UnboundID LDAP SDK not following Referrals
我正在使用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方法遵循引用,如果是這種情況,手動遵循引用或更改其行為的最佳方法是什么?
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);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.