LdapLookup for Ruby Gem Version

Description

This module is to be used for anonymous lookup of user attributes in the MCommunity service provide at the University of Michigan. It can be easily modifed to use other LDAP server configurations.


Try it out

Requirements:

  • Ruby at least 2.0.0
  • Gem 'net-ldap' ~> '0.17.0' > The Net::LDAP (aka net-ldap) gem before 0.16.0 for Ruby has a Missing SSL Certificate Validation.

To try the module out:

  1. Clone the repo
  2. Edit the configurations by opening ldaptest.rb and set the CONFIGURATION BLOCK to your environment.

    
    LdapLookup.configuration do |config|
      config.host = <em>< your host ></em> # "ldap.umich.edu"
      config.port = <em>< your port ></em> # "986" the default is set to "389" so this optional
      config.base = <em>< your LDAP base ></em> # "dc=umich,dc=edu"
      config.dept_attribute = <em>< your dept attribute ></em> # "umichPostalAddressData"
      config.group_attribute = <em>< your group email attribute ></em> # "umichGroupEmail"
    end
    
  3. run the ldaptest.rb script

    ruby ./ldaptest.rb
    

Installation

Add this line to your application's Gemfile:

gem 'ldap_lookup'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ldap_lookup

In your application create a file config/initializers/ldap_lookup.rb


LdapLookup.configuration do |config|
    config.host = <em>< your host ></em> # "ldap.umich.edu"
    config.port = <em>< your port ></em> # "954" port 389 is set by default
    config.base = <em>< your LDAP base ></em> # "dc=umich,dc=edu"
    config.dept_attribute = <em>< your dept attribute ></em> # "umichPostalAddressData"
    config.group_attribute = <em>< your group email attribute ></em> # "umichGroupEmail"
end

Methods available

uid_exist?: returns true if uid is in LDAP

LdapLookup.uid_exist?(uniqname)

get_simple_name: returns the Display Name

LdapLookup.get_simple_name(uniqname = nil)

get_dept: returns the users Department_name

LdapLookup.get_dept(uniqname = nil)

get_email: returns the users email address

LdapLookup.get_email(uniqname = nil)

is_member_of_group?: returns true/false if uniqname is a member of the specified group

LdapLookup.is_member_of_group?(uid = nil, group_name = nil)

get_email_distribution_list: Returns the list of emails that are associated to a group.

LdapLookup.get_email_distribution_list(group_name = nil)

all_groups_for_user: Returns the list of groups that a user is a member of.

LdapLookup.all_groups_for_user(uniqname = nil)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rsmoke/ldap_lookup. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the LdapLookup project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.