Skip to content

Instantly share code, notes, and snippets.

@dpogorzelski
Created May 15, 2012 15:33
Show Gist options
  • Save dpogorzelski/2702690 to your computer and use it in GitHub Desktop.
Save dpogorzelski/2702690 to your computer and use it in GitHub Desktop.
Get LDAP users from WMS
require 'net/ldap'
ldap = Net::LDAP.new
ldap.host = "192.168.222.154"
ldap.port = 389
ldap.auth "cn=netreader,dc=wildix", "wildix"
if !ldap.bind
puts "Connection failed"
end
filter = Net::LDAP::Filter.eq("objectClass", "wPerson")
treebase = "o=com0,dc=wildix"
ldap.search(:base => treebase, :filter => filter) do |entry|
puts "DN: #{entry.dn}"
entry.each do |attribute, value|
puts " #{attribute}: #{value.first}"
end
puts "\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment