Skip to content

Loading…

Multiple domains in Authentication tool #1

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 17 deletions.
  1. +19 −17 src/main/java/hudson/plugins/active_directory/ActiveDirectorySecurityRealm.java
View
36 src/main/java/hudson/plugins/active_directory/ActiveDirectorySecurityRealm.java
@@ -172,23 +172,25 @@ public void doAuthTest(StaplerRequest req, StaplerResponse rsp, @QueryParameter
ActiveDirectoryUnixAuthenticationProvider p = (ActiveDirectoryUnixAuthenticationProvider) uds;
DesciprotrImpl descriptor = getDescriptor();
- try {
- pw.println("Domain="+domain+" site="+site);
- List<SocketInfo> ldapServers = descriptor.obtainLDAPServer(domain, site, server);
- pw.println("List of domain controllers: "+ldapServers);
-
- for (SocketInfo ldapServer : ldapServers) {
- pw.println("Trying a domain controller at "+ldapServer);
- try {
- UserDetails d = p.retrieveUser(username, password, domain, Collections.singletonList(ldapServer));
- pw.println("Authenticated as "+d);
- } catch (AuthenticationException e) {
- e.printStackTrace(pw);
- }
- }
- } catch (NamingException e) {
- pw.println("Failing to resolve domain controllers");
- e.printStackTrace(pw);
+ for (String domainName : domain.split(",")) {
+ try {
+ pw.println("Domain="+domainName+" site="+site);
+ List<SocketInfo> ldapServers = descriptor.obtainLDAPServer(domainName, site, server);
+ pw.println("List of domain controllers: "+ldapServers);
+
+ for (SocketInfo ldapServer : ldapServers) {
+ pw.println("Trying a domain controller at "+ldapServer);
+ try {
+ UserDetails d = p.retrieveUser(username, password, domainName, Collections.singletonList(ldapServer));
+ pw.println("Authenticated as "+d);
+ } catch (AuthenticationException e) {
+ e.printStackTrace(pw);
+ }
+ }
+ } catch (NamingException e) {
+ pw.println("Failing to resolve domain controllers");
+ e.printStackTrace(pw);
+ }
}
} else {
pw.println("Using Windows ADSI. No diagnostics available.");
Something went wrong with that request. Please try again.