Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
3f85432d
Commit
3f85432d
authored
12 years ago
by
Arthur Schiwon
Browse files
Options
Downloads
Patches
Plain Diff
LDAP: make filter in readAttribute configurable
parent
b390da3e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/user_ldap/lib/access.php
+6
-2
6 additions, 2 deletions
apps/user_ldap/lib/access.php
with
6 additions
and
2 deletions
apps/user_ldap/lib/access.php
+
6
−
2
View file @
3f85432d
...
@@ -44,7 +44,7 @@ abstract class Access {
...
@@ -44,7 +44,7 @@ abstract class Access {
*
*
* Reads an attribute from an LDAP entry
* Reads an attribute from an LDAP entry
*/
*/
public
function
readAttribute
(
$dn
,
$attr
)
{
public
function
readAttribute
(
$dn
,
$attr
,
$filter
=
'objectClass=*'
)
{
if
(
!
$this
->
checkConnection
())
{
if
(
!
$this
->
checkConnection
())
{
\OCP\Util
::
writeLog
(
'user_ldap'
,
'No LDAP Connector assigned, access impossible for readAttribute.'
,
\OCP\Util
::
WARN
);
\OCP\Util
::
writeLog
(
'user_ldap'
,
'No LDAP Connector assigned, access impossible for readAttribute.'
,
\OCP\Util
::
WARN
);
return
false
;
return
false
;
...
@@ -55,13 +55,17 @@ abstract class Access {
...
@@ -55,13 +55,17 @@ abstract class Access {
\OCP\Util
::
writeLog
(
'user_ldap'
,
'LDAP resource not available.'
,
\OCP\Util
::
DEBUG
);
\OCP\Util
::
writeLog
(
'user_ldap'
,
'LDAP resource not available.'
,
\OCP\Util
::
DEBUG
);
return
false
;
return
false
;
}
}
$rr
=
@
ldap_read
(
$cr
,
$dn
,
'objectClass=*'
,
array
(
$attr
));
$rr
=
@
ldap_read
(
$cr
,
$dn
,
$filter
,
array
(
$attr
));
if
(
!
is_resource
(
$rr
))
{
if
(
!
is_resource
(
$rr
))
{
\OCP\Util
::
writeLog
(
'user_ldap'
,
'readAttribute '
.
$attr
.
' failed for DN '
.
$dn
,
\OCP\Util
::
DEBUG
);
\OCP\Util
::
writeLog
(
'user_ldap'
,
'readAttribute '
.
$attr
.
' failed for DN '
.
$dn
,
\OCP\Util
::
DEBUG
);
//in case an error occurs , e.g. object does not exist
//in case an error occurs , e.g. object does not exist
return
false
;
return
false
;
}
}
$er
=
ldap_first_entry
(
$cr
,
$rr
);
$er
=
ldap_first_entry
(
$cr
,
$rr
);
if
(
!
is_resource
(
$er
))
{
//did not match the filter, return false
return
false
;
}
//LDAP attributes are not case sensitive
//LDAP attributes are not case sensitive
$result
=
\OCP\Util
::
mb_array_change_key_case
(
ldap_get_attributes
(
$cr
,
$er
),
MB_CASE_LOWER
,
'UTF-8'
);
$result
=
\OCP\Util
::
mb_array_change_key_case
(
ldap_get_attributes
(
$cr
,
$er
),
MB_CASE_LOWER
,
'UTF-8'
);
$attr
=
mb_strtolower
(
$attr
,
'UTF-8'
);
$attr
=
mb_strtolower
(
$attr
,
'UTF-8'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment