Commit 5ade08fe7a6048665d8e00d452dcda901bc6fbc4
1 parent
d41cf41b
Exists in
master
Changed LDAP class to Net::LDAP
Showing
1 changed file
with
10 additions
and
5 deletions
Show diff stats
lib/omniauth/strategies/env.rb
@@ -24,7 +24,7 @@ module OmniAuth | @@ -24,7 +24,7 @@ module OmniAuth | ||
24 | 24 | ||
25 | # fill in some defaults | 25 | # fill in some defaults |
26 | @user_data[:name] = @uid | 26 | @user_data[:name] = @uid |
27 | - @user_data[:email] = env_user | 27 | + @user_data[:email] = env_user |
28 | 28 | ||
29 | fill_ldap_info unless @options.empty? | 29 | fill_ldap_info unless @options.empty? |
30 | 30 | ||
@@ -42,10 +42,15 @@ module OmniAuth | @@ -42,10 +42,15 @@ module OmniAuth | ||
42 | private | 42 | private |
43 | 43 | ||
44 | def fill_ldap_info | 44 | def fill_ldap_info |
45 | - adaptor = OmniAuth::LDAP::Adaptor.new @options | ||
46 | - | ||
47 | - filter = Net::LDAP::Filter.eq('samAccountName', @uid) | ||
48 | - adaptor.connection.search(base: @options[:base], filter: filter) do |entry| | 45 | + ldap = Net::LDAP.new :host => @options[:host], |
46 | + :port => @options[:port], | ||
47 | + :auth => { | ||
48 | + :method => :simple, | ||
49 | + :username => @options[:bind_dn], | ||
50 | + :password => @options[:password] | ||
51 | + } | ||
52 | + filter = Net::LDAP::Filter.eq('uid', @uid) | ||
53 | + ldap.search(:base => @options[:base], filter: filter) do |entry| | ||
49 | @user_data[:name] = "#{entry.givenname.first} #{entry.sn.first}" | 54 | @user_data[:name] = "#{entry.givenname.first} #{entry.sn.first}" |
50 | @user_data[:email] = entry.mail.first | 55 | @user_data[:email] = entry.mail.first |
51 | end | 56 | end |