Closed irulvam closed 5 years ago
Hi @irulvam.
This project aims to replace an LDAP server for authentication purpose when executing tests. Actually it can't be used for more complex search requests.
Here is a complete functional example to configure the LDAP server mock and interrogate it to authenticate a user.
First create a file containing the LDAP server mock configuration:
server-conf.json:
{
"port": 3004,
"userLoginAttribute": "cn",
"searchBase": "dc=test",
"searchFilter": "(&(objectclass=person)(cn={{username}}))"
}
With:
Then create a file containing the users you want to have inside your LDAP server:
users.json:
[
{
"dn": "cn=user1,dc=test",
"cn": "user1-login",
"attribute1": "value1",
"attribute2": "value2"
},
{
"dn": "cn=user2,dc=test",
"cn": "user2-login",
"attribute1": "value3",
"attribute2": "value4"
}
]
With for each user:
You can now launch your LDAP server using:
node node_modules/ldap-server-mock/server.js --conf="/path/to/the/server-conf.json" --database="path/to/the/users.json"
Now that your server is running on port 3004 and listens to the search base "dc=test" you can authenticate your user with your client. The following example, with the ldapsearch command, authenticates the user with login user1-login:
ldapsearch -x -H ldap://127.0.0.1:3004 -b dc=test '(&(objectclass=person)(cn=user1-login))'
dn: cn=user1, dc=test cn: user1-login attribute1: value1 attribute2: value
hi, this is awesome. but i don't understand how to setting of 2 json file. can you explain more example for me?
thanks