Merge pull request #11868 from bafbes/abb100077
New : Use of posixAccount and posixGroup objectclass for users and groups in LDAP
This commit is contained in:
commit
4d1d689fc8
@ -58,6 +58,7 @@ if ($action == 'setvalue' && $user->admin)
|
||||
//if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
|
||||
// This one must be after the others
|
||||
$valkey='';
|
||||
@ -170,6 +171,13 @@ print '</td><td>'.$langs->trans("LDAPFieldGroupMembersExample").'</td>';
|
||||
print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)?' checked':'')."></td>";
|
||||
print '</tr>';
|
||||
|
||||
// Group id
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldGroupid").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldgroupid" value="'.$conf->global->LDAP_GROUP_FIELD_GROUPID.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldGroupidExample").'</td>';
|
||||
print '<td class="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print info_admin($langs->trans("LDAPDescValues"));
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2005 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -73,6 +74,10 @@ if ($action == 'setvalue' && $user->admin)
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), 'chaine', 0, '', $conf->entity)) $error++;
|
||||
|
||||
// This one must be after the others
|
||||
$valkey='';
|
||||
@ -301,6 +306,34 @@ print '</td><td>'.$langs->trans("LDAPFieldSidExample").'</td>';
|
||||
print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_SID"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_SID)?' checked':'')."></td>";
|
||||
print '</tr>';
|
||||
|
||||
// Group id
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldGroupid").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldgroupid" value="'.$conf->global->LDAP_FIELD_GROUPID.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldGroupidExample").'</td>';
|
||||
print '<td class="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Userid
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldUserid").'</td><td>';
|
||||
print '<input size="25" type="text" name="fielduserid" value="'.$conf->global->LDAP_FIELD_USERID.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldUseridExample").'</td>';
|
||||
print '<td class="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Home Directory
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldHomedirectory").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldhomedirectory" value="'.$conf->global->LDAP_FIELD_HOMEDIRECTORY.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldHomedirectoryExample").'</td>';
|
||||
print '<td class="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Home Directory Prefix
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldHomedirectoryprefix").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldhomedirectoryprefix" value="'.$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX.'">';
|
||||
print '</td><td></td>';
|
||||
print '<td class="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print info_admin($langs->trans("LDAPDescValues"));
|
||||
|
||||
@ -1458,6 +1458,13 @@ LDAPFieldSidExample=Example: objectsid
|
||||
LDAPFieldEndLastSubscription=Date of subscription end
|
||||
LDAPFieldTitle=Job position
|
||||
LDAPFieldTitleExample=Example: title
|
||||
LDAPFieldGroupid=Group id
|
||||
LDAPFieldGroupidExample=Exemple : gidnumber
|
||||
LDAPFieldUserid=User id
|
||||
LDAPFieldUseridExample=Exemple : uidnumber
|
||||
LDAPFieldHomedirectory=Home directory prefix
|
||||
LDAPFieldHomedirectoryExample=Exemple : homedirectory
|
||||
LDAPFieldHomedirectoryprefix=Home directory prefix
|
||||
LDAPSetupNotComplete=LDAP setup not complete (go on others tabs)
|
||||
LDAPNoUserOrPasswordProvidedAccessIsReadOnly=No administrator or password provided. LDAP access will be anonymous and in read only mode.
|
||||
LDAPDescContact=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr contacts.
|
||||
|
||||
@ -1458,6 +1458,13 @@ LDAPFieldSidExample=Exemple : objectsid
|
||||
LDAPFieldEndLastSubscription=Date de fin de validité adhésion
|
||||
LDAPFieldTitle=Poste/fonction
|
||||
LDAPFieldTitleExample=Exemple: title
|
||||
LDAPFieldGroupid=Groupe id
|
||||
LDAPFieldGroupidExample=Exemple : gidnumber
|
||||
LDAPFieldUserid=User id
|
||||
LDAPFieldUseridExample=Exemple : uidnumber
|
||||
LDAPFieldHomedirectory=Répertoire d'accueil
|
||||
LDAPFieldHomedirectoryExample=Exemple : homedirectory
|
||||
LDAPFieldHomedirectoryprefix=Préfixe du répertoire d'accueil
|
||||
LDAPSetupNotComplete=Configuration LDAP incomplète (à compléter sur les autres onglets)
|
||||
LDAPNoUserOrPasswordProvidedAccessIsReadOnly=Administrateur ou mot de passe non renseigné. Les accès LDAP seront donc anonymes et en lecture seule.
|
||||
LDAPDescContact=Cette page permet de définir le nom des attributs de l'arbre LDAP pour chaque information des contacts Dolibarr.
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* Copyright (C) 2018 charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -35,6 +36,7 @@
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT .'/user/class/usergroup.class.php';
|
||||
|
||||
/**
|
||||
* Class to manage Dolibarr users
|
||||
@ -2655,8 +2657,22 @@ class User extends CommonObject
|
||||
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Alexis Algoud <alexis@atm-consulting.fr>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -978,7 +979,10 @@ class UserGroup extends CommonObject
|
||||
$valueofldapfield[] = $muser->_load_ldap_dn($info2);
|
||||
}
|
||||
$info[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
|
||||
}
|
||||
}
|
||||
if(!empty($info[$conf->global->LDAP_GROUP_FIELD_GROUPID])){
|
||||
$info[$conf->global->LDAP_GROUP_FIELD_GROUPID]=$this->id;
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user