easy-ldap-login
v0.1.8
Published
easy-ldap-login allows you to easily authenticate users on LDAP server and check if they are in a specific group
Downloads
14
Maintainers
Readme
easy-ldap-login
easy-ldap-login is a wrapper of ldapjs package that allows you to easily authenticate users on LDAP server and check if they are in a specific group.
Installation
npm i easy-ldap-login
Usage
const LDAPLogin = require( 'easy-ldap-login' );
const ldapLogin = new LDAPLogin( 'ldap://myldap01.server.com', 'dc=domain,dc=com', { searchGroups: 'team_marketing', userSearchAttributes: ['givenName'] } );
ldapLogin.auth( 'userName', 'password' )
.then( userAttrs => console.log( `Hello ${userAttrs.givenName}!` ) )
.catch( () => console.log( 'Wrong credentials' ) );
Methods
LDAPLogin.constructor
new LDAPLogin( serverUrls: String | Array, dcString: String [, options: Object = {} ] );
Parameters
serverUrls
Required - URL of the ldap server asString
or anArray
of URL Strings for round-robindcString
Required -String
that identifies Domain Componentoptions
Optional - Module options as anObject
with some properties:usersOu
Optional -String
that identifies Organization Unit base for Users (Default:'ou=users'
)userAttribute
Optional -String
that identifies ID attribute for Users (Default:'uid'
)groupsOu
Optional -String
that identifies Organization Unit base for Groups (Default:'ou=groups'
)groupMemberAttribute
Optional -String
that identifies Group attribute to use for searching its members (Default:'member'
)searchGroups
Optional - It can be one of these:String
that identifies Common Name of Group that User must haveObject
with properties:cn
Required -String
that identifies Common Name of the Group that User must haveou
Required -String
that identifies Organization Unit base string of the GroupuserAttribute
Optional -String
that identifies ID attribute for Users in the GroupgroupMemberAttribute
Optional -String
that identifies Group attribute to use for searching its members
Array
of the previous data for multiple groups
userSearchAttributes
Optional -Array
ofStrings
that indentify user attributes you want to retrievetlsOptions
Optional -Object
options passed to TLS connection layer when connecting vialdaps://
(See: TLS for node.js)caCertPath
Optional -String
path of CA Cert FilecertPath
Optional -String
path of Cert File
Return
An instance of LDAPLogin
LDAPLogin.auth
ldapLogin.auth( userName: String, password: String [, options: Object = {} ] );
Parameters
userName
Required - User's userNamepassword
Required - User's passwordoptions
Optional - Module options as anObject
with some properties:serverUrls
Optional - URL of the ldap server asString
or anArray
of URL Strings for multiple attemptsusersOu
Optional -String
that identifies Organization Unit base for Users (Default:'ou=users'
)userAttribute
Optional -String
that identifies ID attribute for Users (Default:'uid'
)groupsOu
Optional -String
that identifies Organization Unit base for Groups (Default:'ou=groups'
)groupMemberAttribute
Optional -String
that identifies Group attribute to use for searching its members (Default:'member'
)searchGroups
Optional - It can be one of these:String
that identifies Common Name of Group that User must haveObject
with properties:cn
Required -String
that identifies Common Name of the Group that User must haveou
Required -String
that identifies Organization Unit base string of the GroupuserAttribute
Optional -String
that identifies ID attribute for Users in the GroupgroupMemberAttribute
Optional -String
that identifies Group attribute to use for searching its members
Array
of the previous data for multiple groups
userSearchAttributes
Optional -Array
ofStrings
that indentify user attributes you want to retrievetlsOptions
Optional -Object
options passed to TLS connection layer when connecting vialdaps://
(See: TLS for node.js)caCertPath
Optional -String
path of CA Cert FilecertPath
Optional -String
path of Cert File
Return
A promise that resolve if user correctly logged or reject error