allow to use homedirectory attribute from LDAP or ADS authentication for VFS mounts

This commit is contained in:
Ralf Becker 2011-11-15 12:43:59 +00:00
parent 988123bb73
commit 8ab9b0d2f2
4 changed files with 21 additions and 6 deletions

View File

@ -56,7 +56,7 @@ class auth_ads implements auth_backend
}
//echo "<p>Bind with '$username@".$GLOBALS['egw_info']['server']['ads_domain']."' with PW '$passwd'.</p>\n";
$attributes = array('samaccountname','givenName','sn','mail');
$attributes = array('samaccountname','givenName','sn','mail','homeDirectory');
$filter = "(samaccountname=$username)";
// automatic create dn from domain: domain.com ==> DC=domain,DC=com
$base_dn = array();
@ -84,10 +84,15 @@ class auth_ads implements auth_backend
{
return $GLOBALS['egw']->accounts->id2name($id,'account_status') == 'A';
}
// store homedirectory for egw_session->read_repositories
$GLOBALS['auto_create_acct'] = array();
if (isset($allValues[0]['homedirectory']))
{
$GLOBALS['auto_create_acct']['homedirectory'] = $allValues[0]['homedirectory'];
}
if ($GLOBALS['egw_info']['server']['auto_create_acct'])
{
// create a global array with all availible info about that account
$GLOBALS['auto_create_acct'] = array();
foreach(array(
'givenname' => 'firstname',
'sn' => 'lastname',

View File

@ -54,7 +54,7 @@ class auth_ldap implements auth_backend
return False;
}
/* find the dn for this uid, the uid is not always in the dn */
$attributes = array('uid','dn','givenName','sn','mail','uidNumber','shadowExpire');
$attributes = array('uid','dn','givenName','sn','mail','uidNumber','shadowExpire','homeDirectory');
$filter = $GLOBALS['egw_info']['server']['ldap_search_filter'] ? $GLOBALS['egw_info']['server']['ldap_search_filter'] : '(uid=%user)';
$filter = str_replace(array('%user','%domain'),array(ldap::quote($username),$GLOBALS['egw_info']['user']['domain']),$filter);
@ -88,13 +88,18 @@ class auth_ldap implements auth_backend
{
if ($GLOBALS['egw_info']['server']['account_repository'] != 'ldap')
{
// store homedirectory for egw_session->read_repositories
$GLOBALS['auto_create_acct'] = array();
if (isset($allValues[0]['homedirectory']))
{
$GLOBALS['auto_create_acct']['homedirectory'] = $allValues[0]['homedirectory'];
}
if (!($id = $GLOBALS['egw']->accounts->name2id($username,'account_lid','u')))
{
// account does NOT exist, check if we should create it
if ($GLOBALS['egw_info']['server']['auto_create_acct'])
{
// create a global array with all availible info about that account
$GLOBALS['auto_create_acct'] = array();
foreach(array(
'givenname' => 'firstname',
'sn' => 'lastname',

View File

@ -1079,7 +1079,7 @@ class egw_session
// append the url to the webserver url, but avoid more then one slash between the parts of the url
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
// patch inspired by vladimir kolobkov -> we should not try to match the webserver url against the url without '/' as delimiter,
// patch inspired by vladimir kolobkov -> we should not try to match the webserver url against the url without '/' as delimiter,
// as $webserver_url may be part of $url (as /egw is part of phpgwapi/js/egw_instant_load.html)
if (($url[0] != '/' || $webserver_url != '/') && (!$webserver_url || strpos($url, $webserver_url.'/') === false))
{
@ -1429,6 +1429,11 @@ class egw_session
$GLOBALS['egw']->applications->applications($this->account_id);
$this->user = $GLOBALS['egw']->accounts->read_repository();
// set homedirectory from auth_ldap or auth_ads, to be able to use it in vfs
if (!isset($this->user['homedirectory']) && isset($GLOBALS['auto_create_acct']['homedirectory']))
{
$this->user['homedirectory'] = $GLOBALS['auto_create_acct']['homedirectory'];
}
$this->user['acl'] = $GLOBALS['egw']->acl->read_repository();
$this->user['preferences'] = $GLOBALS['egw']->preferences->read_repository();
if (is_object($GLOBALS['egw']->datetime))

View File

@ -194,7 +194,7 @@ class vfs_stream_wrapper implements iface_stream_wrapper
'user' => $GLOBALS['egw_info']['user']['account_lid'],
'pass' => $GLOBALS['egw_info']['user']['passwd'],
'host' => $GLOBALS['egw_info']['user']['domain'],
'home' => $GLOBALS['egw_info']['user']['homedirectory'],
'home' => str_replace(array('\\\\','\\'),array('','/'),$GLOBALS['egw_info']['user']['homedirectory']),
);
}
$parts = array_merge(parse_url($path),$defaults);