summaryrefslogtreecommitdiff
path: root/inc/auth
diff options
context:
space:
mode:
authorDominik Eckelmann <deckelmann@gmail.com>2010-04-29 11:51:11 +0200
committerAdrian Lang <lang@cosmocode.de>2010-04-29 12:04:30 +0200
commitba29aad72a17a6a9c34afcb2adc13f2a7f9e4e17 (patch)
treeb88ff8846245e54408b7a7df7408d0be64ee52e0 /inc/auth
parent274409ef297b1f80c36bf04e64a1571be0e0039f (diff)
downloadrpg-ba29aad72a17a6a9c34afcb2adc13f2a7f9e4e17.tar.gz
rpg-ba29aad72a17a6a9c34afcb2adc13f2a7f9e4e17.tar.bz2
gather additional information from ad backend
Diffstat (limited to 'inc/auth')
-rw-r--r--inc/auth/ad.class.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/inc/auth/ad.class.php b/inc/auth/ad.class.php
index e60598df6..a52f5f8b2 100644
--- a/inc/auth/ad.class.php
+++ b/inc/auth/ad.class.php
@@ -26,6 +26,10 @@
* $conf['auth']['ad']['use_ssl'] = 1;
* $conf['auth']['ad']['debug'] = 1;
*
+ * // get additional informations to the userinfo array
+ * // add a list of comma separated ldap contact fields.
+ * $conf['auth']['ad']['additional'] = 'field1,field2';
+ *
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author James Van Lommel <jamesvl@gmail.com>
* @link http://www.nosq.com/blog/2005/08/ldap-activedirectory-and-dokuwiki/
@@ -47,6 +51,12 @@ class auth_ad extends auth_basic {
global $conf;
$this->cnf = $conf['auth']['ad'];
+ // additional information fields
+ if (isset($this->cnf['additional'])) {
+ $this->cnf['additional'] = str_replace(' ', '', $this->cnf['additional']);
+ $this->cnf['additional'] = explode(',', $this->cnf['additional']);
+ } else $this->cnf['additional'] = array();
+
// ldap extension is needed
if (!function_exists('ldap_connect')) {
if ($this->cnf['debug'])
@@ -131,15 +141,27 @@ class auth_ad extends auth_basic {
global $conf;
if(!$this->_init()) return false;
- //get info for given user
- $result = $this->adldap->user_info($user);
+ $fields = array('mail','displayname','samaccountname');
+
+ // add additional fields to read
+ $fields = array_merge($fields, $this->cnf['additional']);
+ $fields = array_unique($fields);
+ //get info for given user
+ $result = $this->adldap->user_info($user, $fields);
//general user info
$info['name'] = $result[0]['displayname'][0];
$info['mail'] = $result[0]['mail'][0];
$info['uid'] = $result[0]['samaccountname'][0];
$info['dn'] = $result[0]['dn'];
+ // additional informations
+ foreach ($this->cnf['additional'] as $field) {
+ if (isset($result[0][strtolower($field)])) {
+ $info[$field] = $result[0][strtolower($field)][0];
+ }
+ }
+
// handle ActiveDirectory memberOf
$info['grps'] = $this->adldap->user_groups($user,(bool) $this->opts['recursive_groups']);