Fix: Set LDAP password when LDAP key changed
This commit is contained in:
parent
46cc23c568
commit
cb9d627f02
@ -1958,6 +1958,7 @@ class Adherent extends CommonObject
|
|||||||
$info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS);
|
$info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS);
|
||||||
|
|
||||||
$this->fullname=$this->getFullName($langs);
|
$this->fullname=$this->getFullName($langs);
|
||||||
|
|
||||||
// For avoid ldap error when firstname and lastname are empty
|
// For avoid ldap error when firstname and lastname are empty
|
||||||
if ($this->morphy == 'mor' && empty($this->fullname)) {
|
if ($this->morphy == 'mor' && empty($this->fullname)) {
|
||||||
$this->fullname = $this->societe;
|
$this->fullname = $this->societe;
|
||||||
@ -1983,11 +1984,10 @@ class Adherent extends CommonObject
|
|||||||
// Check if it is the LDAP key and if its value has been changed
|
// Check if it is the LDAP key and if its value has been changed
|
||||||
if (! empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname)
|
if (! empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname)
|
||||||
{
|
{
|
||||||
if (! empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) $keymodified=true;
|
if (! empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) $keymodified=true; // For check if LDAP key has been modified
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
|
if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
|
||||||
if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
|
if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
|
||||||
if ($this->societe && ! empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->societe;
|
if ($this->societe && ! empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->societe;
|
||||||
@ -2007,13 +2007,13 @@ class Adherent extends CommonObject
|
|||||||
if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
|
if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
|
||||||
|
|
||||||
// When password is modified
|
// When password is modified
|
||||||
if ($this->pass)
|
if (! empty($this->pass))
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte
|
if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte
|
||||||
if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // md5 for OpenLdap TODO add type of encryption
|
if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption)
|
||||||
}
|
}
|
||||||
// When LDAP key is modified and password no defined
|
// Set LDAP password if possible
|
||||||
else if ($keymodified)
|
else
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
|
if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
|
||||||
{
|
{
|
||||||
@ -2021,7 +2021,7 @@ class Adherent extends CommonObject
|
|||||||
if (empty($conf->global->MAIN_SECURITY_HASH_ALGO))
|
if (empty($conf->global->MAIN_SECURITY_HASH_ALGO))
|
||||||
{
|
{
|
||||||
if ($this->pass_indatabase_crypted && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
|
if ($this->pass_indatabase_crypted && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
|
||||||
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase_crypted, 5); // md5 for OpenLdap TODO add type of encryption
|
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase_crypted, 5); // Create OpenLDAP MD5 password from Dolibarr MD5 password
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,26 +59,23 @@ if (! $result)
|
|||||||
|
|
||||||
if ($action == 'dolibarr2ldap')
|
if ($action == 'dolibarr2ldap')
|
||||||
{
|
{
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$result=$ldap->connect_bind();
|
$result=$ldap->connect_bind();
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
$info=$object->_load_ldap_info();
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
$olddn=$dn; // We can say that old dn = dn as we force synchro
|
$olddn=$dn; // We can say that old dn = dn as we force synchro
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user,$olddn);
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
|
|
||||||
if ($result >= 0)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("MemberSynchronized"), null, 'mesgs');
|
|
||||||
$db->commit();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if ($result >= 0) {
|
||||||
|
setEventMessages($langs->trans("MemberSynchronized"), null, 'mesgs');
|
||||||
|
}
|
||||||
|
else {
|
||||||
setEventMessages($ldap->errors, $ldap->error, 'errors');
|
setEventMessages($ldap->errors, $ldap->error, 'errors');
|
||||||
$db->rollback();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -184,7 +184,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
|
||||||
print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
|
print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
|
||||||
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
|
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
|
||||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_FIRSTNAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FIRSTNAME)?' checked':'')."></td>";
|
print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Login unix
|
// Login unix
|
||||||
@ -208,7 +208,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
|
||||||
print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_FIELD_PASSWORD.'">';
|
print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_FIELD_PASSWORD.'">';
|
||||||
print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
|
print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
|
||||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_PASSWORD"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PASSWORD)?' checked':'')."></td>";
|
print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Password crypted
|
// Password crypted
|
||||||
@ -216,7 +216,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
|
||||||
print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_FIELD_PASSWORD_CRYPTED.'">';
|
print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_FIELD_PASSWORD_CRYPTED.'">';
|
||||||
print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
|
print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
|
||||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_PASSWORD_CRYPTED"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PASSWORD_CRYPTED)?' checked':'')."></td>";
|
print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Mail
|
// Mail
|
||||||
@ -232,7 +232,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
|
||||||
print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
|
print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
|
||||||
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
|
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
|
||||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_PHONE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PHONE)?' checked':'')."></td>";
|
print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Mobile
|
// Mobile
|
||||||
@ -240,7 +240,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
|
||||||
print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
|
print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
|
||||||
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
|
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
|
||||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_MOBILE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MOBILE)?' checked':'')."></td>";
|
print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Skype
|
// Skype
|
||||||
@ -256,7 +256,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
|
||||||
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
|
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
|
||||||
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
|
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
|
||||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_FAX"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FAX)?' checked':'')."></td>";
|
print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
@ -264,7 +264,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTitle").'</td><td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTitle").'</td><td>';
|
||||||
print '<input size="25" type="text" name="fieldtitle" value="'.$conf->global->LDAP_FIELD_TITLE.'">';
|
print '<input size="25" type="text" name="fieldtitle" value="'.$conf->global->LDAP_FIELD_TITLE.'">';
|
||||||
print '</td><td>'.$langs->trans("LDAPFieldTitleExample").'</td>';
|
print '</td><td>'.$langs->trans("LDAPFieldTitleExample").'</td>';
|
||||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_TITLE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_TITLE)?' checked':'')."></td>";
|
print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Note
|
// Note
|
||||||
@ -272,7 +272,7 @@ print '</tr>';
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("Note").'</td><td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("Note").'</td><td>';
|
||||||
print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_FIELD_DESCRIPTION.'">';
|
print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_FIELD_DESCRIPTION.'">';
|
||||||
print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
|
print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
|
||||||
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_DESCRIPTION)?' checked':'')."></td>";
|
print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Sid
|
// Sid
|
||||||
|
|||||||
@ -2265,51 +2265,81 @@ class User extends CommonObject
|
|||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
$info=array();
|
$info=array();
|
||||||
|
$keymodified=false;
|
||||||
|
|
||||||
// Object classes
|
// Object classes
|
||||||
$info["objectclass"]=explode(',',$conf->global->LDAP_USER_OBJECT_CLASS);
|
$info["objectclass"]=explode(',',$conf->global->LDAP_USER_OBJECT_CLASS);
|
||||||
|
|
||||||
$this->fullname=$this->getFullName($langs);
|
$this->fullname=$this->getFullName($langs);
|
||||||
|
|
||||||
// Champs
|
// Possible LDAP KEY (constname => varname)
|
||||||
if ($this->fullname && ! empty($conf->global->LDAP_FIELD_FULLNAME)) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
|
$ldapkey = array(
|
||||||
if ($this->lastname && ! empty($conf->global->LDAP_FIELD_NAME)) $info[$conf->global->LDAP_FIELD_NAME] = $this->lastname;
|
'LDAP_FIELD_FULLNAME' => 'fullname',
|
||||||
if ($this->firstname && ! empty($conf->global->LDAP_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->firstname;
|
'LDAP_FIELD_NAME' => 'lastname',
|
||||||
if ($this->login && ! empty($conf->global->LDAP_FIELD_LOGIN)) $info[$conf->global->LDAP_FIELD_LOGIN] = $this->login;
|
'LDAP_FIELD_LOGIN' => 'login',
|
||||||
if ($this->login && ! empty($conf->global->LDAP_FIELD_LOGIN_SAMBA)) $info[$conf->global->LDAP_FIELD_LOGIN_SAMBA] = $this->login;
|
'LDAP_FIELD_LOGIN_SAMBA' => 'login',
|
||||||
if ($this->ldap_sid && ! empty($conf->global->LDAP_FIELD_SID)) $info[$conf->global->LDAP_FIELD_SID] = $this->ldap_sid;
|
'LDAP_FIELD_MAIL' => 'email',
|
||||||
if ($this->societe_id > 0)
|
'LDAP_FIELD_SID' => 'ldap_sid',
|
||||||
{
|
'LDAP_FIELD_SKYPE' => 'skype'
|
||||||
$soc = new Societe($this->db);
|
);
|
||||||
$soc->fetch($this->societe_id);
|
|
||||||
|
|
||||||
$info["o"] = $soc->lastname;
|
// Champs
|
||||||
if ($soc->client == 1) $info["businessCategory"] = "Customers";
|
foreach ($ldapkey as $constname => $varname)
|
||||||
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
|
{
|
||||||
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
|
if (! empty($this->$varname) && ! empty($conf->global->$constname))
|
||||||
|
{
|
||||||
|
$info[$conf->global->$constname] = $this->$varname;
|
||||||
|
|
||||||
|
// Check if it is the LDAP key and if its value has been changed
|
||||||
|
if (! empty($conf->global->LDAP_KEY_USERS) && $conf->global->LDAP_KEY_USERS == $conf->global->$constname)
|
||||||
|
{
|
||||||
|
if (! empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) $keymodified=true; // For check if LDAP key has been modified
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->firstname && ! empty($conf->global->LDAP_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->firstname;
|
||||||
if ($this->address && ! empty($conf->global->LDAP_FIELD_ADDRESS)) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
|
if ($this->address && ! empty($conf->global->LDAP_FIELD_ADDRESS)) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
|
||||||
if ($this->zip && ! empty($conf->global->LDAP_FIELD_ZIP)) $info[$conf->global->LDAP_FIELD_ZIP] = $this->zip;
|
if ($this->zip && ! empty($conf->global->LDAP_FIELD_ZIP)) $info[$conf->global->LDAP_FIELD_ZIP] = $this->zip;
|
||||||
if ($this->town && ! empty($conf->global->LDAP_FIELD_TOWN)) $info[$conf->global->LDAP_FIELD_TOWN] = $this->town;
|
if ($this->town && ! empty($conf->global->LDAP_FIELD_TOWN)) $info[$conf->global->LDAP_FIELD_TOWN] = $this->town;
|
||||||
if ($this->office_phone && ! empty($conf->global->LDAP_FIELD_PHONE)) $info[$conf->global->LDAP_FIELD_PHONE] = $this->office_phone;
|
if ($this->office_phone && ! empty($conf->global->LDAP_FIELD_PHONE)) $info[$conf->global->LDAP_FIELD_PHONE] = $this->office_phone;
|
||||||
if ($this->user_mobile && ! empty($conf->global->LDAP_FIELD_MOBILE)) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->user_mobile;
|
if ($this->user_mobile && ! empty($conf->global->LDAP_FIELD_MOBILE)) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->user_mobile;
|
||||||
if ($this->office_fax && ! empty($conf->global->LDAP_FIELD_FAX)) $info[$conf->global->LDAP_FIELD_FAX] = $this->office_fax;
|
if ($this->office_fax && ! empty($conf->global->LDAP_FIELD_FAX)) $info[$conf->global->LDAP_FIELD_FAX] = $this->office_fax;
|
||||||
if ($this->note && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note;
|
if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note_public;
|
||||||
if ($this->email && ! empty($conf->global->LDAP_FIELD_MAIL)) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
|
if ($this->socid > 0)
|
||||||
if ($this->skype && ! empty($conf->global->LDAP_FIELD_SKYPE)) $info[$conf->global->LDAP_FIELD_SKYPE] = $this->skype;
|
|
||||||
|
|
||||||
// Password
|
|
||||||
if ($this->pass && ! empty($conf->global->LDAP_FIELD_PASSWORD)) $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte
|
|
||||||
if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
|
|
||||||
{
|
{
|
||||||
if ($this->pass_indatabase_crypted && ! empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) {
|
$soc = new Societe($this->db);
|
||||||
$info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase_crypted, 5); // md5 for OpenLdap TODO add type of encryption
|
$soc->fetch($this->socid);
|
||||||
|
|
||||||
|
$info["o"] = $soc->name;
|
||||||
|
if ($soc->client == 1) $info["businessCategory"] = "Customers";
|
||||||
|
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
|
||||||
|
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When password is modified
|
||||||
|
if (! empty($this->pass))
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->LDAP_FIELD_PASSWORD)) $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte
|
||||||
|
if (! empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption)
|
||||||
}
|
}
|
||||||
|
// Set LDAP password if possible
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($this->pass && ! empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) {
|
if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
|
||||||
$info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // md5 for OpenLdap TODO add type of encryption
|
{
|
||||||
|
// Just for the default MD5 !
|
||||||
|
if (empty($conf->global->MAIN_SECURITY_HASH_ALGO))
|
||||||
|
{
|
||||||
|
if ($this->pass_indatabase_crypted && ! empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) {
|
||||||
|
$info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase_crypted, 5); // Create OpenLDAP MD5 password from Dolibarr MD5 password
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use $this->pass_indatabase value if exists
|
||||||
|
else if (! empty($this->pass_indatabase))
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->LDAP_FIELD_PASSWORD)) $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte
|
||||||
|
if (! empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,28 +57,27 @@ $parameters=array('id'=>$socid);
|
|||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook))
|
||||||
if ($_GET["action"] == 'dolibarr2ldap') {
|
{
|
||||||
$db->begin();
|
if ($_GET["action"] == 'dolibarr2ldap')
|
||||||
|
{
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
$olddn = $dn; // We can say that old dn = dn as we force synchro
|
$olddn = $dn; // We can say that old dn = dn as we force synchro
|
||||||
|
|
||||||
$result = $ldap->update($dn, $info, $user, $olddn);
|
$result = $ldap->update($dn, $info, $user, $olddn);
|
||||||
|
|
||||||
if ($result >= 0)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("UserSynchronized"), null, 'mesgs');
|
|
||||||
$db->commit();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if ($result >= 0) {
|
||||||
|
setEventMessages($langs->trans("UserSynchronized"), null, 'mesgs');
|
||||||
|
}
|
||||||
|
else {
|
||||||
setEventMessages($ldap->error, $ldap->errors, 'errors');
|
setEventMessages($ldap->error, $ldap->errors, 'errors');
|
||||||
$db->rollback();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user