Last active
June 20, 2019 05:13
-
-
Save knjname/0b62867d422ad186d6bea314aa2a2825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ldap = require("ldapjs"); | |
const server = ldap.createServer(); | |
server.bind("", (req, res, next) => { | |
console.log(`Bind attempt with ${req.dn.toString()}`); | |
res.end(); | |
return next(); | |
}); | |
server.search( | |
"", | |
(req, res, next) => { | |
console.log(`Bind attempt with ${req.dn.toString()}`); | |
return next(); | |
}, | |
(req, res, next) => { | |
console.log(`In the search with ${req.dn.toString()}`); | |
res.send({ | |
dn: `CN=user, OU=myorg`, | |
attributes: { | |
userPrincipalName: "userPrincipalName", | |
cn: "userCn", | |
objectClass: ["user"], | |
objectCategory: ["user"] | |
} | |
}); | |
res.send({ | |
dn: `CN=user2, OU=myorg`, | |
attributes: { | |
userPrincipalName: "userPrincipalName", | |
cn: "userCn", | |
objectClass: ["user"], | |
objectCategory: ["user"] | |
} | |
}); | |
res.end(); | |
return next(); | |
} | |
); | |
server.listen(1389, () => { | |
console.log(`LDAP started`); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"start": "nodemon ldapserver.js" | |
}, | |
"dependencies": { | |
"ldapjs": "^1.0.2" | |
}, | |
"devDependencies": { | |
"nodemon": "^1.19.1", | |
"prettier": "^1.18.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment