LDAP access in Ruby


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.