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
1313cad1
Commit
1313cad1
authored
12 years ago
by
Arthur Schiwon
Browse files
Options
Downloads
Patches
Plain Diff
LDAP: let getUsers make use of paged search
parent
84130b88
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/user_ldap.php
+29
-15
29 additions, 15 deletions
apps/user_ldap/user_ldap.php
with
29 additions
and
15 deletions
apps/user_ldap/user_ldap.php
+
29
−
15
View file @
1313cad1
...
...
@@ -104,24 +104,38 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
* Get a list of all users.
*/
public
function
getUsers
(
$search
=
''
,
$limit
=
10
,
$offset
=
0
)
{
$ldap_users
=
$this
->
connection
->
getFromCache
(
'getUsers'
);
if
(
is_null
(
$ldap_users
))
{
$ldap_users
=
$this
->
fetchListOfUsers
(
$this
->
connection
->
ldapUserFilter
,
array
(
$this
->
connection
->
ldapUserDisplayName
,
'dn'
));
$ldap_users
=
$this
->
ownCloudUserNames
(
$ldap_users
);
$this
->
connection
->
writeToCache
(
'getUsers'
,
$ldap_users
);
}
$this
->
userSearch
=
$search
;
if
(
!
empty
(
$this
->
userSearch
))
{
$ldap_users
=
array_filter
(
$ldap_users
,
array
(
$this
,
'userMatchesFilter'
));
$cachekey
=
'getUsers-'
.
$search
.
'-'
.
$limit
.
'-'
.
$offset
;
//check if users are cached, if so return
$ldap_users
=
$this
->
connection
->
getFromCache
(
$cachekey
);
if
(
!
is_null
(
$ldap_users
))
{
return
$ldap_users
;
}
if
(
$limit
==
-
1
)
{
$limit
=
null
;
//prepare search filter
$search
=
empty
(
$search
)
?
'*'
:
'*'
.
$search
.
'*'
;
$filter
=
$this
->
combineFilterWithAnd
(
array
(
$this
->
connection
->
ldapUserFilter
,
$this
->
connection
->
ldapGroupDisplayName
.
'='
.
$search
));
\OCP\Util
::
writeLog
(
'user_ldap'
,
'getUsers: Get users filter '
.
$filter
,
\OCP\Util
::
DEBUG
);
//do the search and translate results to owncloud names
$ldap_users
=
$this
->
fetchListOfUsers
(
$filter
,
array
(
$this
->
connection
->
ldapUserDisplayName
,
'dn'
),
$limit
,
$offset
);
$ldap_users
=
$this
->
ownCloudUserNames
(
$ldap_users
);
if
(
!
$this
->
getPagedSearchResultState
())
{
\OCP\Util
::
writeLog
(
'user_ldap'
,
'getUsers: We got old-style results'
,
\OCP\Util
::
DEBUG
);
//if not supported, a 'normal' search has run automatically, we just need to get our slice of the cake. And we cache the general search, too
$this
->
connection
->
writeToCache
(
'getUsers-'
.
$search
,
$ldap_users
);
$ldap_users
=
array_slice
(
$ldap_users
,
$offset
,
$limit
);
}
else
{
//debug message only
\OCP\Util
::
writeLog
(
'user_ldap'
,
'getUsers: We got paged results'
,
\OCP\Util
::
DEBUG
);
}
return
array_slice
(
$ldap_users
,
$offset
,
$limit
);
}
public
function
userMatchesFilter
(
$
user
)
{
return
(
strripos
(
$user
,
$this
->
userSearch
)
!==
false
)
;
$this
->
connection
->
writeToCache
(
$cachekey
,
$ldap_
user
s
);
return
$ldap_users
;
}
/**
...
...
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