public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
require 'sinatra'
require 'net/ldap'
 
ldap = Net::LDAP.new
ldap.host = '192.168.1.1'
ldap.port = 389
ldap.auth "username", "password"
 
filter = Net::LDAP::Filter.eq('CN', 'john ivanoff')
treebase = "dc=reputablecompany, dc=com"
 
ldap.search(:base => treebase, :filter => filter) 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.