Github user necouchman commented on a diff in the pull request:
https://github.com/apache/guacamole-client/pull/299#discussion_r194409880
--- Diff:
extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java
---
@@ -236,6 +253,58 @@ public AuthenticatedUser authenticateUser(Credentials
credentials)
}
+ /**
+ * Returns all custom LDAP attributes on the user currently bound under
+ * the given LDAP connection. The custom attributes are specified in
+ * guacamole.properties.
+ *
+ * @param ldapConnection
+ * LDAP connection to find the custom LDAP attributes.
+ * @param username
+ * The username of the user whose attributes are queried.
+ *
+ * @return
+ * All attributes on the user currently bound under the
+ * given LDAP connection, as a map of attribute name to
+ * corresponding attribute value.
+ *
+ * @throws LDAPException
+ * If an error occurs while searching for the user attributes.
+ *
+ * @throws GuacamoleException
+ * If an error occurs retrieving the user DN.
+ */
+ private Map<String, String> getLDAPAttributes(LDAPConnection
ldapConnection,
+ String username) throws LDAPException, GuacamoleException {
+
+ // Get attributes from configuration information
+ List<String> attrList = confService.getAttributes();
+
+ // If there are no attributes there is no reason to search LDAP
+ if (attrList.size() == 0)
+ return null;
+
+ // Build LDAP query parameters
+ String[] attrArray = attrList.toArray(new String[attrList.size()]);
+ String userDN = getUserBindDN(username);
+
+ // Get LDAP attributes by querying LDAP
+ LDAPEntry userEntry = ldapConnection.read(userDN, attrArray);
+ LDAPAttributeSet attrSet = userEntry.getAttributeSet();
+
+ // Add each attribute into Map
+ Map<String, String> attrMap = new HashMap<String, String>();
+ Iterator attrIterator = attrSet.iterator();
+ while (attrIterator.hasNext()) {
--- End diff --
Oh, I see what you mean - yeah, that could be a problem, as those custom
classes (particularly ancient ones like the JLDAP ones :smile:) don't always
plan nice with the for-each loop.
---