This commit is contained in:
Laurent Destailleur 2018-04-12 15:17:15 +02:00
parent dd022ee423
commit a8878c3f7e
2 changed files with 74 additions and 50 deletions

View File

@ -1,5 +1,4 @@
# Dolibarr language file - Source file is en_US - ldap # Dolibarr language file - Source file is en_US - ldap
DomainPassword=Password for domain
YouMustChangePassNextLogon=Password for user <b>%s</b> on the domain <b>%s</b> must be changed. YouMustChangePassNextLogon=Password for user <b>%s</b> on the domain <b>%s</b> must be changed.
UserMustChangePassNextLogon=User must change password on the domain %s UserMustChangePassNextLogon=User must change password on the domain %s
LDAPInformationsForThisContact=Information in LDAP database for this contact LDAPInformationsForThisContact=Information in LDAP database for this contact
@ -25,3 +24,4 @@ MemberTypeSynchronized=Member type synchronized
ContactSynchronized=Contact synchronized ContactSynchronized=Contact synchronized
ForceSynchronize=Force synchronizing Dolibarr -> LDAP ForceSynchronize=Force synchronizing Dolibarr -> LDAP
ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility. ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility.
PasswordOfUserInLDAP=Password of user in LDAP

View File

@ -335,7 +335,7 @@ if (empty($reshook)) {
$object->gender = GETPOST("gender", 'alpha'); $object->gender = GETPOST("gender", 'alpha');
$birth = dol_mktime(0, 0, 0, GETPOST('birthmonth'), GETPOST('birthday'), GETPOST('birthyear')); $birth = dol_mktime(0, 0, 0, GETPOST('birthmonth'), GETPOST('birthday'), GETPOST('birthyear'));
$object->birth = $birth; $object->birth = $birth;
$object->pass = GETPOST("password"); $object->pass = GETPOST("password",'none');
$object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key;
if (! empty($user->admin)) $object->admin = GETPOST("admin"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request if (! empty($user->admin)) $object->admin = GETPOST("admin"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request
$object->address = GETPOST('address', 'alpha'); $object->address = GETPOST('address', 'alpha');
@ -349,20 +349,20 @@ if (empty($reshook)) {
$object->skype = GETPOST("skype", 'alpha'); $object->skype = GETPOST("skype", 'alpha');
$object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha'));
$object->job = GETPOST("job", 'alpha'); $object->job = GETPOST("job", 'alpha');
$object->signature = GETPOST("signature"); $object->signature = GETPOST("signature",'none');
$object->accountancy_code = GETPOST("accountancy_code"); $object->accountancy_code = GETPOST("accountancy_code",'alpha');
$object->openid = GETPOST("openid"); $object->openid = GETPOST("openid",'alpha');
$object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; $object->fk_user = GETPOST("fk_user",'int') > 0 ? GETPOST("fk_user",'int') : 0;
$object->employee = GETPOST('employee'); $object->employee = GETPOST('employee');
$object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; $object->thm = GETPOST("thm",'alphanohtml') != '' ? GETPOST("thm",'alphanohtml') : '';
$object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; $object->tjm = GETPOST("tjm",'alphanohtml') != '' ? GETPOST("tjm",'alphanohtml') : '';
$object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; $object->salary = GETPOST("salary",'alphanohtml') != '' ? GETPOST("salary",'alphanohtml') : '';
$object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; $object->salaryextra = GETPOST("salaryextra",'alphanohtml') != '' ? GETPOST("salaryextra",'alphanohtml') : '';
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; $object->weeklyhours = GETPOST("weeklyhours",'alphanohtml') != '' ? GETPOST("weeklyhours",'alphanohtml') : '';
$object->color = GETPOST("color") != '' ? GETPOST("color") : ''; $object->color = GETPOST("color",'alpha') != '' ? GETPOST("color",'alpha') : '';
$dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear')); $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth','int'), GETPOST('dateemploymentday','int'), GETPOST('dateemploymentyear','int'));
$object->dateemployment = $dateemployment; $object->dateemployment = $dateemployment;
if (! empty($conf->multicompany->enabled)) if (! empty($conf->multicompany->enabled))
@ -781,7 +781,7 @@ if ($action == 'create' || $action == 'adduserldap')
} }
else else
{ {
print '<input class="maxwidth200" maxsize="24" type="text" name="login" value="'.GETPOST('login').'">'; print '<input class="maxwidth200" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(GETPOST('login','alpha')).'">';
} }
print '</td></tr>'; print '</td></tr>';
@ -796,23 +796,29 @@ if ($action == 'create' || $action == 'adduserldap')
// Password // Password
print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td>';
print '<td>'; print '<td>';
if (! empty($ldap_sid)) $valuetoshow='';
if (preg_match('/ldap/',$dolibarr_main_authentication))
{ {
print 'Mot de passe du domaine'; $valuetoshow.=($valuetoshow?', ':'').$langs->trans("PasswordOfUserInLDAP");
} }
else if (preg_match('/http/',$dolibarr_main_authentication))
{ {
if (! empty($ldap_pass)) $valuetoshow.=($valuetoshow?', ':'').$langs->trans("HTTPBasicPassword");
}
if (preg_match('/dolibarr/',$dolibarr_main_authentication))
{
if (! empty($ldap_pass)) // For very old system comaptibilty. Now clear password can't be viewed from LDAP read
{ {
print '<input type="hidden" name="password" value="'.$ldap_pass.'">'; $valuetoshow.= ($valuetoshow?', ':'').'<input type="hidden" name="password" value="'.$ldap_pass.'">'; // Dolibarr password is preffiled with LDAP known password
print preg_replace('/./i','*',$ldap_pass); $valuetoshow.= preg_replace('/./i','*',$ldap_pass);
} }
else else
{ {
// We do not use a field password but a field text to show new password to use. // We do not use a field password but a field text to show new password to use.
print '<input size="30" maxsize="32" type="text" name="password" value="'.$password.'" autocomplete="off">'; $valuetoshow.= ($valuetoshow?', ':'').'<input size="30" maxsize="32" type="text" name="password" value="'.$password.'" autocomplete="new-password">';
} }
} }
print $valuetoshow;
print '</td></tr>'; print '</td></tr>';
if(! empty($conf->api->enabled)) if(! empty($conf->api->enabled))
@ -1315,36 +1321,50 @@ else
// Password // Password
print '<tr><td>'.$langs->trans("Password").'</td>'; print '<tr><td>'.$langs->trans("Password").'</td>';
if (! empty($object->ldap_sid))
print '<td>';
$valuetoshow='';
if (preg_match('/ldap/',$dolibarr_main_authentication))
{ {
if ($passDoNotExpire) if (! empty($object->ldap_sid))
{ {
print '<td>'.$langs->trans("LdapUacf_".$statutUACF).'</td>'; if ($passDoNotExpire)
} {
else if($userChangePassNextLogon) $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("LdapUacf_".$statutUACF);
{ }
print '<td class="warning">'.$langs->trans("UserMustChangePassNextLogon",$ldap->domainFQDN).'</td>'; else if($userChangePassNextLogon)
} {
else if($userDisabled) $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').'<span class="warning">'.$langs->trans("UserMustChangePassNextLogon",$ldap->domainFQDN).'</span>';
{ }
print '<td class="warning">'.$langs->trans("LdapUacf_".$statutUACF,$ldap->domainFQDN).'</td>'; else if($userDisabled)
{
$valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').'<span class="warning">'.$langs->trans("LdapUacf_".$statutUACF,$ldap->domainFQDN).'</span>';
}
else
{
$valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP");
}
} }
else else
{ {
print '<td>'.$langs->trans("DomainPassword").'</td>'; $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP");
} }
} }
else if (preg_match('/http/',$dolibarr_main_authentication))
{ {
print '<td>'; $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("HTTPBasicPassword");
if ($object->pass) print preg_replace('/./i','*',$object->pass); }
if (preg_match('/dolibarr/',$dolibarr_main_authentication))
{
if ($object->pass) $valuetoshow.= preg_replace('/./i','*',$object->pass);
else else
{ {
if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; if ($user->admin) $valuetoshow.= ($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
else print $langs->trans("Hidden"); else $valuetoshow.= ($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("Hidden");
} }
print "</td>";
} }
print $valuetoshow;
print "</td>";
print '</tr>'."\n"; print '</tr>'."\n";
// API key // API key
@ -1883,23 +1903,27 @@ else
// Pass // Pass
print '<tr><td>'.$langs->trans("Password").'</td>'; print '<tr><td>'.$langs->trans("Password").'</td>';
print '<td>'; print '<td>';
if ($object->ldap_sid) $valuetoshow='';
if (preg_match('/ldap/',$dolibarr_main_authentication))
{ {
$text=$langs->trans("DomainPassword"); $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP");
} }
else if ($caneditpassword) if (preg_match('/http/',$dolibarr_main_authentication))
{ {
$text='<input size="12" maxlength="32" type="password" class="flat" name="password" value="'.$object->pass.'" autocomplete="new-password">'; $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning');
if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') }
if (preg_match('/dolibarr/',$dolibarr_main_authentication))
{
if ($caneditpassword)
{ {
$text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning'); $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').'<input size="12" maxlength="32" type="password" class="flat" name="password" value="'.$object->pass.'" autocomplete="new-password">';
}
else
{
$valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').preg_replace('/./i','*',$object->pass);
} }
} }
else print $valuetoshow;
{
$text=preg_replace('/./i','*',$object->pass);
}
print $text;
print "</td></tr>\n"; print "</td></tr>\n";
// API key // API key