19 Commits

Author SHA1 Message Date
sam marshall
b154e3cd33 MDL-78434 Lib: PHP 8.1 incompatible code relating to LDAP\Connection 2023-06-13 09:46:49 +01:00
Eloy Lafuente (stronk7)
486bf50413 MDL-67316 ldap: Pass correct hex chars to hexdec()
Before php74 they were silently discarded, now they
show a deprecation message.
2020-04-24 15:56:38 +02:00
Iñaki Arenaza
67bebb69eb MDL-57558 ldap: fix ldap_get_entries_moodle()
While ldap_get_entries_moodle() PHPdocs state that it returns "array
ldap-entries with lower-cased attributes as indexes.", this is not true. It
uses ldap_get_attributes() internally, which returns both numerically indexed
attribute names, and dictionary-like entries indexed by attribute names.

Current code lowercases the dictionary-like entries, but then uses the
numerically indexed entries for the attribute names used as keys in the
returned array. The numerically indexed names might or might not be lowercased,
depending on the LDAP server and PHP version) version. E.g., OpenLDAP 2.x,
Novell eDirectory 8.x and MS Active Directory return mixed-cased attribute
names, and PHP 5.x and PHP 7.x don't lowercase them inside ldap_get_entries().

This is probably why all calls to ldap_get_entries_moodle() are followed by
calls to array_change_key_case(), even if that shouldn't be necessary.

So make sure we always return lower-cased attributs as indexes and add some
unit tests to avoid regressions in the future.
2017-05-16 10:48:27 +01:00
Iñaki Arenaza
e47863e840 MDL-50625 auth_ldap: Better check for paged results support
There is at least one LDAP server (Sun Directory Server) that doesn't
support Paged Results extension, even if it supports LDAP version 3. So
checking just for LDAP version is not enough.

If possible, we check the supportedControl attribute of the LDAP rootDSE
and see if the paged results control is available. This needs an LDAP
connection, which might not be possible to establish before we configure
some essential LDAP settings (server, bind user, password, etc.). Thus
we try to establish the connection and check the supportedControl
attribute. But if we fail, we perform only basic checks that are less
accurate and err on the side of cautiousness.
2017-01-19 10:55:26 +01:00
Cameron Ball
8ffe9aef1f MDL-53580 auth_ldap: Set default value for suspended_attribute
It was also necessary to cast some boolean values to ints as a
workaround for moodle's broken boolean validation.
2016-05-10 23:04:46 +08:00
Andrew Nicols
abedeb8c70 MDL-51723 ldap: Normalise the user objectclass 2016-02-01 10:24:34 +08:00
Matteo Scaramuccia
6514ced4f5 MDL-47004 LDAP: improved the default objectClass setting for AD. 2015-04-15 23:53:35 +02:00
Damyon Wiese
527464a618 MDL-43430 ldap: whitespace fix 2014-11-06 12:05:32 +08:00
Iñaki Arenaza
cc22032502 MDL-43430 enrol_ldap: Enrolment lost if member of group with parenthesis
While testing the fix, it was found that ldap_stripslashes() was broken and
using a deprecated PCRE patter modifier, so it's also been fixed.

Thanks to Damyon Wiese, some units tests have been added to cover
ldap_addslashes() and ldap_stripslashes().
2014-11-05 09:01:27 +01:00
Iñaki Arenaza
9807737734 MDL-43430 enrol_ldap: Enrolment lost if member of group with parenthesis
As part of fixing MDL-43430, a typo has been detected in the
quoted alphanumeric characters (the '=' and '>' were transposed).
2014-11-05 09:00:17 +01:00
Petr Škoda
deae60239d MDL-43503 do not check presence of ldap paging functions, we require PHP 5.4 now 2013-12-31 14:34:20 +08:00
Iñaki Arenaza
3f9562cc5d MDL-42723: Hide and handle LDAP error when user not in context being checked
MDL-41304 only fixed the case when 'Search subcontext' is enabled. We need to
fix the case when it's not enabled too.

While silencing errors with an @ should be avoided if possible, there's no
other way to prevent the warnings in this case.
2013-11-06 17:31:55 +01:00
Tim Lock
6b718780c6 MDL-41304: Hide and handle LDAP error when user not in context being checked 2013-08-20 10:34:16 +09:30
Iñaki Arenaza
326929d54a MDL-3941 auth/cas auth/ldap enrol/ldap Add support for LDAP-TLS.
Credit goes to Chris Bandy for proposing the initial patch.
2012-12-04 12:11:06 +01:00
Dan Poltawski
ee943e7311 MDL-36119 - fix trailing whitespace 2012-11-08 10:18:06 +08:00
Iñaki Arenaza
c090d7c90e MDL-36119: auth_{ldap,cas}: LDAP Sync - implement paged results
Thanks to Jerome Charaoui for the original patch.
2012-11-07 19:13:10 +01:00
Inaki
3e5f4b870e auth/ldap MDL-23652 Error in auth_ldap_sync_users.php
We need to specify a valid user id in the call to role_assign(). And we only
have to make the call if the user has been added successfully, not
otherwise.

Also make sure we lowercase the memberuser and group distinguished names
before comparing them. Depending on the LDAP server we can get mixed case
values for the DNs, and the user may have specified the creators group/ou
name in a different case.

By the way, this has been broken for ages (since the auth cleanup in 1.8, in
2007!). It's a bit strange nobody noticed before :-O

Credit goes to Joe Chryst.
2010-08-07 00:40:16 +00:00
Petr Skoda
78bfb562a0 MDL-21249 improved php docs and adding direct access prevention in core libs 2010-07-25 13:35:05 +00:00
Inaki
5704585cf4 enrol/ldap: MDL-22784 Conversion of the LDAP enrolment plugin to the new enrolment infrastructure.
We've moved some of the LDAP auth plugin "knowledge" of different LDAP
servers to a common library, and we've added support for nested groups
enrolments for selected LDAP servers.

Lots of changes in the language pack, as all the plugin messages have been
internationali[sz]ed (it also includes renaming of quite a few string
identifiers).

During plugin settings migration, we rename 'version' setting to
'ldap_version', as we store the plugin version itself as a setting in the
plugin config table and the two collided.

Performance is not great for larga data sets but this can be improved later
(20000 users, 4000 courses and 100 users/course take around 1h25m on a somewhat
tuned postgresql-8.4 on a 2.66GHz Core2 Duo w/ 4 GB of RAM).

