Thin wrapper around the net-ldap RubyGem. Contains a simple LDAPConnection class that can be used to authenticate against an LDAP directory.
gem install ons-ldap 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']rake test Copyright (C) 2016 Crown Copyright (Office for National Statistics)