From ad2eedb6f6544549f26f058f248bc8e724b4b2ee Mon Sep 17 00:00:00 2001 From: mindless Date: Mon, 2 Feb 2009 19:36:23 +0000 Subject: [PATCH] [FIXED HUDSON-2959] Fix broken images by adding rootUrl in image links returned by checkName; avoid NullPointerException in LDAP groupname lookup when groupSearchBase is not set. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15006 71c3de6d-444a-0410-be80-ed276b4c234a Originally-Committed-As: f6e780339fe674a71cbf8e693b6a8fba01e90b52 --- core/src/main/java/hudson/security/LDAPSecurityRealm.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/security/LDAPSecurityRealm.java b/core/src/main/java/hudson/security/LDAPSecurityRealm.java index 2b60d3a..bf97f55 100644 --- a/core/src/main/java/hudson/security/LDAPSecurityRealm.java +++ b/core/src/main/java/hudson/security/LDAPSecurityRealm.java @@ -250,8 +250,8 @@ public class LDAPSecurityRealm extends SecurityRealm { if(Util.fixEmptyAndTrim(rootDN)==null) rootDN=Util.fixNull(inferRootDN(server)); this.rootDN = rootDN.trim(); this.userSearchBase = userSearchBase.trim(); - if(Util.fixEmptyAndTrim(userSearch)==null) userSearch="uid={0}"; - this.userSearch = userSearch.trim(); + userSearch = Util.fixEmptyAndTrim(userSearch); + this.userSearch = userSearch!=null ? userSearch : "uid={0}"; this.groupSearchBase = Util.fixEmptyAndTrim(groupSearchBase); this.managerDN = Util.fixEmpty(managerDN); this.managerPassword = Scrambler.scramble(Util.fixEmpty(managerPassword)); @@ -327,7 +327,8 @@ public class LDAPSecurityRealm extends SecurityRealm { @Override public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFoundException, DataAccessException { // TODO: obtain a DN instead so that we can obtain multiple attributes later - final Set groups = (Set)ldapTemplate.searchForSingleAttributeValues(groupSearchBase, GROUP_SEARCH, + String searchBase = groupSearchBase != null ? groupSearchBase : ""; + final Set groups = (Set)ldapTemplate.searchForSingleAttributeValues(searchBase, GROUP_SEARCH, new String[]{groupname}, "cn"); if(groups.isEmpty())