New: Ajout onglet LDAP sur fiche utilisateur et groupe
This commit is contained in:
parent
29e737e567
commit
8f1495d945
@ -114,8 +114,11 @@ class Contact
|
||||
// Fin appel triggers
|
||||
|
||||
// \todo Mettre en trigger
|
||||
$this->create_ldap($user);
|
||||
|
||||
if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
|
||||
{
|
||||
$this->create_ldap($user);
|
||||
}
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
@ -188,7 +191,10 @@ class Contact
|
||||
// Fin appel triggers
|
||||
|
||||
// \todo Mettre en trigger
|
||||
$this->update_ldap($user);
|
||||
if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
|
||||
{
|
||||
$this->update_ldap($user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -257,7 +263,7 @@ class Contact
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mise à jour du contact dans l'arbre LDAP
|
||||
* \brief Mise à jour dans l'arbre LDAP
|
||||
* \param user Utilisateur qui effectue la mise à jour
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
@ -265,7 +271,7 @@ class Contact
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if (! $conf->ldap->enabled || ! $conf->global->LDAP_CONTACT_ACTIVE) return 0;
|
||||
//if (! $conf->ldap->enabled || ! $conf->global->LDAP_CONTACT_ACTIVE) return 0;
|
||||
|
||||
$info = array();
|
||||
|
||||
@ -626,8 +632,9 @@ class Contact
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Efface le contact de la base et éventuellement de l'annuaire LDAP
|
||||
* \param id id du contact a effacer
|
||||
* \brief Efface le contact de la base et éventuellement de l'annuaire LDAP
|
||||
* \param id id du contact a effacer
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function delete($id)
|
||||
{
|
||||
@ -664,19 +671,22 @@ class Contact
|
||||
$result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf);
|
||||
// Fin appel triggers
|
||||
|
||||
|
||||
// \todo Mettre en trigger
|
||||
|
||||
// On modifie contact avec anciens noms
|
||||
$savname=$this->name;
|
||||
$savfirstname=$this->firstname;
|
||||
$this->name=$this->old_name;
|
||||
$this->firstname=$this->old_firstname;
|
||||
|
||||
$this->delete_ldap($user);
|
||||
|
||||
$this->name=$savname;
|
||||
$this->firstname=$savfirstname;
|
||||
if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
|
||||
{
|
||||
// On modifie contact avec anciens noms
|
||||
$savname=$this->name;
|
||||
$savfirstname=$this->firstname;
|
||||
$this->name=$this->old_name;
|
||||
$this->firstname=$this->old_firstname;
|
||||
|
||||
$this->delete_ldap($user);
|
||||
|
||||
$this->name=$savname;
|
||||
$this->firstname=$savfirstname;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -21,9 +21,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/contact/exportimport.php
|
||||
\ingroup societe
|
||||
\brief Onglet exports-imports d'un contact
|
||||
\file htdocs/contact/ldap.php
|
||||
\ingroup ldap
|
||||
\brief Page fiche LDAP contact
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
@ -127,15 +127,14 @@ print '<br>';
|
||||
|
||||
print_titre($langs->trans("LDAPInformationsForThisContact"));
|
||||
|
||||
// Affichage actions sur contact
|
||||
// Affichage attributs LDAP
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("LDAPAttribute").'</td>';
|
||||
print '<td>'.$langs->trans("LDAPAttributes").'</td>';
|
||||
print '<td>'.$langs->trans("Value").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Lecture LDAP
|
||||
$ldap=new AuthLdap();
|
||||
$result=$ldap->connect();
|
||||
@ -155,14 +154,21 @@ if ($result)
|
||||
|
||||
if ($bind)
|
||||
{
|
||||
$info["cn"] = utf8_encode(trim($contact->firstname." ".$contact->name));
|
||||
$info["cn"] = trim($contact->firstname." ".$contact->name);
|
||||
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
|
||||
|
||||
$result=$ldap->search($dn,'(objectClass=*)');
|
||||
|
||||
// Affichage arbre
|
||||
$html=new Form($db);
|
||||
$html->show_ldap_content($result,0,0,true);
|
||||
if (sizeof($result))
|
||||
{
|
||||
$html=new Form($db);
|
||||
$html->show_ldap_content($result,0,0,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -546,7 +546,6 @@ LDAPFieldLoginUnix=Login (unix)
|
||||
LDAPFieldLoginExample=Suggested value : uid
|
||||
LDAPFilterConnection=Search filter
|
||||
LDAPFilterConnectionExample=Suggested value : &(objectClass=user)(objectCategory=person)
|
||||
LDAPAttributes=LDAP attributes
|
||||
LDAPFieldLoginSamba=Login (samba, activedirectory)
|
||||
LDAPFieldLoginSambaExample=Suggested value : samaccountname (Samba and ActiveDirectory)
|
||||
LDAPFieldName=Name
|
||||
|
||||
@ -6,5 +6,10 @@ LdapUacf_DONT_EXPIRE_PASSWORD=Password never expires
|
||||
LdapUacf_ACCOUNTDISABLE=Account is disabled on this domain
|
||||
LDAPInformationsForThisContact=Informations in LDAP database for this contact
|
||||
LDAPInformationsForThisUser=Informations in LDAP database for this user
|
||||
LDAPAttribute=Attribute
|
||||
LDAPCard=LDAP card
|
||||
LDAPInformationsForThisGroup=Informations in LDAP database for this group
|
||||
LDAPAttribute=LDAP attribute
|
||||
LDAPAttributes=LDAP attributes
|
||||
LDAPCard=LDAP card
|
||||
LDAPRecordNotFound=Record not found in LDAP database
|
||||
LDAPUsers=Users in LDAP database
|
||||
LDAPGroups=Groups in LDAP database
|
||||
@ -518,7 +518,6 @@ LDAPFieldLogin=Attribut login
|
||||
LDAPFieldLoginExample=Attribut par défaut: uid
|
||||
LDAPFilterConnection=Filtre de recherche
|
||||
LDAPFilterConnectionExample=Filtre par défaut : &(objectClass=user)(objectCategory=person)
|
||||
LDAPAttributes=Attributs LDAP
|
||||
LDAPFieldLoginSamba=Login
|
||||
LDAPFieldLoginSambaExample=Attribut par défaut: samaccountname (Samba and Active Directory)
|
||||
LDAPFieldName=Non
|
||||
|
||||
@ -546,7 +546,6 @@ LDAPFieldLoginUnix=Login (unix)
|
||||
LDAPFieldLoginExample=Valeur recommandée : uid
|
||||
LDAPFilterConnection=Filtre de recherche
|
||||
LDAPFilterConnectionExample=Valeur recommandée : &(objectClass=user)(objectCategory=person)
|
||||
LDAPAttributes=Attributs LDAP
|
||||
LDAPFieldLoginSamba=Login (samba, activedirectory)
|
||||
LDAPFieldLoginSambaExample=Valeur recommandée : samaccountname (Samba et ActiveDirectory)
|
||||
LDAPFieldName=Nom
|
||||
|
||||
@ -6,5 +6,10 @@ LdapUacf_DONT_EXPIRE_PASSWORD=Le mot de passe n'expire jamais
|
||||
LdapUacf_ACCOUNTDISABLE=Le compte est désactivé sur le domaine
|
||||
LDAPInformationsForThisContact=Informations en base LDAP pour ce contact
|
||||
LDAPInformationsForThisUser=Informations en base LDAP pour cet utilisateur
|
||||
LDAPAttribute=Attribut
|
||||
LDAPInformationsForThisGroup=Informations en base LDAP pour ce groupe
|
||||
LDAPAttribute=Attribut LDAP
|
||||
LDAPAttributes=Attributs LDAP
|
||||
LDAPCard=Fiche LDAP
|
||||
LDAPRecordNotFound=Enregistrement non trouvé dans la base LDAP
|
||||
LDAPUsers=Utilisateurs en base LDAP
|
||||
LDAPGroups=Groupes en base LDAP
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
/**
|
||||
\file htdocs/lib/authldap.lib.php
|
||||
\brief Librairie contenant les fonctions pour accèder au serveur LDAP
|
||||
\brief Classe de gestion d'annuaire LDAP
|
||||
\author Rodolphe Quiedeville
|
||||
\author Benoit Mortier
|
||||
\author Regis Houssin
|
||||
@ -545,8 +545,10 @@ class AuthLdap {
|
||||
* username. The search criteria is a standard LDAP query - * returns all
|
||||
* users. The $attributeArray variable contains the required user detail field names
|
||||
*/
|
||||
function getUsers( $search, $attributeArray) {
|
||||
|
||||
function getUsers( $search, $attributeArray)
|
||||
{
|
||||
$userslist=array();
|
||||
|
||||
// Perform the search and get the entry handles
|
||||
|
||||
// if the directory is AD, then bind first with the search user first
|
||||
@ -555,7 +557,7 @@ class AuthLdap {
|
||||
}
|
||||
|
||||
$filter = '('.$this->filter.'('.$this->getUserIdentifier().'='.$search.'))';
|
||||
|
||||
//print "zzz".$filter;
|
||||
$this->result = @ldap_search( $this->connection, $this->people, $filter);
|
||||
|
||||
if (!$this->result)
|
||||
@ -592,16 +594,8 @@ class AuthLdap {
|
||||
}
|
||||
}
|
||||
|
||||
if ( !@asort( $userslist)) {
|
||||
/* Sort into alphabetical order. If this fails, it's because there
|
||||
** were no results returned (array is empty) - so just return false.
|
||||
*/
|
||||
$this->ldapErrorCode = -1;
|
||||
$this->ldapErrorText = "No users found matching search criteria ".$search;
|
||||
return false;
|
||||
}
|
||||
asort($userslist);
|
||||
return $userslist;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -649,22 +643,30 @@ class AuthLdap {
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief fonction de recherche avec filtre
|
||||
* \param dn de recherche
|
||||
* \param filtre de recherche (ex: sn=nom_personne)
|
||||
* \brief Fonction de recherche avec filtre
|
||||
* \param checkDn DN de recherche
|
||||
* \param filter filtre de recherche (ex: sn=nom_personne)
|
||||
* \remarks this->conneciton doit etre défini donc la methode bind ou authbind doit avoir deja été appelée
|
||||
*/
|
||||
function search( $checkDn, $filter) {
|
||||
|
||||
function search($checkDn, $filter)
|
||||
{
|
||||
// Perform the search and get the entry handles
|
||||
if ($this->serverType != "activedirectory")
|
||||
{
|
||||
$checkDn=utf8_decode($checkDn);
|
||||
}
|
||||
|
||||
dolibarr_syslog("authldap.lib::search checkDn=".$checkDn." filter=".$filer);
|
||||
|
||||
// if the directory is AD, then bind first with the search user first
|
||||
if ($this->serverType == "activedirectory") {
|
||||
$this->authBind($this->searchUser, $this->searchPassword);
|
||||
}
|
||||
|
||||
$this->result = @ldap_search( $this->connection, $checkDn, $filter);
|
||||
|
||||
$this->result = @ldap_search($this->connection, $checkDn, $filter);
|
||||
|
||||
$result = @ldap_get_entries( $this->connection, $this->result);
|
||||
$result = @ldap_get_entries($this->connection, $this->result);
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
|
||||
111
htdocs/lib/usergroups.lib.php
Normal file
111
htdocs/lib/usergroups.lib.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/lib/usergroups.lib.php
|
||||
\brief Ensemble de fonctions de base pour les utilisaterus et groupes
|
||||
\version $Revision$
|
||||
|
||||
Ensemble de fonctions de base de dolibarr sous forme d'include
|
||||
*/
|
||||
|
||||
function user_prepare_head($user)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$user->id;
|
||||
$head[$h][1] = $langs->trans("UserCard");
|
||||
$head[$h][2] = 'user';
|
||||
$h++;
|
||||
|
||||
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||
{
|
||||
$langs->load("ldap");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$user->id;
|
||||
$head[$h][1] = $langs->trans("LDAPCard");
|
||||
$head[$h][2] = 'ldap';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$user->id;
|
||||
$head[$h][1] = $langs->trans("UserRights");
|
||||
$head[$h][2] = 'rights';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$user->id;
|
||||
$head[$h][1] = $langs->trans("UserGUISetup");
|
||||
$head[$h][2] = 'guisetup';
|
||||
$h++;
|
||||
|
||||
if ($conf->bookmark4u->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$user->id;
|
||||
$head[$h][1] = $langs->trans("Bookmark4u");
|
||||
$head[$h][2] = 'bookmark4u';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->clicktodial->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$user->id;
|
||||
$head[$h][1] = $langs->trans("ClickToDial");
|
||||
$head[$h][2] = 'clicktodial';
|
||||
$h++;
|
||||
}
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
function group_prepare_head($group)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/fiche.php?id='.$group->id;
|
||||
$head[$h][1] = $langs->trans("GroupCard");
|
||||
$head[$h][2] = 'group';
|
||||
$h++;
|
||||
|
||||
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||
{
|
||||
$langs->load("ldap");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$group->id;
|
||||
$head[$h][1] = $langs->trans("LDAPCard");
|
||||
$head[$h][2] = 'ldap';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$group->id;
|
||||
$head[$h][1] = $langs->trans("GroupRights");
|
||||
$head[$h][2] = 'rights';
|
||||
$h++;
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
?>
|
||||
@ -125,6 +125,7 @@ class User
|
||||
$sql .= " WHERE u.rowid = ".$this->id;
|
||||
}
|
||||
|
||||
dolibarr_syslog("User.class::fetch this->id=".$this->id." login=".$login);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -136,7 +137,7 @@ class User
|
||||
$this->nom = $obj->name;
|
||||
$this->prenom = $obj->firstname;
|
||||
|
||||
$this->fullname = $this->prenom . ' ' . $this->nom;
|
||||
$this->fullname = trim($this->prenom . ' ' . $this->nom);
|
||||
$this->code = $obj->code;
|
||||
$this->login = $obj->login;
|
||||
$this->pass = $obj->pass;
|
||||
@ -1192,7 +1193,155 @@ class User
|
||||
if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mise à jour dans l'arbre LDAP
|
||||
* \param user Utilisateur qui effectue la mise à jour
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update_ldap($user)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
//if (! $conf->ldap->enabled || ! $conf->global->LDAP_SYNCHRO_ACTIVE) return 0;
|
||||
|
||||
$info = array();
|
||||
|
||||
dolibarr_syslog("User.class::update_ldap this->id=".$this->id,LOG_DEBUG);
|
||||
|
||||
$ldap=new AuthLdap();
|
||||
$result=$ldap->connect();
|
||||
if ($result)
|
||||
{
|
||||
$bind='';
|
||||
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
|
||||
{
|
||||
dolibarr_syslog("User.class::update_ldap authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
|
||||
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("User.class::update_ldap bind",LOG_DEBUG);
|
||||
$bind=$ldap->bind();
|
||||
}
|
||||
if ($bind)
|
||||
{
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
|
||||
{
|
||||
$info["objectclass"]=array("top",
|
||||
"person",
|
||||
"organizationalPerson",
|
||||
"user");
|
||||
}
|
||||
else
|
||||
{
|
||||
$info["objectclass"]=array("top",
|
||||
"person",
|
||||
"organizationalPerson",
|
||||
"inetOrgPerson");
|
||||
}
|
||||
|
||||
// Champs obligatoires
|
||||
$info["cn"] = trim($this->prenom." ".$this->nom);
|
||||
if ($this->nom) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Name"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Champs optionnels
|
||||
if ($this->prenom && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->prenom;
|
||||
if ($this->poste) $info["title"] = $this->poste;
|
||||
if ($this->societe_id > 0)
|
||||
{
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->societe_id);
|
||||
|
||||
$info["o"] = $soc->nom;
|
||||
if ($soc->client == 1) $info["businessCategory"] = "Customers";
|
||||
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
|
||||
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
|
||||
}
|
||||
if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
|
||||
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;
|
||||
if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
|
||||
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro;
|
||||
if ($this->phone_perso) $info["homePhone"] = $this->phone_perso;
|
||||
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile;
|
||||
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
|
||||
if ($this->note) $info["description"] = $this->note;
|
||||
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
|
||||
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
|
||||
{
|
||||
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
|
||||
|
||||
$info['uidnumber'] = $this->id;
|
||||
|
||||
$info['phpgwTz'] = 0;
|
||||
$info['phpgwMailType'] = 'INTERNET';
|
||||
$info['phpgwMailHomeType'] = 'INTERNET';
|
||||
|
||||
$info["phpgwContactTypeId"] = 'n';
|
||||
$info["phpgwContactCatId"] = 0;
|
||||
$info["phpgwContactAccess"] = "public";
|
||||
|
||||
if (strlen($user->egroupware_id) == 0)
|
||||
{
|
||||
$user->egroupware_id = 1;
|
||||
}
|
||||
|
||||
$info["phpgwContactOwner"] = $user->egroupware_id;
|
||||
|
||||
if ($this->email) $info["rfc822Mailbox"] = $this->email;
|
||||
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
|
||||
}
|
||||
|
||||
$info["uid"] = "Dolibarr ".$this->ldap_sid;
|
||||
|
||||
$newdn = "cn=".$info["cn"].",".$conf->global->LDAP_USER_DN;
|
||||
$olddn = $newdn;
|
||||
if ($this->old_firstname || $this->old_name) $olddn="cn=".trim($this->old_firstname." ".$this->old_name).",".$conf->global->LDAP_CONTACT_DN;
|
||||
|
||||
// On supprime et on insère
|
||||
dolibarr_syslog("User.class::update_ldap olddn=".$olddn." newdn=".$newdn);
|
||||
|
||||
$result = $ldap->delete($olddn);
|
||||
$result = $ldap->add($newdn, $info);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$this->error = ldap_errno($ldap->connection)." ".ldap_error($ldap->connection)." ".$ldap->error;
|
||||
dolibarr_syslog("User.class::update_ldap ".$this->error,LOG_ERROR);
|
||||
//print_r($info);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("User.class::update_ldap rowid=".$this->id." added in LDAP");
|
||||
}
|
||||
|
||||
$ldap->unbind();
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = "Error ".ldap_errno($ldap->connection)." ".ldap_error($ldap->connection);
|
||||
dolibarr_syslog("User.class::update_ldap bind failed",LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Failed to connect to LDAP server !";
|
||||
dolibarr_syslog("User.class::update_ldap Connexion failed",LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once DOL_DOCUMENT_ROOT."/bookmark4u.class.php";
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
|
||||
$langs->load("users");
|
||||
|
||||
@ -45,6 +46,7 @@ if ($_GET["action"] == 'create_bk4u_login')
|
||||
if ($result > 0)
|
||||
{
|
||||
Header("Location: addon.php?id=".$_GET["id"]);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -71,40 +73,13 @@ if ($_GET["id"])
|
||||
$bk4u->get_bk4u_uid($fuser);
|
||||
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
$h = 0;
|
||||
dolibarr_fiche_head($head, 'bookmark4u', $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserRights");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserGUISetup");
|
||||
$h++;
|
||||
|
||||
if ($conf->bookmark4u->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("Bookmark4u");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->clicktodial->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("ClickToDial");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
/*
|
||||
* Fiche en mode visu
|
||||
@ -125,7 +100,7 @@ if ($_GET["id"])
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Login Boobkmark4u").'</td>';
|
||||
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Login Bookmark4u").'</td>';
|
||||
print '<td class="valeur">';
|
||||
|
||||
if ($bk4u->uid == 0)
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once DOL_DOCUMENT_ROOT."/bookmark4u.class.php";
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
|
||||
$langs->load("users");
|
||||
|
||||
@ -64,43 +64,13 @@ if ($_GET["id"])
|
||||
$fuser->fetch();
|
||||
$fuser->fetch_clicktodial();
|
||||
|
||||
$bk4u = new Bookmark4u($db);
|
||||
$bk4u->get_bk4u_uid($fuser);
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserRights");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserGUISetup");
|
||||
$h++;
|
||||
|
||||
if ($conf->bookmark4u->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("Bookmark4u");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->clicktodial->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("ClickToDial");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
|
||||
dolibarr_fiche_head($head, 'clicktodial', $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
/*
|
||||
* Fiche en mode visu
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
|
||||
|
||||
// Defini si peux creer un utilisateur ou gerer groupe sur un utilisateur
|
||||
@ -50,7 +51,6 @@ if ($_GET["id"])
|
||||
$caneditpassword=( (($user->id == $_GET["id"]) && $user->rights->user->self->password)
|
||||
|| (($user->id != $_GET["id"]) && $user->rights->user->user->password) );
|
||||
}
|
||||
|
||||
if ($user->id <> $_GET["id"] && ! $canreadperms)
|
||||
{
|
||||
accessforbidden();
|
||||
@ -60,10 +60,10 @@ $langs->load("users");
|
||||
$langs->load("companies");
|
||||
$langs->load("ldap");
|
||||
|
||||
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
|
||||
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
|
||||
}
|
||||
}
|
||||
|
||||
//reactive un compte ldap
|
||||
// Reactive un compte ldap
|
||||
if ($conf->ldap->enabled && $_GET["action"] == 'reactivate' && $candisableuser)
|
||||
{
|
||||
if ($_GET["id"] <> $user->id)
|
||||
@ -236,75 +236,75 @@ if ($_GET["action"] == 'removegroup' && $caneditfield)
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'update' && $caneditfield)
|
||||
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $caneditfield)
|
||||
{
|
||||
$message="";
|
||||
$message="";
|
||||
|
||||
$db->begin();
|
||||
$db->begin();
|
||||
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch();
|
||||
|
||||
$edituser->oldpass = $edituser->pass;
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch();
|
||||
|
||||
$edituser->nom = trim($_POST["nom"]);
|
||||
$edituser->prenom = trim($_POST["prenom"]);
|
||||
$edituser->login = trim($_POST["login"]);
|
||||
$edituser->pass = trim($_POST["pass"]);
|
||||
$edituser->admin = trim($_POST["admin"]);
|
||||
$edituser->office_phone = trim($_POST["office_phone"]);
|
||||
$edituser->office_fax = trim($_POST["office_fax"]);
|
||||
$edituser->user_mobile = trim($_POST["user_mobile"]);
|
||||
$edituser->email = trim($_POST["email"]);
|
||||
$edituser->note = trim($_POST["note"]);
|
||||
$edituser->webcal_login = trim($_POST["webcal_login"]);
|
||||
$edituser->oldpass = $edituser->pass;
|
||||
|
||||
$ret=$edituser->update();
|
||||
if ($ret < 0)
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$message.='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$message.='<div class="error">'.$edituser->error.'</div>';
|
||||
}
|
||||
}
|
||||
if ($ret >= 0 && isset($_POST["password"]) && $_POST["password"] !='' )
|
||||
{
|
||||
$ret=$edituser->password($user,$password,$conf->password_encrypted,1);
|
||||
if ($ret < 0)
|
||||
{
|
||||
$message.='<div class="error">'.$edituser->error.'</div>';
|
||||
}
|
||||
}
|
||||
$edituser->nom = trim($_POST["nom"]);
|
||||
$edituser->prenom = trim($_POST["prenom"]);
|
||||
$edituser->login = trim($_POST["login"]);
|
||||
$edituser->pass = trim($_POST["pass"]);
|
||||
$edituser->admin = trim($_POST["admin"]);
|
||||
$edituser->office_phone = trim($_POST["office_phone"]);
|
||||
$edituser->office_fax = trim($_POST["office_fax"]);
|
||||
$edituser->user_mobile = trim($_POST["user_mobile"]);
|
||||
$edituser->email = trim($_POST["email"]);
|
||||
$edituser->note = trim($_POST["note"]);
|
||||
$edituser->webcal_login = trim($_POST["webcal_login"]);
|
||||
|
||||
if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
|
||||
{
|
||||
// Si une photo est fournie avec le formulaire
|
||||
if (! is_dir($conf->users->dir_output))
|
||||
{
|
||||
create_exdir($conf->users->dir_output);
|
||||
}
|
||||
if (is_dir($conf->users->dir_output))
|
||||
{
|
||||
$newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg";
|
||||
if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile))
|
||||
{
|
||||
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret=$edituser->update();
|
||||
if ($ret < 0)
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$message.='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$message.='<div class="error">'.$edituser->error.'</div>';
|
||||
}
|
||||
}
|
||||
if ($ret >= 0 && isset($_POST["password"]) && $_POST["password"] !='' )
|
||||
{
|
||||
$ret=$edituser->password($user,$password,$conf->password_encrypted,1);
|
||||
if ($ret < 0)
|
||||
{
|
||||
$message.='<div class="error">'.$edituser->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($ret >= 0)
|
||||
{
|
||||
$message.='<div class="ok">'.$langs->trans("UserModified").'</div>';
|
||||
$db->commit();
|
||||
} else
|
||||
{
|
||||
$db->rollback;
|
||||
}
|
||||
if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
|
||||
{
|
||||
// Si une photo est fournie avec le formulaire
|
||||
if (! is_dir($conf->users->dir_output))
|
||||
{
|
||||
create_exdir($conf->users->dir_output);
|
||||
}
|
||||
if (is_dir($conf->users->dir_output))
|
||||
{
|
||||
$newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg";
|
||||
if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile))
|
||||
{
|
||||
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($ret >= 0)
|
||||
{
|
||||
$message.='<div class="ok">'.$langs->trans("UserModified").'</div>';
|
||||
$db->commit();
|
||||
} else
|
||||
{
|
||||
$db->rollback;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -346,7 +346,9 @@ if ((($_POST["action"] == 'confirm_password' && $_POST["confirm"] == 'yes')
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affichage page
|
||||
*/
|
||||
|
||||
llxHeader('',$langs->trans("UserCard"));
|
||||
|
||||
@ -354,90 +356,108 @@ $html = new Form($db);
|
||||
|
||||
if (($action == 'create') || ($action == 'adduserldap'))
|
||||
{
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Affichage fiche en mode création */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print_titre($langs->trans("NewUser"));
|
||||
print "<br>";
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Affichage fiche en mode création */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print_titre($langs->trans("NewUser"));
|
||||
print "<br>";
|
||||
|
||||
print $langs->trans("CreateInternalUserDesc");
|
||||
print "<br>";
|
||||
print "<br>";
|
||||
print "<br>";
|
||||
print "<br>";
|
||||
|
||||
if ($message) { print $message.'<br>'; }
|
||||
|
||||
/*
|
||||
* Affiche formulaire d'ajout d'un compte depuis LDAP
|
||||
* si on est en synchro LDAP vers Dolibarr
|
||||
*/
|
||||
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')
|
||||
{
|
||||
$name = $conf->global->LDAP_FIELD_NAME;
|
||||
$firstname = $conf->global->LDAP_FIELD_FIRSTNAME;
|
||||
$mail = $conf->global->LDAP_FIELD_MAIL;
|
||||
$phone = $conf->global->LDAP_FIELD_PHONE;
|
||||
$fax = $conf->global->LDAP_FIELD_FAX;
|
||||
$mobile = $conf->global->LDAP_FIELD_MOBILE;
|
||||
$login = $conf->global->LDAP_FIELD_LOGIN_SAMBA;
|
||||
$SID = "objectsid";
|
||||
|
||||
if ($message) { print $message.'<br>'; }
|
||||
|
||||
/*
|
||||
* ajout utilisateur ldap
|
||||
*/
|
||||
if ($conf->ldap->enabled)
|
||||
{
|
||||
if ($conf->global->LDAP_SERVER_HOST && $conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
|
||||
{
|
||||
$name = $conf->global->LDAP_FIELD_NAME;
|
||||
$firstname = $conf->global->LDAP_FIELD_FIRSTNAME;
|
||||
$mail = $conf->global->LDAP_FIELD_MAIL;
|
||||
$phone = $conf->global->LDAP_FIELD_PHONE;
|
||||
$fax = $conf->global->LDAP_FIELD_FAX;
|
||||
$mobile = $conf->global->LDAP_FIELD_MOBILE;
|
||||
$login = $conf->global->LDAP_FIELD_LOGIN_SAMBA;
|
||||
$SID = "objectsid";
|
||||
|
||||
$ldap = new AuthLdap();
|
||||
|
||||
if ($ldap->connect())
|
||||
{
|
||||
$justthese = array( $name, $firstname, $login);
|
||||
$ldapusers = $ldap->getUsers('*', $justthese);
|
||||
|
||||
if ($ldapusers)
|
||||
{
|
||||
$html = new Form($db);
|
||||
|
||||
foreach ($ldapusers as $key => $ldapuser)
|
||||
{
|
||||
if($ldapuser[$name] != "")
|
||||
$liste[$ldapuser[$login]] = utf8_decode($ldapuser[$name])." ".utf8_decode($ldapuser[$firstname]);
|
||||
}
|
||||
|
||||
print '<form name="add_user_ldap" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="adduserldap">';
|
||||
print $html->select_array('users', $liste, '', 1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Add').'">';
|
||||
print '</form>';
|
||||
print "<br>";
|
||||
}
|
||||
|
||||
if ($action == 'adduserldap')
|
||||
{
|
||||
$selecteduser = $_POST['users'];
|
||||
$justthese = array( $login,
|
||||
$name,
|
||||
$firstname,
|
||||
$mail,
|
||||
$phone,
|
||||
$fax,
|
||||
$mobile,
|
||||
$SID);
|
||||
$ldap = new AuthLdap();
|
||||
|
||||
$selectedUser = $ldap->getUsers($selecteduser, $justthese);
|
||||
|
||||
if ($selectedUser)
|
||||
{
|
||||
foreach ($selectedUser as $key => $attribute)
|
||||
{
|
||||
$ldap_nom = utf8_decode($attribute[$name]?$attribute[$name]:'');
|
||||
$ldap_prenom = utf8_decode($attribute[$firstname]?$attribute[$firstname]:'');
|
||||
$ldap_login = utf8_decode($attribute[$login]?$attribute[$login]:'');
|
||||
$ldap_phone = utf8_decode($attribute[$phone]?$attribute[$phone]:'');
|
||||
$ldap_fax = utf8_decode($attribute[$fax]?$attribute[$fax]:'');
|
||||
$ldap_mobile = utf8_decode($attribute[$mobile]?$attribute[$mobile]:'');
|
||||
$ldap_mail = utf8_decode($attribute[$mail]?$attribute[$mail]:'');
|
||||
$ldap_SID = $attribute[$SID];
|
||||
//$ldap_SID = bin2hex($attribute[$SID]);
|
||||
}
|
||||
if ($ldap->connect())
|
||||
{
|
||||
$bind='';
|
||||
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
|
||||
{
|
||||
dolibarr_syslog("user/fiche.php authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
|
||||
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("user/fiche.php bind",LOG_DEBUG);
|
||||
$bind=$ldap->bind();
|
||||
}
|
||||
if ($bind)
|
||||
{
|
||||
$justthese = array($name, $firstname, $login);
|
||||
$ldapusers = $ldap->getUsers('*', $justthese);
|
||||
|
||||
//print "eee".$justthese." r ".$ldapusers;
|
||||
//print_r($justthese);
|
||||
|
||||
foreach ($ldapusers as $key => $ldapuser)
|
||||
{
|
||||
if($ldapuser[$name] != "")
|
||||
$liste[$ldapuser[$login]] = utf8_decode($ldapuser[$name])." ".utf8_decode($ldapuser[$firstname]);
|
||||
}
|
||||
|
||||
print '<form name="add_user_ldap" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<table><tr><td>';
|
||||
print $langs->trans("LDAPUsers");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="action" value="adduserldap">';
|
||||
print $html->select_array('users', $liste, '', 1);
|
||||
print '</td><td>';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Add').'">';
|
||||
print '</td></tr></table>';
|
||||
print '</form>';
|
||||
print "<br>";
|
||||
|
||||
// Action (a mettre dans actions)
|
||||
if ($action == 'adduserldap')
|
||||
{
|
||||
$selecteduser = $_POST['users'];
|
||||
$justthese = array( $login,
|
||||
$name,
|
||||
$firstname,
|
||||
$mail,
|
||||
$phone,
|
||||
$fax,
|
||||
$mobile,
|
||||
$SID);
|
||||
|
||||
$selectedUser = $ldap->getUsers($selecteduser, $justthese);
|
||||
|
||||
if ($selectedUser)
|
||||
{
|
||||
foreach ($selectedUser as $key => $attribute)
|
||||
{
|
||||
$ldap_nom = utf8_decode($attribute[$name]?$attribute[$name]:'');
|
||||
$ldap_prenom = utf8_decode($attribute[$firstname]?$attribute[$firstname]:'');
|
||||
$ldap_login = utf8_decode($attribute[$login]?$attribute[$login]:'');
|
||||
$ldap_phone = utf8_decode($attribute[$phone]?$attribute[$phone]:'');
|
||||
$ldap_fax = utf8_decode($attribute[$fax]?$attribute[$fax]:'');
|
||||
$ldap_mobile = utf8_decode($attribute[$mobile]?$attribute[$mobile]:'');
|
||||
$ldap_mail = utf8_decode($attribute[$mail]?$attribute[$mail]:'');
|
||||
$ldap_SID = $attribute[$SID];
|
||||
//$ldap_SID = bin2hex($attribute[$SID]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -446,158 +466,166 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
||||
print $ldap->ldapErrorCode;
|
||||
print $ldap->ldapErrorText;
|
||||
}
|
||||
if (!$ldap->close())
|
||||
if (! $ldap->close())
|
||||
{
|
||||
print $ldap->ldapErrorCode;
|
||||
print $ldap->ldapErrorText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '<form action="fiche.php" method="post" name="createuser">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
if ($ldap_SID) print '<input type="hidden" name="ldap_sid" value="'.$ldap_SID.'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_nom)
|
||||
{
|
||||
print '<input type="hidden" name="nom" value="'.$ldap_nom.'">';
|
||||
print $ldap_nom;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="30" type="text" name="nom" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top" width="20%">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_prenom)
|
||||
{
|
||||
print '<input type="hidden" name="prenom" value="'.$ldap_prenom.'">';
|
||||
print $ldap_prenom;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="30" type="text" name="prenom" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_login)
|
||||
{
|
||||
print '<input type="hidden" name="login" value="'.$ldap_login.'">';
|
||||
print $ldap_login;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="20" maxsize="24" type="text" name="login" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if (!$ldap_SID)
|
||||
{
|
||||
$generated_password='';
|
||||
if ($conf->global->USER_PASSWORD_GENERATED)
|
||||
{
|
||||
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
|
||||
$nomfichier=$nomclass.".class.php";
|
||||
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
|
||||
$genhandler=new $nomclass($db,$conf,$lang,$user);
|
||||
$generated_password=$genhandler->getNewGeneratedPassword();
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_SID)
|
||||
{
|
||||
print 'mot de passe du domaine';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
|
||||
print '<td>';
|
||||
$form->selectyesnonum('admin',0);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Type").'</td>';
|
||||
print '<td>';
|
||||
print $html->textwithhelp($langs->trans("Internal"),$langs->trans("InternalExternalDesc"));
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Phone").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_phone)
|
||||
{
|
||||
print '<input type="hidden" name="office_phone" value="'.$ldap_phone.'">';
|
||||
print $ldap_phone;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="20" type="text" name="office_phone" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Fax").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_fax)
|
||||
{
|
||||
print '<input type="hidden" name="office_fax" value="'.$ldap_fax.'">';
|
||||
print $ldap_fax;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="20" type="text" name="office_fax" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Mobile").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_mobile)
|
||||
{
|
||||
print '<input type="hidden" name="user_mobile" value="'.$ldap_mobile.'">';
|
||||
print $ldap_mobile;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="20" type="text" name="user_mobile" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '<form action="fiche.php" method="post" name="createuser">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
if ($ldap_SID) print '<input type="hidden" name="ldap_sid" value="'.$ldap_SID.'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Nom
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_nom)
|
||||
{
|
||||
print '<input type="hidden" name="nom" value="'.$ldap_nom.'">';
|
||||
print $ldap_nom;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="30" type="text" name="nom" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Prenom
|
||||
print '<tr><td valign="top" width="20%">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_prenom)
|
||||
{
|
||||
print '<input type="hidden" name="prenom" value="'.$ldap_prenom.'">';
|
||||
print $ldap_prenom;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="30" type="text" name="prenom" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Login
|
||||
print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_login)
|
||||
{
|
||||
print '<input type="hidden" name="login" value="'.$ldap_login.'">';
|
||||
print $ldap_login;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="20" maxsize="24" type="text" name="login" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if (!$ldap_SID)
|
||||
{
|
||||
$generated_password='';
|
||||
if ($conf->global->USER_PASSWORD_GENERATED)
|
||||
{
|
||||
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
|
||||
$nomfichier=$nomclass.".class.php";
|
||||
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
|
||||
$genhandler=new $nomclass($db,$conf,$lang,$user);
|
||||
$generated_password=$genhandler->getNewGeneratedPassword();
|
||||
}
|
||||
}
|
||||
|
||||
// Mot de passe
|
||||
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_SID)
|
||||
{
|
||||
print 'mot de passe du domaine';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Administrateur
|
||||
if ($user->admin)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
|
||||
print '<td>';
|
||||
$form->selectyesnonum('admin',0);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Type
|
||||
print '<tr><td valign="top">'.$langs->trans("Type").'</td>';
|
||||
print '<td>';
|
||||
print $html->textwithhelp($langs->trans("Internal"),$langs->trans("InternalExternalDesc"));
|
||||
print '</td></tr>';
|
||||
|
||||
// Tel
|
||||
print '<tr><td valign="top">'.$langs->trans("Phone").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_phone)
|
||||
{
|
||||
print '<input type="hidden" name="office_phone" value="'.$ldap_phone.'">';
|
||||
print $ldap_phone;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="20" type="text" name="office_phone" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Fax
|
||||
print '<tr><td valign="top">'.$langs->trans("Fax").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_fax)
|
||||
{
|
||||
print '<input type="hidden" name="office_fax" value="'.$ldap_fax.'">';
|
||||
print $ldap_fax;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="20" type="text" name="office_fax" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Tel portable
|
||||
print '<tr><td valign="top">'.$langs->trans("Mobile").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_mobile)
|
||||
{
|
||||
print '<input type="hidden" name="user_mobile" value="'.$ldap_mobile.'">';
|
||||
print $ldap_mobile;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="20" type="text" name="user_mobile" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// EMail
|
||||
print '<tr><td valign="top">'.$langs->trans("EMail").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_mail)
|
||||
{
|
||||
print '<input type="hidden" name="email" value="'.$ldap_mail.'">';
|
||||
print $ldap_mail;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="40" type="text" name="email" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">';
|
||||
print $langs->trans("Note");
|
||||
print '</td><td>';
|
||||
print '<tr><td valign="top">'.$langs->trans("EMail").'</td>';
|
||||
print '<td>';
|
||||
if ($ldap_mail)
|
||||
{
|
||||
print '<input type="hidden" name="email" value="'.$ldap_mail.'">';
|
||||
print $ldap_mail;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input size="40" type="text" name="email" value="">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Note
|
||||
print '<tr><td valign="top">';
|
||||
print $langs->trans("Note");
|
||||
print '</td><td>';
|
||||
if ($conf->fckeditor->enabled)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
$doleditor=new DolEditor('note','',180,'dolibarr_notes','',false);
|
||||
$doleditor->Create();
|
||||
}
|
||||
@ -606,18 +634,18 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
||||
print '<textarea class="flat" name="note" rows="'.ROWS_4.'" cols="90">';
|
||||
print '</textarea>';
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Autres caractéristiques issus des autres modules
|
||||
if ($conf->webcal->enabled)
|
||||
{
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("LoginWebcal").'</td>';
|
||||
print '<td><input size="30" type="text" name="webcal_login" value=""></td></tr>';
|
||||
}
|
||||
|
||||
print "<tr>".'<td align="center" colspan="2"><input class="button" value="'.$langs->trans("CreateUser").'" type="submit"></td></tr>';
|
||||
print "</table>\n";
|
||||
print "</form>";
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Autres caractéristiques issus des autres modules
|
||||
if ($conf->webcal->enabled)
|
||||
{
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("LoginWebcal").'</td>';
|
||||
print '<td><input size="30" type="text" name="webcal_login" value=""></td></tr>';
|
||||
}
|
||||
|
||||
print "<tr>".'<td align="center" colspan="2"><input class="button" value="'.$langs->trans("CreateUser").'" type="submit"></td></tr>';
|
||||
print "</table>\n";
|
||||
print "</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -660,40 +688,12 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserCard");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserRights");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserGUISetup");
|
||||
$h++;
|
||||
|
||||
if ($conf->bookmark4u->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("Bookmark4u");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->clicktodial->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("ClickToDial");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
dolibarr_fiche_head($head, 'user', $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
|
||||
/*
|
||||
@ -749,9 +749,11 @@ else
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$rowspan=15;
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td width="50%">'.$fuser->nom.'</td>';
|
||||
$rowspan=17;
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
|
||||
print '<td width="50%">'.$fuser->id.'</td>';
|
||||
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
|
||||
if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
|
||||
{
|
||||
@ -763,6 +765,12 @@ else
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Nom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td width="50%">'.$fuser->nom.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Prenom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td width="50%">'.$fuser->prenom.'</td>';
|
||||
print "</tr>\n";
|
||||
@ -1077,12 +1085,11 @@ else
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
$rowspan=11;
|
||||
$rowspan=13;
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
|
||||
print '<td width="50%">';
|
||||
if ($caneditfield) print '<input class="flat" size="30" type="text" name="nom" value="'.$fuser->nom.'">';
|
||||
else print $fuser->nom;
|
||||
print $fuser->id;
|
||||
print '</td>';
|
||||
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
|
||||
if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
|
||||
@ -1102,6 +1109,14 @@ else
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Nom
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Name").'</td>';
|
||||
print '<td>';
|
||||
if ($caneditfield) print '<input size="30" type="text" class="flat" name="nom" value="'.$fuser->nom.'">';
|
||||
else print $fuser->nom;
|
||||
print '</td></tr>';
|
||||
|
||||
// Prenom
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td>';
|
||||
if ($caneditfield) print '<input size="30" type="text" class="flat" name="prenom" value="'.$fuser->prenom.'">';
|
||||
@ -1257,13 +1272,19 @@ else
|
||||
else print $fuser->webcal_login;
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '<tr><td align="center" colspan="3"><input value="'.$langs->trans("Save").'" class="button" type="submit"></td></tr>';
|
||||
|
||||
print '<tr><td align="center" colspan="3">';
|
||||
print '<input value="'.$langs->trans("Save").'" class="button" type="submit" name="save">';
|
||||
print ' ';
|
||||
print '<input value="'.$langs->trans("Cancel").'" class="button" type="submit" name="cancel">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
$ldap->close;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
|
||||
|
||||
// Defini si peux lire/modifier utilisateurs et permisssions
|
||||
@ -180,22 +181,12 @@ else
|
||||
$group = new UserGroup($db);
|
||||
$group->fetch($_GET["id"]);
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/fiche.php?id='.$group->id;
|
||||
$head[$h][1] = $langs->trans("GroupCard");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$group->id;
|
||||
$head[$h][1] = $langs->trans("GroupRights");
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Group").": ".$group->nom);
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = group_prepare_head($group);
|
||||
|
||||
dolibarr_fiche_head($head, 'group', $langs->trans("Group").": ".$group->nom);
|
||||
|
||||
|
||||
/*
|
||||
@ -212,12 +203,16 @@ else
|
||||
* Fiche en mode visu
|
||||
*/
|
||||
|
||||
if ($_GET["action"] != 'edit') {
|
||||
|
||||
if ($_GET["action"] != 'edit')
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Nom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
|
||||
print '<td width="75%" class="valeur">'.$group->nom.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Note
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
||||
print '<td class="valeur">'.nl2br($group->note).' </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
158
htdocs/user/group/ldap.php
Normal file
158
htdocs/user/group/ldap.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/user/group/ldap.php
|
||||
\ingroup ldap
|
||||
\brief Page fiche LDAP groupe
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
|
||||
|
||||
$user->getrights('commercial');
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("ldap");
|
||||
|
||||
// Protection quand utilisateur externe
|
||||
$contactid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affichage page
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$fgroup = new Usergroup($db, $_GET["id"]);
|
||||
$fgroup->fetch($_GET["id"]);
|
||||
$fgroup->getrights();
|
||||
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = group_prepare_head($fgroup);
|
||||
|
||||
dolibarr_fiche_head($head, 'ldap', $langs->trans("Group").": ".$fgroup->nom);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Fiche en mode visu
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Nom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
|
||||
print '<td width="75%" class="valeur">'.$fgroup->nom.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Note
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
||||
print '<td class="valeur">'.nl2br($fgroup->note).' </td>';
|
||||
print "</tr>\n";
|
||||
print "</table>\n";
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
print_titre($langs->trans("LDAPInformationsForThisGroup"));
|
||||
|
||||
// Affichage attributs LDAP
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("LDAPAttributes").'</td>';
|
||||
print '<td>'.$langs->trans("Value").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Lecture LDAP
|
||||
$ldap=new AuthLdap();
|
||||
$result=$ldap->connect();
|
||||
if ($result)
|
||||
{
|
||||
$bind='';
|
||||
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
|
||||
{
|
||||
dolibarr_syslog("ldap.php: authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
|
||||
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("ldap.php: bind",LOG_DEBUG);
|
||||
$bind=$ldap->bind();
|
||||
}
|
||||
|
||||
if ($bind)
|
||||
{
|
||||
// $info["cn"] = $ldap->getUserIdentifier()."=".$fuser->uname;
|
||||
$info["cn"] = trim($fgroup->nom);
|
||||
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_GROUP_DN;
|
||||
|
||||
$result=$ldap->search($dn,'(objectClass=*)');
|
||||
|
||||
// Affichage arbre
|
||||
if (sizeof($result))
|
||||
{
|
||||
$html=new Form($db);
|
||||
$html->show_ldap_content($result,0,0,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error('',$ldap);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error('',$ldap);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
@ -28,8 +28,8 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
|
||||
$langs->load("users");
|
||||
|
||||
@ -74,23 +74,13 @@ if ($_GET["id"])
|
||||
$fgroup->fetch($_GET["id"]);
|
||||
$fgroup->getrights();
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = group_prepare_head($fgroup);
|
||||
|
||||
$h = 0;
|
||||
dolibarr_fiche_head($head, 'rights', $langs->trans("Group").": ".$fgroup->nom);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/fiche.php?id='.$fgroup->id;
|
||||
$head[$h][1] = $langs->trans("GroupCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$fgroup->id;
|
||||
$head[$h][1] = $langs->trans("GroupRights");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Group").": ".$fgroup->nom);
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
||||
174
htdocs/user/ldap.php
Normal file
174
htdocs/user/ldap.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/user/ldap.php
|
||||
\ingroup ldap
|
||||
\brief Page fiche LDAP utilisateur
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
|
||||
|
||||
$user->getrights('commercial');
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("ldap");
|
||||
|
||||
// Protection quand utilisateur externe
|
||||
$contactid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Affichage page
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$fuser = new User($db, $_GET["id"]);
|
||||
$fuser->fetch();
|
||||
$fuser->getrights();
|
||||
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
dolibarr_fiche_head($head, 'ldap', $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Fiche en mode visu
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
|
||||
print '<td>'.$fuser->id.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Nom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td>'.$fuser->nom.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Prenom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td>'.$fuser->prenom.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Login
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Login").'</td>';
|
||||
if ($fuser->ldap_sid)
|
||||
{
|
||||
print '<td class="warning">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>'.$fuser->login.'</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
print_titre($langs->trans("LDAPInformationsForThisUser"));
|
||||
|
||||
// Affichage attributs LDAP
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("LDAPAttributes").'</td>';
|
||||
print '<td>'.$langs->trans("Value").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Lecture LDAP
|
||||
$ldap=new AuthLdap();
|
||||
$result=$ldap->connect();
|
||||
if ($result)
|
||||
{
|
||||
$bind='';
|
||||
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
|
||||
{
|
||||
dolibarr_syslog("ldap.php: authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
|
||||
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("ldap.php: bind",LOG_DEBUG);
|
||||
$bind=$ldap->bind();
|
||||
}
|
||||
|
||||
if ($bind)
|
||||
{
|
||||
// $info["cn"] = $ldap->getUserIdentifier()."=".$fuser->uname;
|
||||
$info["cn"] = trim($fuser->prenom." ".$fuser->nom);
|
||||
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_USER_DN;
|
||||
|
||||
$result=$ldap->search($dn,'(objectClass=*)');
|
||||
|
||||
// Affichage arbre
|
||||
if (sizeof($result))
|
||||
{
|
||||
$html=new Form($db);
|
||||
$html->show_ldap_content($result,0,0,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error('',$ldap);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error('',$ldap);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -25,8 +25,8 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("products");
|
||||
@ -93,43 +93,12 @@ if ($_POST["action"] == 'update')
|
||||
llxHeader();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserRights");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserGUISetup");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
if ($conf->bookmark4u->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("Bookmark4u");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->clicktodial->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("ClickToDial");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
|
||||
dolibarr_fiche_head($head, 'guisetup', $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
|
||||
if ($_GET["action"] == 'edit')
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
|
||||
|
||||
$langs->load("users");
|
||||
|
||||
@ -75,40 +75,13 @@ if ($_GET["id"])
|
||||
$fuser->fetch();
|
||||
$fuser->getrights();
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
$h = 0;
|
||||
dolibarr_fiche_head($head, 'rights', $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserRights");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserGUISetup");
|
||||
$h++;
|
||||
|
||||
if ($conf->bookmark4u->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("Bookmark4u");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->clicktodial->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("ClickToDial");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
||||
@ -423,7 +423,110 @@ class UserGroup
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mise à jour dans l'arbre LDAP
|
||||
* \param user Utilisateur qui effectue la mise à jour
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update_ldap($user)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
//if (! $conf->ldap->enabled || ! $conf->global->LDAP_SYNCHRO_ACTIVE) return 0;
|
||||
|
||||
$info = array();
|
||||
|
||||
dolibarr_syslog("UserGroup.class::update_ldap this->id=".$this->id,LOG_DEBUG);
|
||||
|
||||
$ldap=new AuthLdap();
|
||||
$result=$ldap->connect();
|
||||
if ($result)
|
||||
{
|
||||
$bind='';
|
||||
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
|
||||
{
|
||||
dolibarr_syslog("UserGroup.class::update_ldap authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
|
||||
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("UserGroup.class::update_ldap bind",LOG_DEBUG);
|
||||
$bind=$ldap->bind();
|
||||
}
|
||||
if ($bind)
|
||||
{
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
|
||||
{
|
||||
$info["objectclass"]=array("top",
|
||||
"person",
|
||||
"organizationalPerson",
|
||||
"user");
|
||||
}
|
||||
else
|
||||
{
|
||||
$info["objectclass"]=array("top",
|
||||
"person",
|
||||
"organizationalPerson",
|
||||
"inetOrgPerson");
|
||||
}
|
||||
|
||||
// Champs obligatoires
|
||||
$info["cn"] = trim($this->nom);
|
||||
if ($this->nom) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Name"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Champs optionnels
|
||||
if ($this->note) $info["description"] = $this->note;
|
||||
|
||||
$info["uid"] = "Dolibarr ".$this->id;
|
||||
|
||||
$newdn = "cn=".$info["cn"].",".$conf->global->LDAP_GROUP_DN;
|
||||
$olddn = $newdn;
|
||||
if ($this->old_name) $olddn="cn=".trim($this->old_name).",".$conf->global->LDAP_CONTACT_DN;
|
||||
|
||||
// On supprime et on insère
|
||||
dolibarr_syslog("UserGroup.class::update_ldap olddn=".$olddn." newdn=".$newdn);
|
||||
|
||||
$result = $ldap->delete($olddn);
|
||||
$result = $ldap->add($newdn, $info);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$this->error = ldap_errno($ldap->connection)." ".ldap_error($ldap->connection)." ".$ldap->error;
|
||||
dolibarr_syslog("UserGroup.class::update_ldap ".$this->error,LOG_ERROR);
|
||||
//print_r($info);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("UserGroup.class::update_ldap rowid=".$this->id." added in LDAP");
|
||||
}
|
||||
|
||||
$ldap->unbind();
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = "Error ".ldap_errno($ldap->connection)." ".ldap_error($ldap->connection);
|
||||
dolibarr_syslog("UserGroup.class::update_ldap bind failed",LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Failed to connect to LDAP server !";
|
||||
dolibarr_syslog("UserGroup.class::update_ldap Connexion failed",LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user