LdapLookup for Ruby

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/ldap_lookup. To experiment with that code, run bin/console for an interactive prompt.

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.16.1' > Install by running the following command at your command prompt_for_action > The Net::LDAP (aka net-ldap) gem before 0.16.0 for Ruby has a Missing SSL Certificate Validation. bash gem install net-ldap

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 = < your host > # "ldap.umich.edu"
      config.base = < your LDAP base > # "dc=umich,dc=edu"
      config.dept_attribute = < your dept attribute > # "umichPostalAddressData"
      config.group_attribute = < your group email attribute > # "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 = < your host > # "ldap.umich.edu"
    config.port = < your port > # "954" port 389 is set by default
    config.base = < your LDAP base > # "dc=umich,dc=edu"
    config.dept_attribute = < your dept attribute > # "umichPostalAddressData"
    config.group_attribute = < your group email attribute > # "umichGroupEmail"
end

Methods available

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)

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.