Posted By

paramah on 01/05/09


Tagged

ruby ldap


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


LDAP access in Ruby


 / Published in: Ruby
 

  1. require 'rubygems'
  2. require 'net/ldap'
  3.  
  4. username = ''
  5. password = ''
  6. ldaphost = ''
  7. basedn=''
  8.  
  9. ldap = Net::LDAP.new(:host => ldaphost, :base => basedn)
  10. filter = Net::LDAP::Filter.eq('uid', username)
  11. ldap.search(:filter => filter) {|entry| username = entry.dn}
  12. ldap.auth(username, password)
  13.  
  14. if ldap.bind
  15. print "YEAP";
  16. else
  17. print "NOPE";
  18. end

Report this snippet  

You need to login to post a comment.