Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2010 18:05
Show Gist options
  • Save anonymous/647448 to your computer and use it in GitHub Desktop.
Save anonymous/647448 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'net/ldap'
ldap = Net::LDAP.new
ldap.host = "ldap2.int-evry.fr"
ldap.port = 389
if ldap.bind
treebase = "ou=People,dc=int-evry,dc=fr"
filter = Net::LDAP::Filter.pres("uid") & Net::LDAP::Filter.eq("title", "CL_FE-EM1EM")
attrs = ["uid", "mail", "ou", "cn", "dn", "employeeType", "title"]
ldap.search(:base => treebase, :filter => filter, :attributes => attrs) do |entry|
puts entry.cn.to_s + " - " + entry.uid.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment