From db2dae88c1dde96e2e77a7c8041163a7f92edd22 Mon Sep 17 00:00:00 2001 From: "fbelzunc@gmail.com" Date: Fri, 16 Aug 2019 14:22:06 +0200 Subject: [PATCH] [JENKINS-56124] If fetching user by "userPrincipalName" launched an Exception, search for "sAMAccountName" will not be executed --- .../ActiveDirectoryUnixAuthenticationProvider.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/hudson/plugins/active_directory/ActiveDirectoryUnixAuthenticationProvider.java b/src/main/java/hudson/plugins/active_directory/ActiveDirectoryUnixAuthenticationProvider.java index c24bcf58..03049529 100755 --- a/src/main/java/hudson/plugins/active_directory/ActiveDirectoryUnixAuthenticationProvider.java +++ b/src/main/java/hudson/plugins/active_directory/ActiveDirectoryUnixAuthenticationProvider.java @@ -383,6 +383,11 @@ public UserDetails call() throws AuthenticationException, NamingException { final String domainDN = toDC(domain.getName()); Attributes user = new LDAPSearchBuilder(context, domainDN).subTreeScope().searchOne("(& (userPrincipalName={0})(objectCategory=user))", userPrincipalName); + try { + user = new LDAPSearchBuilder(context, domainDN).subTreeScope().searchOne("(& (userPrincipalName={0})(objectCategory=user))", userPrincipalName); + } catch (NamingException e) { + LOGGER.log(Level.FINE, "Failed to find {0} in userPrincipalName", userPrincipalName); + } if (user == null) { // failed to find it. Fall back to sAMAccountName. // see http://www.nabble.com/Re%3A-Hudson-AD-plug-in-td21428668.html