Created
November 18, 2013 18:28
-
-
Save trepidity/7532818 to your computer and use it in GitHub Desktop.
Example of connecting to eDirectory with a Ruby LDAP script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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