diff --git a/lib/github/ldap/domain.rb b/lib/github/ldap/domain.rb index 8085c44..aa2066b 100644 --- a/lib/github/ldap/domain.rb +++ b/lib/github/ldap/domain.rb @@ -110,11 +110,15 @@ def valid_login?(login, password) # Check if a user exists based in the `uid`. # # login: is the user's login + # search_options: Net::LDAP#search compatible options to pass through # # Returns the user if the login matches any `uid`. # Returns nil if there are no matches. - def user?(login) - search(filter: login_filter(@uid, login), size: 1).first + def user?(login, search_options = {}) + options = search_options.merge \ + filter: login_filter(@uid, login), + size: 1 + search(options).first end # Check if a user can be bound with a password. diff --git a/test/domain_test.rb b/test/domain_test.rb index 8ddf72c..797f716 100644 --- a/test/domain_test.rb +++ b/test/domain_test.rb @@ -126,6 +126,11 @@ def test_user_returns_every_attribute assert_equal ['user1@github.com'], user[:mail] end + def test_user_returns_subset_of_attributes + assert entry = @domain.user?('user1', :attributes => [:cn]) + assert_equal [:dn, :cn], entry.attribute_names + end + def test_auth_binds assert user = @domain.user?('user1') assert @domain.auth(user, 'passworD1'), 'Expected user to bind'
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: