fix : Tests for attributes exsitence in Use of posixAccount and posixGroup objectclass for users and groups in LDAP

This commit is contained in:
Abbes Bahfir 2019-09-12 11:18:22 +01:00
parent 5183a1ec7a
commit 195ac8e8f6
2 changed files with 14 additions and 10 deletions

View File

@ -2657,17 +2657,19 @@ class User extends CommonObject
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
}
$info[$conf->global->LDAP_FIELD_USERID] = $this->id;
$info[$conf->global->LDAP_FIELD_GROUPID] = '1';
$usergroup = new UserGroup($this->db);
$groupslist = $usergroup->listGroupsForUser($this->id);
if(!empty($groupslist)){
foreach ($groupslist as $groupforuser) {
$info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id;//Select first group in list
break;
if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id;
if(!empty($info[$conf->global->LDAP_FIELD_GROUPID])){
$usergroup = new UserGroup($this->db);
$groupslist = $usergroup->listGroupsForUser($this->id);
$info[$conf->global->LDAP_FIELD_GROUPID] = '1';
if(!empty($groupslist)){
foreach ($groupslist as $groupforuser) {
$info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id;//Select first group in list
break;
}
}
}
$info[$conf->global->LDAP_FIELD_HOMEDIRECTORY]="{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname";
if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY]="{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname";
return $info;
}

View File

@ -981,7 +981,9 @@ class UserGroup extends CommonObject
$info[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
}
$info[$conf->global->LDAP_FIELD_GROUPID]=$this->id;
if(!empty($info[$conf->global->LDAP_FIELD_GROUPID])){
$info[$conf->global->LDAP_FIELD_GROUPID]=$this->id;
}
return $info;
}