Comments (1)
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:
- port: The port the server will listen to
- userLoginAttribute: The LDAP attribute holding the login of the user you want to authenticate. It must correspond to a user property in the users.json file below
- searchBase: The LDAP base you will interrogate with your LDAP client
- searchFilter: The search filter you will use to authenticate your user with your LDAP client with {{username}} the placeholder in the filter which will contain the user login
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:
- dn: A valid LDAP distinguished name for the user
- cn: The user login as we specified in server-conf.json that the cn property holds the user login
- attribute1 | attribute2 | and more : Any number of properties that will be returned as is when authenticating the 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
from ldap-server-mock.
Related Issues (14)
- Need help with some examples of searching a user HOT 3
- I want to authenticate user/pass for client
- throw new Error(`Invalid arguments: ${error.message}`); HOT 2
- Can we search by multiple criteria HOT 1
- Please add basic authentication support to LDAP mock server HOT 3
- Start programatically HOT 15
- Mock returns data that it should not when searching by dn
- Throws an error moments after listening on port 3004 HOT 4
- installation instructions HOT 1
- File path is relative to the executable directory instead of the directory node executes from... HOT 2
- Error: Invalid arguments: /data/ldap-server-mock-conf.json: Unexpected token / in JSON at position 18 HOT 3
- Add example command using common ldap client HOT 2
- Manipulate LDAP search filter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ldap-server-mock.