|
@@ -58,7 +58,7 @@ if ($action == 'setvalue' && $user->admin) {
|
|
|
$error++;
|
|
|
}
|
|
|
if (!dolibarr_set_const($db, 'LDAP_GROUP_FILTER', GETPOST("filter"), 'chaine', 0, '', $conf->entity)) {
|
|
|
- $error++;
|
|
|
+ $error++;
|
|
|
}
|
|
|
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
|
|
|
$error++;
|
|
@@ -222,12 +222,12 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
|
|
|
|
|
|
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
|
|
|
} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
|
|
|
- $butlabel = $langs->trans("LDAPTestSearch");
|
|
|
- $testlabel = 'testsearchgroup';
|
|
|
- $key = $conf->global->LDAP_KEY_GROUPS;
|
|
|
- $dn = $conf->global->LDAP_GROUP_DN;
|
|
|
- $objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS;
|
|
|
- show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
|
|
|
+ $butlabel = $langs->trans("LDAPTestSearch");
|
|
|
+ $testlabel = 'testsearchgroup';
|
|
|
+ $key = $conf->global->LDAP_KEY_GROUPS;
|
|
|
+ $dn = $conf->global->LDAP_GROUP_DN;
|
|
|
+ $objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS;
|
|
|
+ show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
|
|
|
}
|
|
|
|
|
|
if (function_exists("ldap_connect")) {
|
|
@@ -278,59 +278,59 @@ if (function_exists("ldap_connect")) {
|
|
|
}
|
|
|
|
|
|
if ($action == 'testsearchgroup') {
|
|
|
- // TODO Mutualize code following with other ldap_xxxx.php pages
|
|
|
-
|
|
|
- // Test synchro
|
|
|
- $ldap = new Ldap();
|
|
|
- $result = $ldap->connect_bind();
|
|
|
-
|
|
|
- if ($result > 0) {
|
|
|
- $required_fields = array(
|
|
|
- $conf->global->LDAP_KEY_GROUPS,
|
|
|
- // $conf->global->LDAP_GROUP_FIELD_NAME,
|
|
|
- $conf->global->LDAP_GROUP_FIELD_DESCRIPTION,
|
|
|
- $conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS,
|
|
|
- $conf->global->LDAP_GROUP_FIELD_GROUPID
|
|
|
- );
|
|
|
-
|
|
|
- // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
|
|
|
- $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement")));
|
|
|
-
|
|
|
- // Get from LDAP database an array of results
|
|
|
- $ldapgroups = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, $required_fields, 'group');
|
|
|
- //$ldapgroups = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, '', 'group');
|
|
|
-
|
|
|
- if (is_array($ldapgroups)) {
|
|
|
- $liste = array();
|
|
|
- foreach ($ldapgroups as $key => $ldapgroup) {
|
|
|
- // Define the label string for this group
|
|
|
- $label = '';
|
|
|
- foreach ($required_fields as $value) {
|
|
|
- if ($value) {
|
|
|
- $label .= $value."=".$ldapgroup[$value]." ";
|
|
|
- }
|
|
|
- }
|
|
|
- $liste[$key] = $label;
|
|
|
- }
|
|
|
- } else {
|
|
|
- setEventMessages($ldap->error, $ldap->errors, 'errors');
|
|
|
- }
|
|
|
-
|
|
|
- print "<br>\n";
|
|
|
- print "LDAP search for group:<br>\n";
|
|
|
- print "search: *<br>\n";
|
|
|
- print "userDN: ".$conf->global->LDAP_GROUP_DN."<br>\n";
|
|
|
- print "useridentifier: ".$conf->global->LDAP_KEY_GROUPS."<br>\n";
|
|
|
- print "required_fields: ".implode(',', $required_fields)."<br>\n";
|
|
|
- print "=> ".count($liste)." records<br>\n";
|
|
|
- print "\n<br>";
|
|
|
- } else {
|
|
|
- print img_picto('', 'error').' ';
|
|
|
- print '<font class="error">'.$langs->trans("LDAPSynchroKO");
|
|
|
- print ': '.$ldap->error;
|
|
|
- print '</font><br>';
|
|
|
- print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
|
|
|
- }
|
|
|
+ // TODO Mutualize code following with other ldap_xxxx.php pages
|
|
|
+
|
|
|
+ // Test synchro
|
|
|
+ $ldap = new Ldap();
|
|
|
+ $result = $ldap->connect_bind();
|
|
|
+
|
|
|
+ if ($result > 0) {
|
|
|
+ $required_fields = array(
|
|
|
+ $conf->global->LDAP_KEY_GROUPS,
|
|
|
+ // $conf->global->LDAP_GROUP_FIELD_NAME,
|
|
|
+ $conf->global->LDAP_GROUP_FIELD_DESCRIPTION,
|
|
|
+ $conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS,
|
|
|
+ $conf->global->LDAP_GROUP_FIELD_GROUPID
|
|
|
+ );
|
|
|
+
|
|
|
+ // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
|
|
|
+ $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement")));
|
|
|
+
|
|
|
+ // Get from LDAP database an array of results
|
|
|
+ $ldapgroups = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, $required_fields, 'group');
|
|
|
+ //$ldapgroups = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, '', 'group');
|
|
|
+
|
|
|
+ if (is_array($ldapgroups)) {
|
|
|
+ $liste = array();
|
|
|
+ foreach ($ldapgroups as $key => $ldapgroup) {
|
|
|
+ // Define the label string for this group
|
|
|
+ $label = '';
|
|
|
+ foreach ($required_fields as $value) {
|
|
|
+ if ($value) {
|
|
|
+ $label .= $value."=".$ldapgroup[$value]." ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $liste[$key] = $label;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ setEventMessages($ldap->error, $ldap->errors, 'errors');
|
|
|
+ }
|
|
|
+
|
|
|
+ print "<br>\n";
|
|
|
+ print "LDAP search for group:<br>\n";
|
|
|
+ print "search: *<br>\n";
|
|
|
+ print "userDN: ".$conf->global->LDAP_GROUP_DN."<br>\n";
|
|
|
+ print "useridentifier: ".$conf->global->LDAP_KEY_GROUPS."<br>\n";
|
|
|
+ print "required_fields: ".implode(',', $required_fields)."<br>\n";
|
|
|
+ print "=> ".count($liste)." records<br>\n";
|
|
|
+ print "\n<br>";
|
|
|
+ } else {
|
|
|
+ print img_picto('', 'error').' ';
|
|
|
+ print '<font class="error">'.$langs->trans("LDAPSynchroKO");
|
|
|
+ print ': '.$ldap->error;
|
|
|
+ print '</font><br>';
|
|
|
+ print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|