Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-auth_ldap_syncplus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-auth_ldap_syncplus
Commits
dab5a1e1
Commit
dab5a1e1
authored
5 years ago
by
Alexander Bias
Browse files
Options
Downloads
Patches
Plain Diff
Adopt code changes Moodle 3.8 core auth_ldap.
parent
9027d870
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGES.md
+1
-0
1 addition, 0 deletions
CHANGES.md
auth.php
+43
-8
43 additions, 8 deletions
auth.php
with
44 additions
and
8 deletions
CHANGES.md
+
1
−
0
View file @
dab5a1e1
...
...
@@ -6,6 +6,7 @@ Changes
### Unreleased
*
2020-02-19 - Adopt code changes Moodle 3.8 core auth_ldap.
*
2020-02-19 - Prepare compatibility for Moodle 3.8.
### v3.7-r1
...
...
This diff is collapsed.
Click to expand it.
auth.php
+
43
−
8
View file @
dab5a1e1
...
...
@@ -100,6 +100,7 @@ class auth_plugin_ldap_syncplus extends auth_plugin_ldap {
// Get user's list from ldap to sql in a scalable fashion.
// Prepare some data we'll need.
$filter
=
'(&('
.
$this
->
config
->
user_attribute
.
'=*)'
.
$this
->
config
->
objectclass
.
')'
;
$servercontrols
=
array
();
$contexts
=
explode
(
';'
,
$this
->
config
->
contexts
);
...
...
@@ -117,25 +118,59 @@ class auth_plugin_ldap_syncplus extends auth_plugin_ldap {
do
{
if
(
$ldappagedresults
)
{
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 4.1).
if
(
version_compare
(
PHP_VERSION
,
'7.3.0'
,
'<'
))
{
// Before 7.3, use this function that was deprecated in PHP 7.4.
ldap_control_paged_result
(
$ldapconnection
,
$this
->
config
->
pagesize
,
true
,
$ldapcookie
);
}
else
{
// PHP 7.3 and up, use server controls.
$servercontrols
=
array
(
array
(
'oid'
=>
LDAP_CONTROL_PAGEDRESULTS
,
'value'
=>
array
(
'size'
=>
$this
->
config
->
pagesize
,
'cookie'
=>
$ldapcookie
)));
}
}
if
(
$this
->
config
->
search_sub
)
{
// Use ldap_search to find first user from subtree.
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 4.1).
if
(
version_compare
(
PHP_VERSION
,
'7.3.0'
,
'<'
))
{
$ldapresult
=
ldap_search
(
$ldapconnection
,
$context
,
$filter
,
array
(
$this
->
config
->
user_attribute
));
}
else
{
$ldapresult
=
ldap_search
(
$ldapconnection
,
$context
,
$filter
,
array
(
$this
->
config
->
user_attribute
),
0
,
-
1
,
-
1
,
LDAP_DEREF_NEVER
,
$servercontrols
);
}
}
else
{
// Search only in this context.
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 4.1).
if
(
version_compare
(
PHP_VERSION
,
'7.3.0'
,
'<'
))
{
$ldapresult
=
ldap_list
(
$ldapconnection
,
$context
,
$filter
,
array
(
$this
->
config
->
user_attribute
));
}
else
{
$ldapresult
=
ldap_list
(
$ldapconnection
,
$context
,
$filter
,
array
(
$this
->
config
->
user_attribute
),
0
,
-
1
,
-
1
,
LDAP_DEREF_NEVER
,
$servercontrols
);
}
}
if
(
!
$ldapresult
)
{
continue
;
}
if
(
$ldappagedresults
)
{
// Get next server cookie to know if we'll need to continue searching.
$ldapcookie
=
''
;
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 4.1).
if
(
version_compare
(
PHP_VERSION
,
'7.3.0'
,
'<'
))
{
// Before 7.3, use this function that was deprecated in PHP 7.4.
$pagedresp
=
ldap_control_paged_result_response
(
$ldapconnection
,
$ldapresult
,
$ldapcookie
);
// Function ldap_control_paged_result_response() does not overwrite $ldapcookie if it fails, by
// setting this to null we avoid an infinite loop.
if
(
$pagedresp
===
false
)
{
$ldapcookie
=
null
;
}
}
else
{
// Get next cookie from controls.
ldap_parse_result
(
$ldapconnection
,
$ldapresult
,
$errcode
,
$matcheddn
,
$errmsg
,
$referrals
,
$controls
);
if
(
isset
(
$controls
[
LDAP_CONTROL_PAGEDRESULTS
][
'value'
][
'cookie'
]))
{
$ldapcookie
=
$controls
[
LDAP_CONTROL_PAGEDRESULTS
][
'value'
][
'cookie'
];
}
}
}
if
(
$entry
=
@
ldap_first_entry
(
$ldapconnection
,
$ldapresult
))
{
do
{
...
...
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