fixed internal problem with references

This commit is contained in:
katagia 2003-12-30 17:09:15 +00:00
parent ff1ceeac80
commit 193ae2c571
8 changed files with 40 additions and 33 deletions

View File

@ -47,9 +47,8 @@ class account {
if (!is_string($base)) trigger_error(_('Please create a new module object with $accountContainer->add_objectClass(\'account\');'), E_USER_ERROR); if (!is_string($base)) trigger_error(_('Please create a new module object with $accountContainer->add_objectClass(\'account\');'), E_USER_ERROR);
if ($_SESSION[$this->base]->get_type() != 'host') trigger_error(_('account can only be used for hosts.'), E_USER_WARNING); if ($_SESSION[$this->base]->get_type() != 'host') trigger_error(_('account can only be used for hosts.'), E_USER_WARNING);
// load attribtues which are used in account objectClass // load attribtues which are used in account objectClass
$this->orig = $_SESSION[$this->base]->get_module_attributes('account');
$this->attributes = $_SESSION[$this->base]->get_module_attributes('account'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('account');
// Create copy of attributes
$this->orig = $this->attributes ;
// Add objectClass to attributes // Add objectClass to attributes
$this->attributes['objectClass'][0] = 'account'; $this->attributes['objectClass'][0] = 'account';
} }
@ -103,6 +102,7 @@ class account {
* $attr is an array as it's retured from ldap_get_attributes * $attr is an array as it's retured from ldap_get_attributes
*/ */
function load_attributes($attr) { function load_attributes($attr) {
// Load attributes which are displayed
// unset count entries // unset count entries
unset ($attr['count']); unset ($attr['count']);
$attributes = array_keys($attr); $attributes = array_keys($attr);
@ -110,18 +110,18 @@ class account {
// unset double entries // unset double entries
for ($i=0; $i<count($attr); $i++) for ($i=0; $i<count($attr); $i++)
if (isset($attr[$i])) unset($attr[$i]); if (isset($attr[$i])) unset($attr[$i]);
// load attribtues
foreach ($attributes as $attribute) { foreach ($attributes as $attribute) {
if (isset($this->orig[$attribute])) { if (isset($this->attributes[$attribute])) {
$this->orig[$attribute] = $attr[$attribute];
// decode as unicode // decode as unicode
for ($i=0; $i<count($this->orig[$attribute]); $i++) $this->orig[$attribute][$i] = utf8_decode ($this->orig[$attribute][$i]); $this->attributes[$attribute] = $attr[$attribute];
for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
}
} }
} }
// Add objectClass to orig because we don't want to add objectClass if it's already set // Add objectClass to orig because we don't want to add objectClass if it's already set
$this->orig['objectClass'][0] = 'account'; $this->orig['objectClass'][0] = 'account';
// Values are kept as copy so we can compare old attributes with new attributes
$this->attributes = $this->orig;
return 0; return 0;
} }

View File

@ -102,6 +102,7 @@ class inetOrgPerson {
* $attr is an array as it's retured from ldap_get_attributes * $attr is an array as it's retured from ldap_get_attributes
*/ */
function load_attributes($attr) { function load_attributes($attr) {
// Load attributes which are displayed
// unset count entries // unset count entries
unset ($attr['count']); unset ($attr['count']);
$attributes = array_keys($attr); $attributes = array_keys($attr);
@ -109,18 +110,18 @@ class inetOrgPerson {
// unset double entries // unset double entries
for ($i=0; $i<count($attr); $i++) for ($i=0; $i<count($attr); $i++)
if (isset($attr[$i])) unset($attr[$i]); if (isset($attr[$i])) unset($attr[$i]);
// load attribtues
foreach ($attributes as $attribute) { foreach ($attributes as $attribute) {
if (isset($this->orig[$attribute])) { if (isset($this->attributes[$attribute])) {
$this->orig[$attribute] = $attr[$attribute];
// decode as unicode // decode as unicode
for ($i=0; $i<count($this->orig[$attribute]); $i++) $this->orig[$attribute][$i] = utf8_decode ($this->orig[$attribute][$i]); $this->attributes[$attribute] = $attr[$attribute];
for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
}
} }
} }
// Add objectClass to orig because we don't want to add objectClass if it's already set // Add objectClass to orig because we don't want to add objectClass if it's already set
$this->orig['objectClass'][0] = 'inetOrgPerson'; $this->orig['objectClass'][0] = 'inetOrgPerson';
// Values are kept as copy so we can compare old attributes with new attributes
$this->attributes = $this->orig;
return 0; return 0;
} }

View File

@ -69,8 +69,8 @@ class posixAccount {
if (!isset($_SESSION[$this->base]->module['inetOrgPerson']) && $_SESSION[$this->base]->type=='user') $_SESSION[$this->base]->add_objectClass('inetOrgPerson'); if (!isset($_SESSION[$this->base]->module['inetOrgPerson']) && $_SESSION[$this->base]->type=='user') $_SESSION[$this->base]->add_objectClass('inetOrgPerson');
if (!isset($_SESSION[$this->base]->module['account']) && $_SESSION[$this->base]->type=='host') $_SESSION[$this->base]->add_objectClass('account'); if (!isset($_SESSION[$this->base]->module['account']) && $_SESSION[$this->base]->type=='host') $_SESSION[$this->base]->add_objectClass('account');
// Add Array with all attributes and type // Add Array with all attributes and type
$this->orig = $_SESSION[$this->base]->get_module_attributes('posixAccount');
$this->attributes = $_SESSION[$this->base]->get_module_attributes('posixAccount'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('posixAccount');
$_SESSION[$this->base]->add_attributes ('posixAccount');
$this->alias = _('posixAccount'); $this->alias = _('posixAccount');
$groups = $_SESSION[$_SESSION[$this->base]->cache]->findgroups(); // list of all groupnames $groups = $_SESSION[$_SESSION[$this->base]->cache]->findgroups(); // list of all groupnames
@ -83,7 +83,6 @@ class posixAccount {
foreach ($newattributes as $attribute) foreach ($newattributes as $attribute)
if (isset($_SESSION[$this->base]->module[$module[$i]]->attributes[$attribute])) $this->attributes[$attribute] =& $_SESSION[$this->base]->module[$module[$i]]->attributes[$attribute]; if (isset($_SESSION[$this->base]->module[$module[$i]]->attributes[$attribute])) $this->attributes[$attribute] =& $_SESSION[$this->base]->module[$module[$i]]->attributes[$attribute];
} }
$this->orig = $this->attributes ;
$this->attributes['objectClass'][0] = 'posixAccount'; $this->attributes['objectClass'][0] = 'posixAccount';
$this->createhomedir=false; $this->createhomedir=false;
} }
@ -191,12 +190,14 @@ class posixAccount {
if (isset($this->attributes[$attribute])) { if (isset($this->attributes[$attribute])) {
// decode as unicode // decode as unicode
$this->attributes[$attribute] = $attr[$attribute]; $this->attributes[$attribute] = $attr[$attribute];
for ($i=0; $i<count($this->attributes[$attribute]); $i++) $this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]); for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
}
} }
} }
// Values are kept as copy so we can compare old attributes with new attributes // Values are kept as copy so we can compare old attributes with new attributes
$this->attributes['objectClass'][0] = 'posixAccount'; $this->attributes['objectClass'][0] = 'posixAccount';
$this->orig = $this->attributes;
// get all additional groupmemberships // get all additional groupmemberships
$dn_groups = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('memberUid', 'posixGroup', 'group'); $dn_groups = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('memberUid', 'posixGroup', 'group');
@ -535,9 +536,6 @@ class posixAccount {
* It will output a complete html-table * It will output a complete html-table
*/ */
function display_html_attributes($post) { function display_html_attributes($post) {
print_r($this->attributes);
print "<br>";
print_r($this->attributes);
$groups = $_SESSION[$_SESSION[$this->base]->cache]->findgroups(); // list of all groupnames $groups = $_SESSION[$_SESSION[$this->base]->cache]->findgroups(); // list of all groupnames
$shelllist = getshells(); // list of all valid shells $shelllist = getshells(); // list of all valid shells
if ($this->attributes['userPassword'][0] != $this->orig['userPassword'][0]) $password=$this->userPassword(); if ($this->attributes['userPassword'][0] != $this->orig['userPassword'][0]) $password=$this->userPassword();

View File

@ -178,12 +178,14 @@ class posixGroup {
if (isset($this->attributes[$attribute])) { if (isset($this->attributes[$attribute])) {
// decode as unicode // decode as unicode
$this->attributes[$attribute] = $attr[$attribute]; $this->attributes[$attribute] = $attr[$attribute];
for ($i=0; $i<count($this->attributes[$attribute]); $i++) $this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]); for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
}
} }
} }
// Values are kept as copy so we can compare old attributes with new attributes // Values are kept as copy so we can compare old attributes with new attributes
$this->attributes['objectClass'][0] = 'posixGroup'; $this->attributes['objectClass'][0] = 'posixGroup';
$this->orig = $this->attributes;
return 0; return 0;
} }

View File

@ -181,13 +181,14 @@ class sambaAccount {
if (isset($this->attributes[$attribute])) { if (isset($this->attributes[$attribute])) {
// decode as unicode // decode as unicode
$this->attributes[$attribute] = $attr[$attribute]; $this->attributes[$attribute] = $attr[$attribute];
for ($i=0; $i<count($this->attributes[$attribute]); $i++) $this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]); for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
}
} }
} }
// Values are kept as copy so we can compare old attributes with new attributes // Values are kept as copy so we can compare old attributes with new attributes
$this->attributes['objectClass'][0] = 'sambaAccount'; $this->attributes['objectClass'][0] = 'sambaAccount';
$this->orig = $this->attributes;
$this->lmPassword(''); // Remove old password so it won't displayed as hash
return 0; return 0;
} }

View File

@ -142,12 +142,14 @@ class sambaGroupMapping {
if (isset($this->attributes[$attribute])) { if (isset($this->attributes[$attribute])) {
// decode as unicode // decode as unicode
$this->attributes[$attribute] = $attr[$attribute]; $this->attributes[$attribute] = $attr[$attribute];
for ($i=0; $i<count($this->attributes[$attribute]); $i++) $this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]); for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
}
} }
} }
// Values are kept as copy so we can compare old attributes with new attributes // Values are kept as copy so we can compare old attributes with new attributes
$this->attributes['objectClass'][0] = 'sambaGroupMapping'; $this->attributes['objectClass'][0] = 'sambaGroupMapping';
$this->orig = $this->attributes;
return 0; return 0;
} }

