fill default user name from AD module

This commit is contained in:
Roland Gruber 2013-12-28 10:48:31 +00:00
parent 7538def6f7
commit 25d6611231
1 changed files with 14 additions and 4 deletions

View File

@ -1297,11 +1297,21 @@ class posixAccount extends baseModule implements passwordService {
$shelllist = $this->getShells(); // list of all valid shells
// set default values
if (!isset($this->attributes['uid'][0]) && ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null)) {
if (empty($this->attributes['uid'][0])) {
if ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) {
// fill default value for user ID with first/last name
$attrs = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
$this->attributes['uid'][0] = $this->getUserNameSuggestion($attrs);
}
elseif ($this->getAccountContainer()->getAccountModule('windowsUser') != null) {
// fill default value for user ID with AD user name
$attrs = $this->getAccountContainer()->getAccountModule('windowsUser')->getAttributes();
if (!empty($attrs['userPrincipalName'][0])) {
$parts = explode('@', $attrs['userPrincipalName'][0]);
$this->attributes['uid'][0] = $parts[0];
}
}
}
if ($this->manageCn() && (!isset($this->attributes['cn'][0]) || ($this->attributes['cn'][0] == ''))) {
// set a default value for common name
if (($this->get_scope() == 'host') && isset($_POST['uid']) && (substr($_POST['uid'], -1, 1) == '$')) {