AMOS BEGIN
  MOV [description,enrol_ldap],[pluginname_desc,enrol_ldap]
  MOV [enrol_ldap_autocreate,enrol_ldap],[autocreate,enrol_ldap]
  MOV [enrol_ldap_autocreate_key,enrol_ldap],[autocreate_key,enrol_ldap]
  MOV [enrol_ldap_autocreation_settings,enrol_ldap],[autocreation_settings,enrol_ldap]
  MOV [enrol_ldap_bind_dn,enrol_ldap],[bind_dn,enrol_ldap]
  MOV [enrol_ldap_bind_dn_key,enrol_ldap],[bind_dn_key,enrol_ldap]
  MOV [enrol_ldap_bind_pw,enrol_ldap],[bind_pw,enrol_ldap]
  MOV [enrol_ldap_bind_pw_key,enrol_ldap],[bind_pw_key,enrol_ldap]
  MOV [enrol_ldap_bind_settings,enrol_ldap],[bind_settings,enrol_ldap]
  MOV [enrol_ldap_category,enrol_ldap],[category,enrol_ldap]
  MOV [enrol_ldap_category_key,enrol_ldap],[category_key,enrol_ldap]
  MOV [enrol_ldap_contexts,enrol_ldap],[contexts,enrol_ldap]
  MOV [enrol_ldap_course_fullname,enrol_ldap],[course_fullname,enrol_ldap]
  MOV [enrol_ldap_course_fullname_key,enrol_ldap],[course_fullname_key,enrol_ldap]
  MOV [enrol_ldap_course_idnumber,enrol_ldap],[course_idnumber,enrol_ldap]
  MOV [enrol_ldap_course_idnumber_key,enrol_ldap],[course_idnumber_key,enrol_ldap]
  MOV [enrol_ldap_course_search_sub,enrol_ldap],[course_search_sub,enrol_ldap]
  MOV [enrol_ldap_course_settings,enrol_ldap],[course_settings,enrol_ldap]
  MOV [enrol_ldap_course_shortname,enrol_ldap],[course_shortname,enrol_ldap]
  MOV [enrol_ldap_course_shortname_key,enrol_ldap],[course_shortname_key,enrol_ldap]
  MOV [enrol_ldap_course_summary,enrol_ldap],[course_summary,enrol_ldap]
  MOV [enrol_ldap_course_summary_key,enrol_ldap],[course_summary_key,enrol_ldap]
  MOV [enrol_ldap_editlock,enrol_ldap],[editlock,enrol_ldap]
  MOV [enrol_ldap_ldap_encoding,enrol_ldap],[ldap_encoding,enrol_ldap]
  MOV [enrol_ldap_ldap_encoding_key,enrol_ldap],[ldap_encoding_key,enrol_ldap]
  MOV [enrol_ldap_general_options,enrol_ldap],[general_options,enrol_ldap]
  MOV [enrol_ldap_group_memberofattribute,enrol_ldap],[group_memberofattribute,enrol_ldap]
  MOV [enrol_ldap_group_memberofattribute_key,enrol_ldap],[group_memberofattribute_key,enrol_ldap]
  MOV [enrol_ldap_host_url,enrol_ldap],[host_url,enrol_ldap]
  MOV [enrol_ldap_host_url_key,enrol_ldap],[host_url_key,enrol_ldap]
  MOV [enrol_ldap_idnumber_attribute,enrol_ldap],[idnumber_attribute,enrol_ldap]
  MOV [enrol_ldap_idnumber_attribute_key,enrol_ldap],[idnumber_attribute_key,enrol_ldap]
  MOV [enrol_ldap_memberattribute,enrol_ldap],[memberattribute,enrol_ldap]
  MOV [enrol_ldap_memberattribute_isdn,enrol_ldap],[memberattribute_isdn,enrol_ldap]
  MOV [enrol_ldap_memberattribute_isdn_key,enrol_ldap],[memberattribute_isdn_key,enrol_ldap]
  MOV [enrol_ldap_nested_groups,enrol_ldap],[nested_groups,enrol_ldap]
  MOV [enrol_ldap_nested_groups_key,enrol_ldap],[nested_groups_key,enrol_ldap]
  MOV [enrol_ldap_nested_groups_settings,enrol_ldap],[nested_groups_settings,enrol_ldap]
  MOV [enrol_ldap_objectclass,enrol_ldap],[objectclass,enrol_ldap]
  MOV [enrol_ldap_objectclass_key,enrol_ldap],[objectclass_key,enrol_ldap]
  MOV [enrol_ldap_opt_deref,enrol_ldap],[opt_deref,enrol_ldap]
  MOV [enrol_ldap_opt_deref_key,enrol_ldap],[opt_deref_key,enrol_ldap]
  MOV [enrol_ldap_roles,enrol_ldap],[roles,enrol_ldap]
  MOV [enrol_ldap_search_sub_key,enrol_ldap],[search_sub_key,enrol_ldap]
  MOV [enrol_ldap_server_settings,enrol_ldap],[server_settings,enrol_ldap]
  MOV [enrol_ldap_template,enrol_ldap],[template,enrol_ldap]
  MOV [enrol_ldap_template_key,enrol_ldap],[template_key,enrol_ldap]
  MOV [enrol_ldap_updatelocal,enrol_ldap],[updatelocal,enrol_ldap]
  MOV [enrol_ldap_user_attribute,enrol_ldap],[user_attribute,enrol_ldap]
  MOV [enrol_ldap_user_attribute_key,enrol_ldap],[user_attribute_key,enrol_ldap]
  MOV [enrol_ldap_user_contexts,enrol_ldap],[user_contexts,enrol_ldap]
  MOV [enrol_ldap_user_contexts_key,enrol_ldap],[user_contexts_key,enrol_ldap]
  MOV [enrol_ldap_user_search_sub,enrol_ldap],[user_search_sub,enrol_ldap]
  MOV [enrol_ldap_user_settings,enrol_ldap],[user_settings,enrol_ldap]
  MOV [enrol_ldap_user_type,enrol_ldap],[user_type,enrol_ldap]
  MOV [enrol_ldap_user_type_key,enrol_ldap],[user_type_key,enrol_ldap]
  MOV [enrol_ldap_version,enrol_ldap],[version,enrol_ldap]
  MOV [enrol_ldap_version_key,enrol_ldap],[version_key,enrol_ldap]
  MOV [search_sub_key,enrol_ldap],[course_search_sub_key,enrol_ldap]
AMOS END
2010-07-19 21:52:52 +00:00