easier switching to long user name suggestion
This commit is contained in:
parent
ed42627653
commit
0a5743b0ff
|
@ -52,6 +52,8 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
private $clearTextPassword;
|
private $clearTextPassword;
|
||||||
/** caches the list of known UIDs */
|
/** caches the list of known UIDs */
|
||||||
private $cachedUIDList = null;
|
private $cachedUIDList = null;
|
||||||
|
/** if set to true the suggested user name for John Doe will be john.doe instead of jdoe */
|
||||||
|
private $SUGGEST_LONG_USER_NAME = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function fills the error message array with messages.
|
* This function fills the error message array with messages.
|
||||||
|
@ -897,14 +899,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
if (!isset($this->attributes['uid'][0]) && ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null)) {
|
if (!isset($this->attributes['uid'][0]) && ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null)) {
|
||||||
// fill default value for user ID with first/last name
|
// fill default value for user ID with first/last name
|
||||||
$attrs = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
|
$attrs = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
|
||||||
if (isset($attrs['sn'][0])) {
|
$this->attributes['uid'][0] = $this->getUserNameSuggestion($attrs);
|
||||||
if (isset($attrs['givenName'][0]) && ($attrs['givenName'][0] != '')) {
|
|
||||||
$this->attributes['uid'][0] = preg_replace('/[^a-z0-9_-]/', '', strtolower($attrs['givenName'][0][0] . $attrs['sn'][0]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->attributes['uid'][0] = preg_replace('/[^a-z0-9_-]/', '', strtolower($attrs['sn'][0]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!isset($this->attributes['cn'][0]) || ($this->attributes['cn'][0] == '')) {
|
if (!isset($this->attributes['cn'][0]) || ($this->attributes['cn'][0] == '')) {
|
||||||
// set a default value for common name
|
// set a default value for common name
|
||||||
|
@ -1844,6 +1839,30 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
return $this->cachedUIDList;
|
return $this->cachedUIDList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a suggestion for the user name.
|
||||||
|
* By deafult this wil be the first character of the first name plus the last name.
|
||||||
|
*
|
||||||
|
* @param array $attrs LDAP attributes
|
||||||
|
* @return String user name
|
||||||
|
*/
|
||||||
|
private function getUserNameSuggestion($attrs) {
|
||||||
|
if (isset($attrs['sn'][0])) {
|
||||||
|
if (isset($attrs['givenName'][0]) && ($attrs['givenName'][0] != '')) {
|
||||||
|
if ($this->SUGGEST_LONG_USER_NAME) {
|
||||||
|
return preg_replace('/[^a-z0-9_\\.-]/', '', strtolower($attrs['givenName'][0] . '.' . $attrs['sn'][0]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return preg_replace('/[^a-z0-9_-]/', '', strtolower($attrs['givenName'][0][0] . $attrs['sn'][0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return preg_replace('/[^a-z0-9_-]/', '', strtolower($attrs['sn'][0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue