-
Improvement
-
Resolution: Unresolved
-
Major
-
None
LDAP Email Plugin requires the search attribute must be formatted to 'attribute=value'.
I would like more options for selection of LDAP search attribute.
Example search attribute : (&(ID=%s)(cn=prefix*))
The 'LdapMailAddressResolver' requires one simple change to support this. Instead of "search attribute" being the attribute, it is an LDAP filter with %s entered for where userName is to be inserted.
private String performSearch(DirContext ctx, String userName) throws NamingException {
String emailAddress = null;
SearchControls controls = new SearchControls();
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
//String filter = String.format("%s=%s", configuration.getSearchAttribute(), userName);
String filter = String.format(configuration.getSearchAttribute(), userName);
I agree this is a much more flexible method of performing the search but I suggest changing the filter to a replaceAll so that we can use multiple matches of userName.
We would like to use a search attribute like (|(cn=%s)(uid=%s)), where the userName could match the cn or the uid.
I have attached a patch file to make this change.