Project

ons-ldap

0.0
No commit activity in last 3 years
No release in over 3 years
Simple class for authenticating against an LDAP directory.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.11, ~> 0
 Project Readme

ONS LDAP RubyGem

Thin wrapper around the net-ldap RubyGem. Contains a simple LDAPConnection class that can be used to authenticate against an LDAP directory.

Installation

gem install ons-ldap

Example

require 'ons-ldap'

host = 'localhost '        # LDAP server host
port = '636'               # LDAP server port (LDAPS)
base = 'dc=example,dc=com' # LDAP tree base

# Hash of LDAP group names.
groups = { admins: 'admins', users: 'users' }

ldap_connection = LDAPConnection.new(host, port, base, groups, logger)
user_entry      = ldap_connection.authenticate('johntopley', 'password')

user_entry.user_id      #=> 'johntopley'
user_entry.display_name #=> 'John Topley'
user_entry.token        # 2FA token, stored in LDAP's employeeNumber field for expediency
user_entry.groups       #=> ['admins', 'users']

Testing

rake test

Copyright

Copyright (C) 2016 Crown Copyright (Office for National Statistics)