LDAP Authentication

Hi all,
I’ve LDAP basic authentication working using NET::LDAP.

#####################################################
require ‘ldap_auth’

#LDAP connection info

host= ‘myldapserver’ #Your ldap server
dn = ‘CN=users,DC=org,DC=com’
#Credentials of the user we are trying to authenticate

account_name = ‘somename’
password = ‘somepass’

print “#{account_name} "
unless LDAP::Auth.authenticate(”#{account_name}", password, dn, host) do
|auth_obj|

puts 'authenticated!'
puts 'Group info:'
groups = auth_obj.groups_for(account_name, 'sAMAccountName',

‘memberOf’){|group|puts group}
puts groups.inspect
puts
puts ‘Some attributes:’
attributes = auth_obj.attributes_for(account_name, ‘sAMAccountName’,
[‘sn’, ‘givenName’, ‘mail’, ]){|name, value| puts “#{name} = #{value}”}
puts attributes.inspect
end
puts ‘authentication failed! Bad account name and/or password’
end
####################################################
o/p

someone authenticated!
Group info:
[]

Some attributes:
{}
#######################

It is working and put ‘authenticated’ message for valid user. But I am
unable to get groupinfo and other attributes.
Can I use this authentication to retrieve data from MYSql database?
How to get groupinfo and user attributes?
Please help me out.

Thanks,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs