Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
Expand Down Expand Up @@ -550,6 +551,10 @@ public List<SocketInfo> obtainLDAPServer(String domainName, String site, String
// see http://technet.microsoft.com/en-us/library/cc759550(WS.10).aspx
private static final List<String> CANDIDATES = Arrays.asList("_gc._tcp.", "_ldap._tcp.");

private boolean serverIsInDomain(String serverToken, String domainName) {
return serverToken.split(":")[0].endsWith(domainName);
}

/**
* Use DNS and obtains the LDAP servers that we should try.
*
Expand All @@ -570,7 +575,8 @@ public List<SocketInfo> obtainLDAPServer(DirContext ictx, String domainName, Str

if (preferredServers!=null) {
for (String token : preferredServers.split(",")) {
result.add(new SocketInfo(token.trim()));
if (serverIsInDomain(token, domainName))
result.add(new SocketInfo(token.trim()));
}
return result;
}
Expand Down