From 612b2d181145597257c082aa24456112bcc2aee3 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Sat, 9 Dec 2017 11:17:06 +0100 Subject: Add setting `ldap.usernameField` This determines which ldap field is used as the username on HackMD. By default, the "id" is used as username, too. The id is taken from the fields `uidNumber`, `uid` or `sAMAccountName`. To give the user more flexibility, they can now choose the field used for the username instead. --- lib/web/auth/ldap/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/web/auth/ldap/index.js') diff --git a/lib/web/auth/ldap/index.js b/lib/web/auth/ldap/index.js index 9a63578a..cc0d29ad 100644 --- a/lib/web/auth/ldap/index.js +++ b/lib/web/auth/ldap/index.js @@ -24,9 +24,15 @@ passport.use(new LDAPStrategy({ } }, function (user, done) { var uuid = user.uidNumber || user.uid || user.sAMAccountName + var username = uuid + + if (config.ldap.usernameField && user[config.ldap.usernameField]) { + username = user[config.ldap.usernameField] + } + var profile = { id: 'LDAP-' + uuid, - username: uuid, + username: username, displayName: user.displayName, emails: user.mail ? [user.mail] : [], avatarUrl: null, -- cgit v1.2.3