[bugfix] Fix LDAP issue with OpenLDAP/MS AD
This commit is contained in:
parent
5332c81739
commit
2e5def404f
3 changed files with 9 additions and 5 deletions
|
@ -112,6 +112,8 @@ host="localhost"
|
|||
port=3002
|
||||
baseDN="ou=users,dc=company"
|
||||
filter="(|(username={{username}})(mail={{username}}))"
|
||||
#Username field in LDAP (uid/cn/username)
|
||||
uidTag="username"
|
||||
passwordresetlink=""
|
||||
|
||||
[postfixbounce]
|
||||
|
|
|
@ -80,27 +80,28 @@ if (config.ldap.enabled && LdapStrategy) {
|
|||
base: config.ldap.baseDN,
|
||||
search: {
|
||||
filter: config.ldap.filter,
|
||||
attributes: ['username', 'mail'],
|
||||
attributes: [config.ldap.uidTag, 'mail'],
|
||||
scope: 'sub'
|
||||
}
|
||||
},
|
||||
uidTag: config.ldap.uidTag
|
||||
};
|
||||
|
||||
passport.use(new LdapStrategy(opts, (profile, done) => {
|
||||
users.findByUsername(profile.username, (err, user) => {
|
||||
users.findByUsername(profile[config.ldap.uidTag], (err, user) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
// password is empty for ldap
|
||||
users.add(profile.username, '', profile.mail, (err, id) => {
|
||||
users.add(profile[config.ldap.uidTag], '', profile.mail, (err, id) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
return done(null, {
|
||||
id,
|
||||
username: profile.username
|
||||
username: profile[config.ldap.uidTag]
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
"npmlog": "^4.0.2",
|
||||
"openpgp": "^2.4.0",
|
||||
"passport": "^0.3.2",
|
||||
"passport-ldapjs": "^1.0.2",
|
||||
"passport-local": "^1.0.0",
|
||||
"premailer-api": "^1.0.4",
|
||||
"redfour": "^1.0.0",
|
||||
|
|
Loading…
Reference in a new issue