mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop
This commit is contained in:
commit
49e63e1d38
|
|
@ -65,6 +65,9 @@ if (empty($reshook)) {
|
|||
if (!dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
if (!dolibarr_set_const($db, 'LDAP_USERACCOUNTCONTROL', GETPOST("userAccountControl", 'int'), 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
if (!dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
|
|
@ -195,6 +198,11 @@ print '<tr class="oddeven"><td>'.$langs->trans("Type").'</td><td>';
|
|||
print $formldap->selectLdapServerType(getDolGlobalString('LDAP_SERVER_TYPE'), 'type');
|
||||
print '</td><td> </td></tr>';
|
||||
|
||||
// userAccountControl
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPUserAccountControl").'</td><td>';
|
||||
print '<input class="width75" type="text" name="userAccountControl" value="'.getDolGlobalString('LDAP_USERACCOUNTCONTROL', '512').'">';
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPUserAccountControlExample").'</span></td></tr>';
|
||||
|
||||
// Version
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("Version").'</td><td>';
|
||||
print $formldap->selectLdapServerProtocolVersion(getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION'), 'LDAP_SERVER_PROTOCOLVERSION');
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ class modLdap extends DolibarrModules
|
|||
12=>array('LDAP_FIELD_FAX', 'chaine', 'facsimiletelephonenumber', '', 0),
|
||||
13=>array('LDAP_FIELD_MOBILE', 'chaine', 'mobile', '', 0),
|
||||
14=>array('LDAP_GROUP_FILTER', 'chaine', '&(objectClass=groupOfNames)', '', 0),
|
||||
15=>array('LDAP_USERACCOUNTCONTROL', 'int', 512, '', 0),
|
||||
);
|
||||
|
||||
// Boxes
|
||||
|
|
|
|||
|
|
@ -89,6 +89,11 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
$info = $object->_load_ldap_info();
|
||||
$dn = $object->_load_ldap_dn($info);
|
||||
|
||||
//For compatibility with Samba 4 AD
|
||||
if ($ldap->serverType == "activedirectory") {
|
||||
$info['userAccountControl'] = $conf->global->LDAP_USERACCOUNTCONTROL;
|
||||
}
|
||||
|
||||
$result = $ldap->add($dn, $info, $user);
|
||||
}
|
||||
|
||||
|
|
@ -210,6 +215,33 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
} elseif ($action == 'USER_ENABLEDISABLE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (intval($conf->global->LDAP_SYNCHRO_ACTIVE) === Ldap::SYNCHRO_DOLIBARR_TO_LDAP && $conf->global->LDAP_SERVER_TYPE == "activedirectory") {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
if ($result > 0) {
|
||||
$info = $object->_load_ldap_info();
|
||||
$dn = $object->_load_ldap_dn($info);
|
||||
$search = "(" . $object->_load_ldap_dn($info, 2) . ")";
|
||||
$uAC = $ldap->getAttributeValues($search, "userAccountControl");
|
||||
if ($uAC["count"] == 1) {
|
||||
$userAccountControl = intval($uAC[0]);
|
||||
$enabledBitMask = 0x2;
|
||||
$isEnabled = ($userAccountControl & $enabledBitMask) === 0;
|
||||
if ($isEnabled && intval($object->statut) === 1) {
|
||||
$userAccountControl += 2;
|
||||
} elseif (!$isEnabled && intval($object->statut) === 0) {
|
||||
$userAccountControl -= 2;
|
||||
}
|
||||
$info['userAccountControl'] = $userAccountControl;
|
||||
$resUpdate = $ldap->update($dn, $info, $user, $dn);
|
||||
if ($resUpdate < 0) {
|
||||
$this->error = "ErrorLDAP " . $ldap->error;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->error = "ErrorLDAP " . $ldap->error;
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'USER_DELETE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
|
|
@ -314,6 +346,15 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
$result = $ldap->add($dn, $info, $user);
|
||||
}
|
||||
|
||||
// Avoid Ldap error due to empty member
|
||||
if (isset($info['member']) && empty($info['member'])) {
|
||||
unset($info['member']);
|
||||
}
|
||||
|
||||
if ($ldap->serverType == "activedirectory") {
|
||||
$info['sAMAccountName'] = $object->name;
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
$this->error = "ErrorLDAP ".$ldap->error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
|||
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('doncard', 'globalcard'));
|
||||
$hookmanager->initHooks(array($object->element.'card', 'globalcard'));
|
||||
|
||||
$upload_dir = $conf->don->dir_output;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,4 +28,6 @@ PasswordOfUserInLDAP=Password of user in LDAP
|
|||
LDAPPasswordHashType=Password hash type
|
||||
LDAPPasswordHashTypeExample=Type of password hash used on the server
|
||||
SupportedForLDAPExportScriptOnly=Only supported by an ldap export script
|
||||
SupportedForLDAPImportScriptOnly=Only supported by an ldap import script
|
||||
SupportedForLDAPImportScriptOnly=Only supported by an ldap import script
|
||||
LDAPUserAccountControl = userAccountControl on creation (active directory)
|
||||
LDAPUserAccountControlExample = 512 Normal Account / 546 Normal Account + No Passwd + Disabled (see : https://fr.wikipedia.org/wiki/Active_Directory)
|
||||
Loading…
Reference in New Issue
Block a user