Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
48fa4ec0
Commit
48fa4ec0
authored
Apr 15, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'handle-ldap-errors' into 'master'
Handle ldap errors Fixes #85
parents
de68bada
eff30fff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+16
-5
lib/gitlab/ldap/person.rb
lib/gitlab/ldap/person.rb
+1
-1
spec/lib/gitlab/ldap/ldap_adapter_spec.rb
spec/lib/gitlab/ldap/ldap_adapter_spec.rb
+1
-1
No files found.
lib/gitlab/ldap/adapter.rb
View file @
48fa4ec0
...
...
@@ -62,7 +62,7 @@ module Gitlab
options
.
merge!
(
size:
size
)
if
size
ldap
.
search
(
options
).
map
do
|
entry
|
ldap
_
search
(
options
).
map
do
|
entry
|
Gitlab
::
LDAP
::
Group
.
new
(
entry
,
self
)
end
end
...
...
@@ -93,7 +93,7 @@ module Gitlab
end
end
entries
=
ldap
.
search
(
options
).
select
do
|
entry
|
entries
=
ldap
_
search
(
options
).
select
do
|
entry
|
entry
.
respond_to?
config
.
uid
end
...
...
@@ -107,11 +107,22 @@ module Gitlab
end
def
dn_matches_filter?
(
dn
,
filter
)
results
=
ldap
.
search
(
base:
dn
,
filter:
filter
,
attributes:
%w{dn}
)
ldap_search
(
base:
dn
,
filter:
filter
,
attributes:
%w{dn}
).
any?
end
def
ldap_search
(
*
args
)
results
=
ldap
.
search
(
*
args
)
if
results
.
nil?
false
# Net::LDAP encountered an LDAP error
response
=
ldap
.
get_operation_result
unless
response
.
code
.
zero?
Rails
.
logger
.
warn
(
"LDAP search error:
#{
response
.
message
}
"
)
end
[]
else
results
.
any?
results
end
end
...
...
lib/gitlab/ldap/person.rb
View file @
48fa4ec0
...
...
@@ -9,7 +9,7 @@ module Gitlab
class
Person
def
self
.
find_by_uid
(
uid
,
adapter
=
nil
)
adapter
||=
Gitlab
::
LDAP
::
Adapter
.
new
adapter
.
user
(
config
.
uid
,
uid
)
adapter
.
user
(
Gitlab
.
config
.
ldap
.
uid
,
uid
)
end
def
self
.
find_by_dn
(
dn
,
adapter
=
nil
)
...
...
spec/lib/gitlab/ldap/ldap_adapter_spec.rb
View file @
48fa4ec0
...
...
@@ -23,7 +23,7 @@ describe Gitlab::LDAP::Adapter do
end
context
"when the search encounters an error"
do
before
{
ldap
.
stub
(
search:
nil
)
}
before
{
ldap
.
stub
(
search:
nil
,
get_operation_result:
double
(
code:
1
,
message:
'some error'
)
)
}
it
{
should
be_false
}
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment