-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathexample.js
46 lines (40 loc) · 1.03 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var express = require('express');
var session = require('express-session');
var LDAPStrategy = require('passport-ldap').Strategy;
// Windows LDAP
var ldapConfig = {
server: {
url: 'ldap://some.server.url.com:9999'
},
authMode: 0,
debug: false,
usernameField: 'username',
passwordField: 'password',
base: ['dc=ad','dc=sm','dc=else'],
search: {
filter: '(sAMAccountName=$uid$)',
scope: 'sub',
attributes: ['list','of','user','attributes','you','want','returned'],
sizeLimit: 1
},
searchAttributes: ['displayName']
};
module.exports = function(app,passport){
app.use(session({
secret: 'anawesomesecret'
}));
passport.use(new LDAPStrategy(
ldapConfig,
function(profile, done) {
return done(null, profile);
}
));
passport.serializeUser(function(user,done){
done(null,user);
});
passport.deserializeUser(function(user,done){
done(null,user);
});
app.use(passport.initialize());
app.use(passport.session());
};