View File

@ -182,13 +182,14 @@ class sambaSamAccount {
if (isset($this->attributes[$attribute])) { if (isset($this->attributes[$attribute])) {
// decode as unicode // decode as unicode
$this->attributes[$attribute] = $attr[$attribute]; $this->attributes[$attribute] = $attr[$attribute];
for ($i=0; $i<count($this->attributes[$attribute]); $i++) $this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]); for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
}
} }
} }
// Values are kept as copy so we can compare old attributes with new attributes // Values are kept as copy so we can compare old attributes with new attributes
$this->attributes['objectClass'][0] = 'sambaSamAccount'; $this->attributes['objectClass'][0] = 'sambaSamAccount';
$this->orig = $this->attributes;
$this->sambaLMPassword(''); // Remove old password so it won't displayed as hash
return 0; return 0;
} }

View File

@ -135,12 +135,14 @@ class shadowAccount {
if (isset($this->attributes[$attribute])) { if (isset($this->attributes[$attribute])) {
// decode as unicode // decode as unicode
$this->attributes[$attribute] = $attr[$attribute]; $this->attributes[$attribute] = $attr[$attribute];
for ($i=0; $i<count($this->attributes[$attribute]); $i++) $this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]); for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
}
} }
} }
// Values are kept as copy so we can compare old attributes with new attributes // Values are kept as copy so we can compare old attributes with new attributes
$this->attributes['objectClass'][0] = 'shadowAccount'; $this->attributes['objectClass'][0] = 'shadowAccount';
$this->orig = $this->attributes;
} }
/* This function returns an array with 3 entries: /* This function returns an array with 3 entries: