From 0a88c386b0db0e7f6cfdcbe4dd81177a126038aa Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jul 2015 20:56:48 +0300 Subject: [PATCH 1/2] Add 'puredn' ldap authentication --- html/includes/authentication/ldap.inc.php | 8 +++++++- includes/defaults.inc.php | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/html/includes/authentication/ldap.inc.php b/html/includes/authentication/ldap.inc.php index c55b54009..02c54931f 100644 --- a/html/includes/authentication/ldap.inc.php +++ b/html/includes/authentication/ldap.inc.php @@ -203,10 +203,16 @@ function update_user($user_id, $realname, $level, $can_modify_passwd, $email) { function get_membername($username) { - global $config; + global $config, $ds; if ($config['auth_ldap_groupmembertype'] == 'fulldn') { $membername = $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix']; } + elseif ($config['auth_ldap_groupmembertype'] == 'puredn') { + $filter = '('.$config['auth_ldap_attr']['uid'].'='.$username.')'; + $search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter); + $entries = ldap_get_entries($ds, $search); + $membername = $entries[0]['dn']; + } else { $membername = $username; } diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 1c209b785..d25e6b445 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -496,6 +496,7 @@ $config['auth_ldap_prefix'] = 'uid='; $config['auth_ldap_suffix'] = ',ou=People,dc=example,dc=com'; $config['auth_ldap_group'] = 'cn=groupname,ou=groups,dc=example,dc=com'; +$config['auth_ldap_attr']['uid'] = "uid"; $config['auth_ldap_groupbase'] = 'ou=group,dc=example,dc=com'; $config['auth_ldap_groups']['admin']['level'] = 10; $config['auth_ldap_groups']['pfy']['level'] = 7; From 9d1ba8bb1a1824b55404091b5ae915e1e86c471d Mon Sep 17 00:00:00 2001 From: Mikhail Bratchikov Date: Wed, 22 Jul 2015 14:44:29 +0300 Subject: [PATCH 2/2] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 1cfdac80a..4d1b12a62 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -41,6 +41,7 @@ Contributors to LibreNMS: - Job Snijders (job) - Rasmus Aberg (rasssta) - Jan Saner (trick77) +- Mikhail Bratchikov (pepyaka) [1]: http://observium.org/ "Observium web site"