Skip to content

Instantly share code, notes, and snippets.

@rubiojr
Created July 21, 2009 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubiojr/151258 to your computer and use it in GitHub Desktop.
Save rubiojr/151258 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'net/ldap'
ldap = Net::LDAP.new
ldap.host = 'foo.bar.stuff'
ldap.port = 636
ldap.encryption :method => :simple_tls
ldap.auth 'cn=user, dc=foo, dc=bar', 'something-secret'
if ldap.bind
filter = Net::LDAP::Filter.eq( "cn", "my.name*" )
ldap.search(:base => "idnc=usuarios,dc=foo,dc=bar", :filter => filter) do |e|
puts e.dn
end
else
puts 'could not bind'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment