# ldapAuth
LDAP Authentication bridge

This will start a LDAP Server witch can be used to auth against and bridge the auth to where ever you want (TextFile, Database, SMTP Auth...)

# HowTo Server
Starting the Server is simple:
1. Clone this repo
2. run `npm i`
3. spin up the sample server.js
```
var ldapAuth = require('./ldapAuth');

ldapAuth.init({
  serverPort : 389, //Default 389
	ldapServerPassword : "asdg", //Change password here
	warningCallback : function(warning) {
		console.log("warning",warning);
	},
	errorCallback : function(error) {
		console.log("error",error);
	},
	checkPassword : function(auth, isPasswordCorrectCallback) {
		var userName = auth["userName"];
		var userPassword = auth["userPassword"];

		if(userName=="test" && userPassword=="test") { //Test user+pw combination here
			isPasswordCorrectCallback(true);
		} else {
			isPasswordCorrectCallback(false);
		}
	}
});
```

# HowTo Client
Change to this settings at your LDAP Client
* HOST: IP of the Server you set this up
* PORT: Change to the port you defined (389 default)
* DN Bind: `cn=auth`
* DN Password: Change to your ldapServerPassword
* Base for user filter: `ou=users`
* User filter: `(&(uid=%s))`
* Username attribute: `username`
* Mail attribute: `mail`