Skip to content

Improved multiple domain support #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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