Skip to content

Commit 5361a97

Browse files
authored
Merge pull request #770 from SISheogorath/fix/ldapUUID
Add check for undefined UUID
2 parents f6df2de + 638eae0 commit 5361a97

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/web/auth/ldap/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ passport.use(new LDAPStrategy({
2323
tlsOptions: config.ldap.tlsOptions || null
2424
}
2525
}, function (user, done) {
26-
var uuid = user.uidNumber || user.uid || user.sAMAccountName
26+
var uuid = user.uidNumber || user.uid || user.sAMAccountName || undefined
2727
if (config.ldap.useridField && user[config.ldap.useridField]) {
2828
uuid = user[config.ldap.useridField]
2929
}
3030

31+
if (typeof uuid === 'undefined') {
32+
throw new Error('Could not determine UUID for LDAP user. Check that ' +
33+
'either uidNumber, uid or sAMAccountName is set in your LDAP directory ' +
34+
'or use another unique attribute and configure it using the ' +
35+
'"useridField" option in ldap settings.')
36+
}
37+
3138
var username = uuid
3239
if (config.ldap.usernameField && user[config.ldap.usernameField]) {
3340
username = user[config.ldap.usernameField]

0 commit comments

Comments
 (0)