GUACAMOLE-234: Clean up some LDAP implementation details.

This commit is contained in:
Nick Couchman
2018-12-09 09:48:01 -05:00
committed by Virtually Nick
parent 2f1fac51af
commit 5777d93fdc
3 changed files with 10 additions and 6 deletions

View File

@@ -134,13 +134,14 @@ public class ConnectionService {
// Get common name (CN) // Get common name (CN)
Attribute cn = entry.get("cn"); Attribute cn = entry.get("cn");
String cnName;
if (cn == null) { if (cn == null) {
logger.warn("guacConfigGroup is missing a cn."); logger.warn("guacConfigGroup is missing a cn.");
return null; return null;
} }
String cnName;
try { try {
cnName = cn.getString(); cnName = cn.getString();
} }
@@ -179,6 +180,7 @@ public class ConnectionService {
parameter = parameterAttribute.getString(); parameter = parameterAttribute.getString();
} }
catch (LdapInvalidAttributeValueException e) { catch (LdapInvalidAttributeValueException e) {
logger.warn("Parameter value not valid for {}", cnName, e);
return null; return null;
} }
parameterAttribute.remove(parameter); parameterAttribute.remove(parameter);
@@ -235,7 +237,7 @@ public class ConnectionService {
* An LDAP search filter which queries all guacConfigGroup objects * An LDAP search filter which queries all guacConfigGroup objects
* accessible by the user having the given DN. * accessible by the user having the given DN.
* *
* @throws LDAPException * @throws LdapException
* If an error occurs preventing retrieval of user groups. * If an error occurs preventing retrieval of user groups.
* *
* @throws GuacamoleException * @throws GuacamoleException

View File

@@ -50,7 +50,7 @@ public class UserGroupService {
/** /**
* Logger for this class. * Logger for this class.
*/ */
private final Logger logger = LoggerFactory.getLogger(UserGroupService.class); private static final Logger logger = LoggerFactory.getLogger(UserGroupService.class);
/** /**
* Service for retrieving LDAP server configuration information. * Service for retrieving LDAP server configuration information.

View File

@@ -29,6 +29,7 @@ import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.name.Rdn;
import org.apache.guacamole.auth.ldap.conf.ConfigurationService; import org.apache.guacamole.auth.ldap.conf.ConfigurationService;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleServerException; import org.apache.guacamole.GuacamoleServerException;
@@ -104,6 +105,7 @@ public class UserService {
return new SimpleUser(username); return new SimpleUser(username);
} }
catch (LdapInvalidAttributeValueException e) { catch (LdapInvalidAttributeValueException e) {
return null; return null;
} }
@@ -184,10 +186,10 @@ public class UserService {
// Derive user DN from base DN // Derive user DN from base DN
try { try {
return new Dn(usernameAttributes.get(0) + "=" + username return new Dn(new Rdn(usernameAttributes.get(0), username),
+ "," + confService.getUserBaseDN().toString()); confService.getUserBaseDN());
} }
catch (LdapInvalidDnException e) { catch (LdapInvalidAttributeValueException | LdapInvalidDnException e) {
throw new GuacamoleServerException("Error trying to derive user DN.", e); throw new GuacamoleServerException("Error trying to derive user DN.", e);
} }