GithubHelp home page GithubHelp logo

file json about ldap-server-mock HOT 1 CLOSED

veo-labs avatar veo-labs commented on June 25, 2024
file json

from ldap-server-mock.

Comments (1)

maxime-beguin avatar maxime-beguin commented on June 25, 2024 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
  • attribute1attribute2 | 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.