Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

ONSdigital/ldap-rubygem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

RubyGem for authenticating against an LDAP directory.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages