Ruby on rails 是否有方法使用电子邮件/密码对LDAP用户进行身份验证?
是否有一种方法可以通过电子邮件(邮件)而不是cn或DN对LDAP用户进行身份验证?我们使用的是ruby ldap,可能还有活动ldap(不过,我们一直在使用它)。我们需要做的就是对用户进行身份验证,然后根据验证成功的情况在系统中创建成员身份 与管理用户一起登录ldap,并通过电子邮件和密码使用过滤器搜索用户:Ruby on rails 是否有方法使用电子邮件/密码对LDAP用户进行身份验证?,ruby-on-rails,ruby,ldap,Ruby On Rails,Ruby,Ldap,是否有一种方法可以通过电子邮件(邮件)而不是cn或DN对LDAP用户进行身份验证?我们使用的是ruby ldap,可能还有活动ldap(不过,我们一直在使用它)。我们需要做的就是对用户进行身份验证,然后根据验证成功的情况在系统中创建成员身份 与管理用户一起登录ldap,并通过电子邮件和密码使用过滤器搜索用户: require 'rubygems' require 'net/ldap' ldap = Net::LDAP.new :host => server_ip_address,
require 'rubygems'
require 'net/ldap'
ldap = Net::LDAP.new :host => server_ip_address,
:port => 389,
:auth => {
:method => :simple,
:username => "cn=manager,dc=example,dc=com",
:password => "opensesame"
}
filter = Net::LDAP::Filter.eq( "email", "joe@email.com" )
treebase = "ou=Users,dc=example,dc=com"
@auth = false
ldap.search( :base => treebase, :filter => filter ) do |entry|
ldap2 = Net::LDAP.new :host => server_ip_address,
:port => 389,
:auth => {
:method => :simple,
:username => entry.dn,
:password => "joe's password"
}
@auth = true if ldap2.bind
end
puts "user authenticated" if @auth