[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc/accounts/class.accounts_ldap.inc.php, 1
From: |
nomail |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc/accounts/class.accounts_ldap.inc.php, 1.1.2.2 |
Date: |
Tue, 14 Dec 2004 21:11:01 +0100 |
Update of /phpgwapi/inc/accounts
Modified Files:
Branch: proposed-0_9_18-branch
class.accounts_ldap.inc.php
date: 2004/12/14 20:11:01; author: fipsfuchs; state: Exp; lines: +21 -112
Log Message:
moved common stuff from childs to parent
smarter rdn handling for ldap
=====================================================================
Index: phpgwapi/inc/accounts/class.accounts_ldap.inc.php
diff -u phpgwapi/inc/accounts/class.accounts_ldap.inc.php:1.1.2.1
phpgwapi/inc/accounts/class.accounts_ldap.inc.php:1.1.2.2
--- phpgwapi/inc/accounts/class.accounts_ldap.inc.php:1.1.2.1 Fri Dec 10
15:28:40 2004
+++ phpgwapi/inc/accounts/class.accounts_ldap.inc.php Tue Dec 14 20:11:01 2004
@@ -33,6 +33,7 @@
/**
* @internal Be Carefull to correctly set the following!
* @internal Need to be set in the setup system! (Caeies)
+ * @internal Be very carefull - it will certainly break the
account system
*/
var $rdn_account = 'uid';
var $rdn_group = 'cn';
@@ -334,7 +335,7 @@
*/
function groupName2id($name)
{
- $sri = ldap_search($this->ds, $this->group_context,
'(&(cn='. $name .')(objectclass=phpgwgroup))');
+ $sri = ldap_search($this->ds, $this->group_context,
'(&('.$this->rdn_group.'='. $name .')(objectclass=phpgwgroup))');
$allValues = ldap_get_entries($this->ds, $sri);
if (@$allValues[0]['gidnumber'][0])
@@ -355,7 +356,7 @@
*/
function accountName2id($name)
{
- $sri = ldap_search($this->ds, $this->user_context,
'(&(uid='. $name .')(objectclass=phpgwaccount))');
+ $sri = ldap_search($this->ds, $this->user_context,
'(&('.$this->rdn_account.'='. $name .')(objectclass=phpgwaccount))');
$allValues = ldap_get_entries($this->ds, $sri);
if (@$allValues[0]['uidnumber'][0])
@@ -671,34 +672,26 @@
* @param string $default_prefs Unused
* @return array|boolean Id of the newly created account or
false
*/
- function create($account_info,$default_prefs = true)
+ function create($account_info, $default_prefs = true)
{
- //parent::create($account_info, $default_prefs);
if (empty($account_info['account_id']) ||
!$account_info['account_id'])
{
$account_info['account_id'] =
$this->get_nextid($account_info['account_type']);
}
if ($account_info['account_type'] == 'u')
{
- /* this line is not working
- $account_info['person_id'] =
$this->save_contact_for_account($this->data);
- */
- $this->create_account($account_info,
$default_prefs);
+ $this->create_account($account_info);
}
elseif($account_info['account_type'] == 'g')
{
- $this->create_group($account_info,
$default_prefs);
+ $this->create_group($account_info);
}
else
{
return false;
}
- if($account_info['account_id'] &&
is_object($GLOBALS['phpgw']->preferences) && $default_prefs)
- {
-
$GLOBALS['phpgw']->preferences->create_defaults($account_info['account_id']);
- }
- return $account_info['account_id'];
+ return parent::create($account_info, $default_prefs);
}
/**
@@ -707,7 +700,7 @@
* @param array $account_info Account information: account_id,
account_expires, account_status, lastlogin, lastloginfrom, lastpasswd_change,
account_firstname, account_lastname, account_passwd, homedirectory, ...
* @param string $default_prefs Unused
*/
- function create_account($account_info, $default_prefs)
+ function create_account($account_info)
{
$dn = $this->rdn_account .
'=' .
@@ -885,18 +878,18 @@
}
}
ldap_delete($this->ds,
$oldEntry['dn']);
-
$this->add_LDAP_Entry($oldEntry['dn'], $entry);
+ return
$this->add_LDAP_Entry($oldEntry['dn'], $entry);
}
else
{
-
$this->modify_LDAP_Entry($oldEntry['dn'], $entry);
+ return
$this->modify_LDAP_Entry($oldEntry['dn'], $entry);
}
$dn = $oldEntry['dn'];
}
}
else // entry not yet in LDAP
{
- $this->add_LDAP_Entry($dn, $entry);
+ return $this->add_LDAP_Entry($dn, $entry);
}
}
@@ -906,7 +899,7 @@
* @param array $account_info Group information: account_id,
account_lid, ...
* @param string $default_prefs Unused
*/
- function create_group($account_info, $default_prefs)
+ function create_group($account_info)
{
$dn = $this->rdn_group . '=' .
$account_info['account_lid'] . ',' . $this->group_context;
@@ -1076,82 +1069,6 @@
}
}
}
-
-
- /**
- * Create a non existing but authorized user
- *
- * @param string $accountname User name
- * @param string $passwd User password
- * @param boolean $default_prefs Default preferences for this
new user
- * @param boolean $default_acls Acls (modules) for this new user
- * @param integer $expiredate Expire date of this account. '-1'
for never. Defaults to 'in 30 days'
- * @param char $account_status Status for new user. 'A' for
active user.
- * @return integer Account id
- */
- function auto_add($accountname, $passwd, $default_prefs =
false, $default_acls = false, $expiredate = 0, $account_status = 'A')
- {
- if ($expiredate)
- {
- $expires = mktime(2,0,0,date('n',$expiredate),
intval(date('d',$expiredate)), date('Y',$expiredate));
- }
- else
- {
-
if($GLOBALS['phpgw_info']['server']['auto_create_expire'])
- {
-
if($GLOBALS['phpgw_info']['server']['auto_create_expire'] == 'never')
- {
- $expires = -1;
- }
- else
- {
- $expiredate = time() +
$GLOBALS['phpgw_info']['server']['auto_create_expire'];
- $expires =
mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)),
date('Y',$expiredate));
- }
- }
- else
- {
- /* expire in 30 days by default */
- $expiredate = time() + ( ( 60 * 60 ) *
(30 * 24) );
- $expires =
mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)),
date('Y',$expiredate));
- }
- }
-
- $acct_info = array(
- 'account_id' => $this->get_nextid('u'),
//'u' for account
- 'account_lid' => $accountname,
- 'account_passwd' => $passwd,
- 'account_firstname' => 'New',
- 'account_lastname' => 'User',
- 'account_status' => $account_status,
- 'account_expires' => $expires
- );
- $this->create_account($acct_info, $default_prefs);
- $accountid = $this->accountName2id($accountname);
-
- $this->db->transaction_begin();
- if ($default_acls == false)
- {
- $apps = $this->fallback_apps;
-
- $default_group_lid =
$GLOBALS['phpgw_info']['server']['default_group_lid'];
- $default_group_id =
$this->groupName2id($default_group_lid);
- $defaultgroupid = $default_group_id ?
$default_group_id : $this->groupName2id('Default');
- if($defaultgroupid)
- {
- $this->db->query("INSERT INTO phpgw_acl
(acl_appname, acl_location, acl_account, acl_rights) values('phpgw_group', "
- . $defaultgroupid . ', ' .
$accountid . ', 1)',__LINE__,__FILE__);
- }
- $this->db->query("INSERT INTO phpgw_acl
(acl_appname, acl_location, acl_account, acl_rights)values('preferences',
'changepassword', ".$accountid.", 1)",__LINE__,__FILE__);
- @reset($apps);
- while(list($key,$app) = each($apps))
- {
- $this->db->query("INSERT INTO phpgw_acl
(acl_appname, acl_location, acl_account, acl_rights) VALUES ('".$app."', 'run',
".$accountid.", 1)",__LINE__,__FILE__);
- }
- }
- $this->db->transaction_commit();
- return $accountid;
- }
function get_account_name($accountid,&$lid,&$fname,&$lname)
{
@@ -1196,20 +1113,6 @@
return;
}
- function get_account_data($account_id)
- {
- $this->account_id = $account_id;
- $this->read_repository();
-
- $data[$this->data['account_id']]['lid'] =
$this->data['account_lid'];
- $data[$this->data['account_id']]['firstname'] =
$this->data['account_firstname'];
- $data[$this->data['account_id']]['lastname'] =
$this->data['account_lastname'];
- $data[$this->data['account_id']]['fullname'] =
$this->data['fullname'];
- $data[$this->data['account_id']]['type'] =
$this->data['type'];
- $data[$this->data['account_id']]['person_id'] =
$this->data['person_id'];
- return $data;
- }
-
/**
* Get the DN for the given account id
*
@@ -1319,12 +1222,18 @@
*/
function idTester($IDs, $min = 1, $max = 0)
{
-
$interval = intval($max) - intval($min);
$base = intval($min) ? intval($min) : 1;
if ($interval > 0)
{
- $pointer = $start =
$IDs[count($IDs)-1]%$interval;
+ if($IDs[count($IDs)-1] < $base ) // still,
there are low ids
+ {
+ $pointer = $start =
($IDs[count($IDs)-1] - 0 ) % $interval;
+ }
+ else
+ {
+ $pointer = $start =
($IDs[count($IDs)-1] - $base ) % $interval;
+ }
}
else
{
@@ -1336,7 +1245,7 @@
{
if ($interval > 0)
{
- $pointer =
($pointer+1)%$interval;
+ $pointer = ($pointer+1) %
$interval;
if ($pointer == $start)
{
die('no free id found');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc/accounts/class.accounts_ldap.inc.php, 1.1.2.2,
nomail <=