Alex
Alex

Reputation: 809

Concatenate givenName and sn attribute as display name in Jenkins LDAP plugin

I finally managed to get a connection to my company's Active Directory via Jenkins LDAP plugin. While everything's working fine I recognized that displayed names of logged in users are not as expected.

I configured field Display Name LDAP attribute in Jenkins security configuration as displayName. But my company decided to append it's name to every displayNameattribute in AD. I want to get rid of it because using internal Jenkins we know where we're working at :)

My idea was to simply read display name from another AD attribute but there's none which contains exactly forename followed by surname. Question is: is there a way to concatenate two or more AD attributes in Jenkins LDAP plugin?

I want to have "Forename Surname" and I got following AD attributes I can choose from:

Speaking in Java syntax I simply want givenName + " " + sn. Is there a way to do so in Jenkins LDAP plugin?

Upvotes: 1

Views: 2262

Answers (1)

Gabriel Luci
Gabriel Luci

Reputation: 40998

Looking at the source code of the Jenkins LDAP plugin, it does not look like it allows concatenation. What you provide as the display name attribute must match the name of one attribute exactly.

These are the lines I'm referring to (starting at line 729):

Attribute attribute = d.getAttributes().get(getDisplayNameAttributeName());
String displayName = attribute == null ? null : (String) attribute.get();
if (StringUtils.isNotBlank(displayName) && u.getId().equals(u.getFullName()) && !u.getFullName().equals(displayName)) {
    u.setFullName(displayName);
}

Upvotes: 4

Related Questions