Skip to content

Instantly share code, notes, and snippets.

@schaary
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schaary/10142473 to your computer and use it in GitHub Desktop.
Save schaary/10142473 to your computer and use it in GitHub Desktop.
shows an example ldapsearch call with net/ldap gem, when you have the dn of the entry
basedn = "uid=foo,ou=bar,c=baz"
attrs = ["mail", "cn", "sn", "objectclass"]
ldap.search(:base => basedn, :attributes => attrs) do |entry|
puts "DN: #{entry.dn}"
entry.each do |attr, values|
puts "#{attr}:"
values.each do |value|
puts "#{value}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment