From 838617100c264e24a6c03a5be32274736c7201f7 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Wed, 21 Sep 2011 22:04:05 +0000 Subject: [PATCH] get ldap userlevel and user id from ldap now, configure the ldap groups levels in the config file; please note if you assigned rights to certain users they might have vanished as the userid is now the uidnumber from ldap git-svn-id: http://www.observium.org/svn/observer/trunk@2539 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/authentication/ldap.inc.php | 53 ++++++++++++++++++++--- includes/defaults.inc.php | 5 +++ 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/html/includes/authentication/ldap.inc.php b/html/includes/authentication/ldap.inc.php index c091d4b2db..397ca1983f 100644 --- a/html/includes/authentication/ldap.inc.php +++ b/html/includes/authentication/ldap.inc.php @@ -1,10 +1,11 @@ $userlevel) + { + $userlevel = $config['auth_ldap_groups'][$groupname]['level']; + } + } + + return $userlevel; } function get_userid($username) { - # FIXME should come from LDAP - return dbFetchCell("SELECT `user_id` FROM `users` WHERE `username` = ?", array($username)); + global $config, $ds; + + $filter = "(" . $config['auth_ldap_prefix'] . $username . ")"; + $search = ldap_search($ds, trim($config['auth_ldap_suffix'],','), $filter); + $entries = ldap_get_entries($ds, $search); + + if ($entries['count']) + { + return $entries[0]['uidnumber'][0]; + } + + return -1; } function deluser($username) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index bf07a927f2..8556477539 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -310,6 +310,11 @@ $config['auth_ldap_prefix'] = "uid="; $config['auth_ldap_suffix'] = ",ou=People,dc=example,dc=com"; $config['auth_ldap_group'] = "cn=observium,ou=groups,dc=example,dc=com"; +$config['auth_ldap_groupbase'] = "ou=group,dc=luciad,dc=com"; +$config['auth_ldap_groups']['admin']['level'] = 10; +$config['auth_ldap_groups']['pfy']['level'] = 7; +$config['auth_ldap_groups']['support']['level'] = 1; + ### Hardcoded ASN descriptions $config['astext'][65333] = "Cymru Bogon Feed";