Skip to content

Instantly share code, notes, and snippets.

@trepidity
Created November 18, 2013 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trepidity/7532818 to your computer and use it in GitHub Desktop.
Save trepidity/7532818 to your computer and use it in GitHub Desktop.
Example of connecting to eDirectory with a Ruby LDAP script
require 'rubygems'
require 'net/ldap' #gem install --no-rdoc --no-ri net-ldap
ldap = Net::LDAP.new :host => "172.16.138.142",
:port => 389,
:auth => {
:method => :simple,
:username => "cn=admin,o=novell",
:password => "n0v3ll"
}
filter = Net::LDAP::Filter.eq("cn", "jj*")
treebase = "o=novell"
attrs = ["mail", "cn", "sn", "objectclass", "loginTime"]
ldap.search(:base => treebase, :filter => filter, :attributes => attrs) do |entry|
puts "DN: #{entry.dn}"
entry.each do |attribute, values|
puts " #{attribute}:"
values.each do |value|
puts " --->#{value}"
end
end
end
p ldap.get_operation_result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment