Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2017-02-26 14:51:49 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
a90f564980608f8682d65a8558fb7ed5a0d6f43c
a90f5649
1 parent
253132af
Made LDAP email attribute configurable via .env
Closes #306
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
app/Services/LdapService.php
config/services.php
app/Services/LdapService.php
View file @
a90f564
...
...
@@ -41,7 +41,8 @@ class LdapService
// Find user
$userFilter
=
$this
->
buildFilter
(
$this
->
config
[
'user_filter'
],
[
'user'
=>
$userName
]);
$baseDn
=
$this
->
config
[
'base_dn'
];
$users
=
$this
->
ldap
->
searchAndGetEntries
(
$ldapConnection
,
$baseDn
,
$userFilter
,
[
'cn'
,
'uid'
,
'dn'
,
'mail'
]);
$emailAttr
=
$this
->
config
[
'email_attribute'
];
$users
=
$this
->
ldap
->
searchAndGetEntries
(
$ldapConnection
,
$baseDn
,
$userFilter
,
[
'cn'
,
'uid'
,
'dn'
,
$emailAttr
]);
if
(
$users
[
'count'
]
===
0
)
return
null
;
$user
=
$users
[
0
];
...
...
@@ -49,7 +50,7 @@ class LdapService
'uid'
=>
(
isset
(
$user
[
'uid'
]))
?
$user
[
'uid'
][
0
]
:
$user
[
'dn'
],
'name'
=>
$user
[
'cn'
][
0
],
'dn'
=>
$user
[
'dn'
],
'email'
=>
(
isset
(
$user
[
'mail'
]))
?
$user
[
'mail'
][
0
]
:
null
'email'
=>
(
isset
(
$user
[
$emailAttr
]))
?
(
is_array
(
$user
[
$emailAttr
])
?
$user
[
$emailAttr
][
0
]
:
$user
[
$emailAttr
])
:
null
];
}
...
...
config/services.php
View file @
a90f564
...
...
@@ -78,7 +78,8 @@ return [
'pass'
=>
env
(
'LDAP_PASS'
,
false
),
'base_dn'
=>
env
(
'LDAP_BASE_DN'
,
false
),
'user_filter'
=>
env
(
'LDAP_USER_FILTER'
,
'(&(uid=${user}))'
),
'version'
=>
env
(
'LDAP_VERSION'
,
false
)
'version'
=>
env
(
'LDAP_VERSION'
,
false
),
'email_attribute'
=>
env
(
'LDAP_EMAIL_ATTRIBUTE'
,
'mail'
),
]
];
...
...
Please
register
or
sign in
to post a comment