added generated default user name
This commit is contained in:
parent
20a7f923bd
commit
3fae8d2611
|
@ -1,6 +1,7 @@
|
||||||
March 2010 3.0.0
|
March 2010 3.0.0
|
||||||
- support to remove extension from an existing account: shadowAccount, sambaSamAccount, eduPerson
|
- support to remove extension from an existing account: shadowAccount, sambaSamAccount, eduPerson
|
||||||
- removed frames
|
- removed frames
|
||||||
|
- Unix: automatic user name generation from first and last name (2492675)
|
||||||
- fixed bugs:
|
- fixed bugs:
|
||||||
-> Multi-delete not working (2931458)
|
-> Multi-delete not working (2931458)
|
||||||
-> Samba: can/must change password needs to be read from domain policy (2919236)
|
-> Samba: can/must change password needs to be read from domain policy (2919236)
|
||||||
|
|
|
@ -706,8 +706,24 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
unset($this->attributes['userPassword']);
|
unset($this->attributes['userPassword']);
|
||||||
}
|
}
|
||||||
$this->attributes['uid'][0] = $_POST['uid'];
|
$this->attributes['uid'][0] = $_POST['uid'];
|
||||||
|
$setDefaultUserName = false;
|
||||||
|
if (($this->attributes['uid'][0] == '') && ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null)) {
|
||||||
|
// fill default value for user ID with first/last name
|
||||||
|
$attrs = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
|
||||||
|
if (isset($attrs['sn'][0])) {
|
||||||
|
if (isset($attrs['givenName'])) {
|
||||||
|
$this->attributes['uid'][0] = preg_replace('/[^a-z0-9_-]/', '', strtolower($attrs['givenName'][0][0] . $attrs['sn'][0]));
|
||||||
|
$setDefaultUserName = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->attributes['uid'][0] = preg_replace('/[^a-z0-9_-]/', '', strtolower($attrs['sn'][0]));
|
||||||
|
$setDefaultUserName = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->attributes['cn'][0] = $_POST['cn'];
|
$this->attributes['cn'][0] = $_POST['cn'];
|
||||||
if ($this->attributes['cn'][0] == '') {
|
if ($this->attributes['cn'][0] == '') {
|
||||||
|
// set a default value for common name
|
||||||
if (($this->get_scope() == 'host') && (substr($_POST['uid'], -1, 1) == '$')) {
|
if (($this->get_scope() == 'host') && (substr($_POST['uid'], -1, 1) == '$')) {
|
||||||
$this->attributes['cn'][0] = substr($_POST['uid'], 0, strlen($_POST['uid']) - 1);
|
$this->attributes['cn'][0] = substr($_POST['uid'], 0, strlen($_POST['uid']) - 1);
|
||||||
}
|
}
|
||||||
|
@ -809,10 +825,11 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
// Create automatic useraccount with number if original user already exists
|
// Create automatic useraccount with number if original user already exists
|
||||||
// Reset name to original name if new name is in use
|
// Reset name to original name if new name is in use
|
||||||
// Set username back to original name if new username is in use
|
// Set username back to original name if new username is in use
|
||||||
if ((sizeof(searchLDAPByAttribute('uid', $this->attributes['uid'][0], 'posixAccount', array('uid'), array('user', 'host'))) > 0) && ($this->orig['uid'][0]!=''))
|
if ((sizeof(searchLDAPByAttribute('uid', $this->attributes['uid'][0], 'posixAccount', array('uid'), array('user', 'host'))) > 0) && ($this->orig['uid'][0]!='')) {
|
||||||
$this->attributes['uid'][0] = $this->orig['uid'][0];
|
$this->attributes['uid'][0] = $this->orig['uid'][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Change uid to a new uid until a free uid is found
|
// Change uid to a new uid until a free uid is found
|
||||||
else
|
|
||||||
while (sizeof(searchLDAPByAttribute('uid', $this->attributes['uid'][0], 'posixAccount', array('uid'), array('user', 'host'))) > 0) {
|
while (sizeof(searchLDAPByAttribute('uid', $this->attributes['uid'][0], 'posixAccount', array('uid'), array('user', 'host'))) > 0) {
|
||||||
if ($this->get_scope()=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1);
|
if ($this->get_scope()=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1);
|
||||||
// get last character of username
|
// get last character of username
|
||||||
|
@ -848,8 +865,9 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
else $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1);
|
else $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Show warning if lam has changed username
|
// Show warning if lam has changed username
|
||||||
if ($this->attributes['uid'][0] != $_POST['uid']) {
|
if (!$setDefaultUserName && ($this->attributes['uid'][0] != $_POST['uid'])) {
|
||||||
if ($this->get_scope()=='user') $errors[] = $this->messages['uid'][5];
|
if ($this->get_scope()=='user') $errors[] = $this->messages['uid'][5];
|
||||||
if ($this->get_scope()=='host') $errors[] = $this->messages['uid'][6];
|
if ($this->get_scope()=='host') $errors[] = $this->messages['uid'][6];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue