Skip to content

Commit 3af0a88

Browse files
author
Dave Sims
committed
Make sure global catalog search returns first entry from result array
1 parent ab2d49a commit 3af0a88

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

lib/github/ldap/domain.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ def user?(login, search_options = {})
122122
if @ldap.active_directory_capability?
123123
# when doing a global search for a user's DN, set the search base to blank
124124
options[:base] = ""
125-
@ldap.global_catalog_search(options)
126-
125+
@ldap.global_catalog_search(options).first
127126
else
128127
search(options).first
129128
end

test/domain_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ def test_use_global_catalog_if_active_directory
148148
@domain.user?('user1', :attributes => [:cn])
149149
end
150150

151+
def test_global_catalog_search_returns_first_entry
152+
@ldap.stubs(:active_directory_capability?).returns(true)
153+
entry = Object.new
154+
@ldap.expects(:global_catalog_search).returns([entry])
155+
user = @domain.user?('user1', :attributes => [:cn])
156+
assert_equal entry, user
157+
end
158+
151159
def test_global_catalog_has_empty_search_base
152160
@ldap.stubs(:active_directory_capability?).returns(true)
153161
@ldap.expects(:global_catalog_search).with(has_entry(:base => "")).returns([])

0 commit comments

Comments
 (0)