File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -110,11 +110,15 @@ def valid_login?(login, password)
110
110
# Check if a user exists based in the `uid`.
111
111
#
112
112
# login: is the user's login
113
+ # search_options: Net::LDAP#search compatible options to pass through
113
114
#
114
115
# Returns the user if the login matches any `uid`.
115
116
# Returns nil if there are no matches.
116
- def user? ( login )
117
- search ( filter : login_filter ( @uid , login ) , size : 1 ) . first
117
+ def user? ( login , search_options = { } )
118
+ options = search_options . merge \
119
+ filter : login_filter ( @uid , login ) ,
120
+ size : 1
121
+ search ( options ) . first
118
122
end
119
123
120
124
# Check if a user can be bound with a password.
Original file line number Diff line number Diff line change @@ -126,6 +126,11 @@ def test_user_returns_every_attribute
126
126
assert_equal [ 'user1@github.com' ] , user [ :mail ]
127
127
end
128
128
129
+ def test_user_returns_subset_of_attributes
130
+ assert entry = @domain . user? ( 'user1' , :attributes => [ :cn ] )
131
+ assert_equal [ :dn , :cn ] , entry . attribute_names
132
+ end
133
+
129
134
def test_auth_binds
130
135
assert user = @domain . user? ( 'user1' )
131
136
assert @domain . auth ( user , 'passworD1' ) , 'Expected user to bind'
You can’t perform that action at this time.
0 commit comments