public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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', '*')
treebase = "dc=reputablecompany, dc=com"
 
ldap.search(:base => treebase, :filter => filter) do |entry|
puts "CN: #{entry.cn}"
puts "Department: #{entry.company}"
end
 
p ldap.get_operation_result

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.