132 Commits

Author SHA1 Message Date
Stonewall Jackson
3a08e80d5a Fix scope=onelevel in LDAP driver
When `scope` is set to 'onelevel', the LDAP driver actually does a full
subtree search instead.

Should be `ldap_list` instead. Fixed.
2024-02-27 13:32:15 -05:00
Andrew Ruthven
eb4d120bbf Honour do_not_sync_from_ldap when sync'ing group members
This had been working as a side effect of the way the SQL insert
statement was working, but better to be explict about skipping them.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
8a6274e6cf Rather than look for a flag, if a member is a DN, modify/fetch the record.
This changes 48c6512a70740c403027b66e9d609e9b871d29c0, in Eric's commit it
needs a flag to go fetch the record and apply the mapping to find the
username field. This approach looks for a telltale that this is DN (naively
an "=") and then either grabs the first element from the DN if the username
attr matches or fetches the entry from LDAP.

There have also been attempts in the past to special case uniqueMember and
to add a group_member_dnfix config option.

This should handle the cases where people use uid/cn/whatever for the
username.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
03d0e66b39 Handle there being no one in the group in the database 2024-02-17 02:25:25 +00:00
Andrew Ruthven
ef6bd9a7e9 fullname is a better default than group 2024-02-17 02:25:25 +00:00
Andrew Ruthven
98d9925241 Always update groups from LDAP
The logic actually handled updated group details, but only new groups were
being passed in. This will cause changes to what is being used for the
fullname to flow through.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
b77b2640f8 The displayname can be unset, test for that 2024-02-17 02:25:25 +00:00
Andrew Ruthven
cb287c5abf Use filterUsers from the config 2024-02-17 02:25:25 +00:00
Andrew Ruthven
56d7d22d86 Rename mapping_field to user_mapping_field
This is to be consistent with group_mapping_field. The code is backwards
compatible with mapping_field.

In sync_LDAP_groups assign user_mapping once, not for every group.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
3d28433b5b Fix the comments 2024-02-17 02:25:25 +00:00
Andrew Ruthven
9d40ae1aa7 Simplify the code by assigning the array after we've cleaned it up.
This allows shorter lines which means easier to understand code.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
2a30a9646c Have some sane defaults for LDAP group mappings 2024-02-17 02:25:25 +00:00
Andrew Ruthven
13083b07e8 Rename username to name in group mappings, drop unused fullname from example
Usinger "username" for the group name is confusing and misleading. Just
use name, but support our users who still have username.

We don't use fullname, drop it from the example.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
bb713137fd memberUid is deprecated, make member default 2024-02-17 02:25:25 +00:00
Andrew Ruthven
a7fc46a848 Add whitespace to sync_LDAP_groups
Make the function more readable.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
dc2991666a Allow the LDAP group to have no members 2024-02-17 02:25:25 +00:00
Andrew Ruthven
3846d31664 Handle there being no group members in the DB 2024-02-17 02:25:25 +00:00
Andrew Ruthven
1db3663302 We're using a baseDN, not querying a DN 2024-02-17 02:25:25 +00:00
Andrew Ruthven
775ecb8f3b Ensure that users_nothing_done is created as an array
This is likely only going to generate an error on the first time you
sync from LDAP, but still, let's not spit an unncessary error out.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
ed7f308b87 Add default filters for users and groups
Some (all?) LDAP servers will just not respond if there is no filter,
provide a sensible default.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
702fc05b57 Bail out early to prevent bogus errors if baseDNGroups isn't set 2024-02-17 02:25:25 +00:00
Andrew Ruthven
e73f2d73d4 Better handle when we can't talk to the server, log that 2024-02-17 02:25:25 +00:00
Andrew Ruthven
15e5a89675 Log better information about the connection to the server 2024-02-17 02:25:25 +00:00
Eric Wagner
016e51b4ac use username attr for matching group members 2024-02-17 02:25:25 +00:00
Scott Savarese
0059d0dcdb Support ldap connections via URI to handle ldaps and redundant ldap servers 2023-04-27 11:00:50 +00:00
Andrew Ruthven
0041577fc8 Handle baseDNGroups being unset. 2023-02-04 19:03:50 +13:00
Andrew Ruthven
444a098130 Ensure that groups_nothing_done is defined
Closes #278.
2023-02-04 05:48:09 +00:00
Florian Schlichting
75f62a81f6 fix PHP8 deprecation warnings: "Required parameter X follows optional parameter Y"
Deprecated: Required parameter $username follows optional parameter $attributes in inc/drivers_ldap.php on line 190
Deprecated: Required parameter $passwd follows optional parameter $attributes in inc/drivers_ldap.php on line 190
Deprecated: Required parameter $ua_string follows optional parameter $min_age in inc/external-fetch.php on line 42

As explained in https://www.php.net/manual/en/migration80.deprecated.php,
    If a parameter with a default value is followed by a required
    parameter, the default value has no effect. This is deprecated as of
    PHP 8.0.0 and can generally be resolved by dropping the default
    value, without a change in functionality
2021-02-03 23:25:51 +08:00
Florian Schlichting
9bc94556b4 add users to new groups in the "update groups" step
do not maintain the same code twice
2019-01-30 22:28:58 +01:00
Florian Schlichting
8d622df3e5 honour do_not_sync_group_from_ldap when creating groups, correctly display all results
same for groups
2019-01-30 22:18:43 +01:00
Florian Schlichting
eb0e9a8aec honour do_not_sync_from_ldap when creating users, correctly display all results
despite its name, $c->do_not_sync_from_ldap did not stop accounts in
LDAP from being created in Davical, it only stopped accounts not in LDAP
from being deactived in Davical (like a local admin account)
2019-01-30 21:57:24 +01:00
Florian Schlichting
afcaacaf2a do_not_sync_from_ldap for groups (fixes #158) 2019-01-30 21:42:01 +01:00
Florian Schlichting
db709ddebd Merge branch 'ldap-uid-vs-cn' into 'master'
LDAP: any 'dn' compatibility

See merge request davical-project/davical!43
2018-01-10 21:39:21 +00:00
Jean-Baptiste Guerraz
79acc80eb7 use php ldap explode in order to be compatible with any dn 2018-01-10 17:00:13 +01:00
Jean-Baptiste Guerraz
0fa38c8580 sync ldap user - reactivate 2018-01-10 15:55:26 +01:00
Rik Theys
e0b8ecada5 Fix modified mapping (fix #108)
The checks to test if a "modified" attribute was found in the
$valid array used in_array, which fails.

Replace this with array_key_exists calls.

This fixes https://gitlab.com/davical-project/davical/issues/108

[ $mapping['modified'] is a key in $valid, not a value. This is a
regression introduced in 970b61ac, for 1.1.5 ]
2017-04-08 00:09:50 +02:00
Florian Schlichting
f1ca12bbe9 Fix display of deactivated users after LDAP sync to not include those in $c->do_not_sync_from_ldap
...thus reducing the rate of heart attacks in DAViCal admins.

Also: ignore empty user objects that my LDAP server seems to generate.
2017-03-27 16:56:34 +02:00
Florian Schlichting
6edd828803 Fix ldapDriver instantiation 2017-01-17 23:36:05 +01:00
Marc
364bbd1df5 allow admins to manually toggle the uniqueMember fix via config (fix #102) 2017-01-17 23:30:59 +01:00
Florian Schlichting
701feb6143 drivers_*: brush up apidoc 2016-12-30 08:54:05 +01:00
Florian Schlichting
eb7f2edc0c eliminate trailing whitespace, expand tabs 2016-12-30 08:52:44 +01:00
Émile Morel
af5cdfd46d ldap group import: unset group after import 2016-12-08 15:08:38 +01:00
Benoît Bleuzé
970b61ac14 Handle empty "modified" ldap mapping
add the epoch origin modification date if the "modified" attribute is either
empty in the config file or is not returned by the request.
2016-09-14 23:18:29 +02:00
Florian Schlichting
0281a8d619 adapt to AWL function rename get_fields() -> awl_get_fields() 2016-06-13 22:02:47 +02:00
“Paul
e913676660 inc/drivers_ldap: fix 'Undefined variable' 2014-06-23 21:44:13 +02:00
“Paul
096594fac3 Support uniqueMember with DN for user names. 2014-06-23 20:28:08 +02:00
Ján Máté
6b8193ad9a added network timeout option for LDAP (thanks Sebastian Kotthoff) 2014-06-12 12:34:05 +02:00
Ján Máté
1330892852 fixed missing semicolons in drivers_ldap.php 2014-03-25 19:24:49 +01:00
Matthias Beyer
8ab19de1fe Added dbg_error_log() calls for error msgs
If the ldap driver is not valid, the error messages were not printed.
There was just "Couldn't contact LDAP server for authentication" - But
why?

This commit adds a print loop for all messages from the global
$c->messages message array.
2013-10-25 12:16:19 +13:00
Matthias Beyer
b732dcaeb3 Only set the cached instance if driver is valid
As I could see at other locations in the code, the ldap driver instance
can be invalid. And if the instance is invalid, the getStaticLdap()
function gets called again. Caching would prevent the function from
retrying to initiate the ldapDrivers object.

This commit adds conditional caching: only if the ldap driver instance is
valid, the object gets cached. This ensures that a retry with this function
would really try to create a new ldapDrivers object and not simply
return the (invalid) cached one.
2013-10-24 17:04:36 +13:00