Skip to content

Instantly share code, notes, and snippets.

@whunter
Created May 15, 2018 18:43
Show Gist options
  • Save whunter/02bc567781b7e3d4c9928b330e8b26b5 to your computer and use it in GitHub Desktop.
Save whunter/02bc567781b7e3d4c9928b330e8b26b5 to your computer and use it in GitHub Desktop.
require 'net/ldap'
email = ARGV[0]
ldap = Net::LDAP.new(host: 'directory.vt.edu')
ldap.bind
treebase = 'ou=People,dc=vt,dc=edu'
ldap_attributes = {display_name: :displayname, department: :department}
filter = Net::LDAP::Filter.eq('mail', email)
results = ldap.search(base: treebase, filter: filter)
puts results[0].uid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment