-
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);
[JENKINS-6550] add flexiblity to LDAP search attribute, instead of just attribute=username, complete filter can be defined.
Issue Type | Original: Bug [ 1 ] | New: Improvement [ 4 ] |
Description |
Original:
LDAP Email Plugin requires the search attribute must be formatted to 'attribute=value'. I would like more attitude in 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); |
New:
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); |
Attachment | New: ldapemail.patch [ 19666 ] |
Workflow | Original: JNJira [ 136645 ] | New: JNJira + In-Review [ 174534 ] |
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.