117 |
('LDAP_CONTACT_DN','".$_POST["contact"]."',0);"; |
('LDAP_CONTACT_DN','".$_POST["contact"]."',0);"; |
118 |
$db->query($sql); |
$db->query($sql); |
119 |
|
|
120 |
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_PROTOCOLVERSION';"; |
121 |
|
$db->query($sql); |
122 |
|
|
123 |
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES |
124 |
|
('LDAP_SERVER_PROTOCOLVERSION','".$_POST["version"]."',0);"; |
125 |
|
$db->query($sql); |
126 |
|
|
127 |
|
|
128 |
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_TYPE';"; |
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_TYPE';"; |
129 |
$db->query($sql); |
$db->query($sql); |
130 |
|
|
156 |
print '<td>'.$langs->trans("Value").'</td><td colspan="2"> </td>'; |
print '<td>'.$langs->trans("Value").'</td><td colspan="2"> </td>'; |
157 |
print "</tr>\n"; |
print "</tr>\n"; |
158 |
|
|
159 |
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST) |
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST) |
160 |
{ |
{ |
161 |
print '<tr><td>'.$langs->trans("LDAPServer").'</td><td>'.LDAP_SERVER_HOST.'</td></tr>'; |
print '<tr><td>'.$langs->trans("LDAPServer").'</td><td>'.LDAP_SERVER_HOST.'</td></tr>'; |
162 |
} |
} |
163 |
else |
else |
164 |
{ |
{ |
165 |
print '<tr><td>'.$langs->trans("LDAPServer").'</td><td>'.$langs->trans("LDAPServerExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("LDAPServer").'</td><td>'.$langs->trans("LDAPServerExample").'</td></tr>'; |
166 |
} |
} |
167 |
if (defined("LDAP_SERVER_PORT") && LDAP_SERVER_PORT) |
if (defined("LDAP_SERVER_PORT") && LDAP_SERVER_PORT) |
168 |
{ |
{ |
169 |
print '<tr><td>'.$langs->trans("LDAPServerPort").'</td><td>'.LDAP_SERVER_PORT.'</td></tr>'; |
print '<tr><td>'.$langs->trans("LDAPServerPort").'</td><td>'.LDAP_SERVER_PORT.'</td></tr>'; |
170 |
} |
} |
171 |
else |
else |
172 |
{ |
{ |
173 |
print '<tr><td>'.$langs->trans("LDAPServerPort").'</td><td>'.$langs->trans("LDAPServerPortExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("LDAPServerPort").'</td><td>'.$langs->trans("LDAPServerPortExample").'</td></tr>'; |
174 |
} |
} |
175 |
|
|
176 |
//suppression pour compatibilité divers config ldap |
//suppression pour compatibilité divers config ldap |
177 |
// |
// |
178 |
//if (defined("LDAP_SUFFIX_DN") && LDAP_SUFFIX_DN) |
//if (defined("LDAP_SUFFIX_DN") && LDAP_SUFFIX_DN) |
179 |
//{ |
//{ |
180 |
// print '<tr><td>'.$langs->trans("LDAPSuffix").'</td><td>'.LDAP_SUFFIX_DN.'</td></tr>'; |
// print '<tr><td>'.$langs->trans("LDAPSuffix").'</td><td>'.LDAP_SUFFIX_DN.'</td></tr>'; |
181 |
//} |
//} |
182 |
//else |
//else |
183 |
//{ |
//{ |
184 |
// print '<tr><td>'.$langs->trans("LDAPSuffix").'</td><td>'.$langs->trans("LDAPSuffixExample").'</td></tr>'; |
// print '<tr><td>'.$langs->trans("LDAPSuffix").'</td><td>'.$langs->trans("LDAPSuffixExample").'</td></tr>'; |
185 |
//} |
//} |
186 |
|
|
187 |
if (defined("LDAP_ADMIN_DN") && LDAP_ADMIN_DN) |
if (defined("LDAP_ADMIN_DN") && LDAP_ADMIN_DN) |
188 |
{ |
{ |
189 |
print '<tr><td>'.$langs->trans("DNAdmin").'</td><td>'.LDAP_ADMIN_DN.'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNAdmin").'</td><td>'.LDAP_ADMIN_DN.'</td></tr>'; |
190 |
} |
} |
191 |
else |
else |
192 |
{ |
{ |
193 |
print '<tr><td>'.$langs->trans("DNAdmin").'</td><td>'.$langs->trans("DNAdminExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNAdmin").'</td><td>'.$langs->trans("DNAdminExample").'</td></tr>'; |
194 |
} |
} |
195 |
if (defined("LDAP_ADMIN_PASS") && LDAP_ADMIN_PASS) |
if (defined("LDAP_ADMIN_PASS") && LDAP_ADMIN_PASS) |
196 |
{ |
{ |
197 |
print '<tr><td>'.$langs->trans("LDAPPassword").'</td><td>********</td></tr>'; |
print '<tr><td>'.$langs->trans("LDAPPassword").'</td><td>********</td></tr>'; |
198 |
} |
} |
199 |
else |
else |
200 |
{ |
{ |
201 |
print '<tr><td>'.$langs->trans("LDAPPassword").'</td><td>'.$langs->trans("LDAPPasswordExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("LDAPPassword").'</td><td>'.$langs->trans("LDAPPasswordExample").'</td></tr>'; |
202 |
} |
} |
203 |
if (defined("LDAP_USER_DN") && LDAP_USER_DN) |
if (defined("LDAP_USER_DN") && LDAP_USER_DN) |
204 |
{ |
{ |
205 |
print '<tr><td>'.$langs->trans("DNUser").'</td><td>'.LDAP_USER_DN.'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNUser").'</td><td>'.LDAP_USER_DN.'</td></tr>'; |
206 |
} |
} |
207 |
else |
else |
208 |
{ |
{ |
209 |
print '<tr><td>'.$langs->trans("DNUser").'</td><td>'.$langs->trans("DNUserExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNUser").'</td><td>'.$langs->trans("DNUserExample").'</td></tr>'; |
210 |
} |
} |
211 |
if (defined("LDAP_GROUP_DN") && LDAP_GROUP_DN) |
if (defined("LDAP_GROUP_DN") && LDAP_GROUP_DN) |
212 |
{ |
{ |
213 |
print '<tr><td>'.$langs->trans("DNGroup").'</td><td>'.LDAP_GROUP_DN.'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNGroup").'</td><td>'.LDAP_GROUP_DN.'</td></tr>'; |
214 |
} |
} |
215 |
else |
else |
216 |
{ |
{ |
217 |
print '<tr><td>'.$langs->trans("DNGroup").'</td><td>'.$langs->trans("DNGroupExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNGroup").'</td><td>'.$langs->trans("DNGroupExample").'</td></tr>'; |
218 |
} |
} |
219 |
if (defined("LDAP_CONTACT_ACTIVE") && LDAP_CONTACT_ACTIVE) |
if (defined("LDAP_CONTACT_ACTIVE") && LDAP_CONTACT_ACTIVE) |
220 |
{ |
{ |
221 |
print '<tr><td>'.$langs->trans("DNContactActive").'</td><td>'.$langs->trans("DNContactActiveYes").'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNContactActive").'</td><td>'.$langs->trans("DNContactActiveYes").'</td></tr>'; |
222 |
} |
} |
223 |
else |
else |
224 |
{ |
{ |
225 |
print '<tr><td>'.$langs->trans("DNContactActive").'</td><td>'.$langs->trans("DNContactActiveExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNContactActive").'</td><td>'.$langs->trans("DNContactActiveExample").'</td></tr>'; |
226 |
} |
} |
227 |
if (defined("LDAP_CONTACT_DN") && LDAP_CONTACT_DN) |
if (defined("LDAP_CONTACT_DN") && LDAP_CONTACT_DN) |
228 |
{ |
{ |
229 |
print '<tr><td>'.$langs->trans("DNContact").'</td><td>'.LDAP_CONTACT_DN.'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNContact").'</td><td>'.LDAP_CONTACT_DN.'</td></tr>'; |
230 |
} |
} |
231 |
else |
else |
232 |
{ |
{ |
233 |
print '<tr><td>'.$langs->trans("DNContact").'</td><td>'.$langs->trans("DNContactExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("DNContact").'</td><td>'.$langs->trans("DNContactExample").'</td></tr>'; |
234 |
} |
} |
235 |
if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE) |
if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE) |
236 |
{ |
{ |
237 |
print '<tr><td>'.$langs->trans("Type").'</td><td>'.LDAP_SERVER_TYPE.'</td></tr>'; |
print '<tr><td>'.$langs->trans("Type").'</td><td>'.LDAP_SERVER_TYPE.'</td></tr>'; |
238 |
} |
} |
239 |
else |
else |
240 |
{ |
{ |
241 |
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("TypeExample").'</td></tr>'; |
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("TypeExample").'</td></tr>'; |
242 |
} |
} |
243 |
|
|
244 |
|
print '<tr><td>'.$langs->trans("Version").'</td><td>'.LDAP_SERVER_PROTOCOLVERSION.'</td></tr>'; |
245 |
|
|
246 |
print '</table>'; |
print '</table>'; |
247 |
|
|
265 |
print '<tr><td>'.$langs->trans("LDAPServerPort").'</td><td>'; |
print '<tr><td>'.$langs->trans("LDAPServerPort").'</td><td>'; |
266 |
if (defined("LDAP_SERVER_PORT") && LDAP_SERVER_PORT) |
if (defined("LDAP_SERVER_PORT") && LDAP_SERVER_PORT) |
267 |
{ |
{ |
268 |
print '<input size="25" type="text" name="port" value="'.LDAP_SERVER_PORT.'">'; |
print '<input size="25" type="text" name="port" value="'.LDAP_SERVER_PORT.'">'; |
269 |
} |
} |
270 |
else |
else |
271 |
{ |
{ |
272 |
print '<input size="25" type="text" name="port" value="389">'; |
print '<input size="25" type="text" name="port" value="389">'; |
273 |
} |
} |
274 |
print '</td></tr>'; |
print '</td></tr>'; |
275 |
|
|
289 |
} |
} |
290 |
else |
else |
291 |
{ |
{ |
292 |
print '<input size="25" type="text" name="pass" value="'.LDAP_ADMIN_PASS.'">'; |
print '<input size="25" type="text" name="pass" value="'.LDAP_ADMIN_PASS.'">'; |
293 |
} |
} |
294 |
print '</td></tr>'; |
print '</td></tr>'; |
295 |
print '<tr><td>'.$langs->trans("DNUser").'</td><td>'; |
print '<tr><td>'.$langs->trans("DNUser").'</td><td>'; |
301 |
print '<tr><td>'.$langs->trans("DNContactActive").'</td><td><select name="activecontact">'; |
print '<tr><td>'.$langs->trans("DNContactActive").'</td><td><select name="activecontact">'; |
302 |
if (defined("LDAP_CONTACT_ACTIVE") && LDAP_CONTACT_ACTIVE == 1) |
if (defined("LDAP_CONTACT_ACTIVE") && LDAP_CONTACT_ACTIVE == 1) |
303 |
{ |
{ |
304 |
print '<option value="1" selected>'.$langs->trans("Yes"); |
print '<option value="1" selected>'.$langs->trans("Yes"); |
305 |
} |
} |
306 |
else |
else |
307 |
{ |
{ |
319 |
print '<tr><td>'.$langs->trans("Type").'</td><td><select name="type">'; |
print '<tr><td>'.$langs->trans("Type").'</td><td><select name="type">'; |
320 |
if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE == activedirectory) |
if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE == activedirectory) |
321 |
{ |
{ |
322 |
print '<option value="activedirectory" selected>Active Directory'; |
print '<option value="activedirectory" selected>Active Directory'; |
323 |
} |
} |
324 |
else |
else |
325 |
{ |
{ |
326 |
if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE == egroupware) |
if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE == egroupware) |
327 |
{ |
{ |
328 |
print '<option value="egroupware" selected>Egroupware'; |
print '<option value="egroupware" selected>Egroupware'; |
329 |
} |
} |
330 |
else |
else |
331 |
{ |
{ |
332 |
print '<option value="openldap" selected>OpenLdap'; |
print '<option value="openldap" selected>OpenLdap'; |
333 |
} |
} |
334 |
} |
} |
335 |
print '<option value="LDAP_SERVER_TYPE">------------------------'; |
print '<option value="LDAP_SERVER_TYPE">------------------------'; |
336 |
print '<option value="openldap">OpenLdap'; |
print '<option value="openldap">OpenLdap'; |
339 |
print '</select>'; |
print '</select>'; |
340 |
print '</td></tr>'; |
print '</td></tr>'; |
341 |
|
|
342 |
|
print '<tr><td>'.$langs->trans("Version").'</td><td><select name="version">'; |
343 |
|
|
344 |
|
if (defined("LDAP_SERVER_PROTOCOLVERSION") && LDAP_SERVER_PROTOCOLVERSION == 3) |
345 |
|
{ |
346 |
|
print '<option value="3" selected>Version 3'; |
347 |
|
} |
348 |
|
else |
349 |
|
{ |
350 |
|
print '<option value="2" selected>Version 2'; |
351 |
|
} |
352 |
|
print '<option value="LDAP_SERVER_PROTOCOLVERSION">------------------------'; |
353 |
|
print '<option value="3">Version 3'; |
354 |
|
print '<option value="2">Version 2'; |
355 |
|
print '</select>'; |
356 |
|
print '</td></tr>'; |
357 |
|
|
358 |
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Modify").'"></td></tr>'; |
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Modify").'"></td></tr>'; |
359 |
print '</table></form>'; |
print '</table></form>'; |
360 |
|
|
373 |
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && LDAP_ADMIN_DN && LDAP_ADMIN_PASS && $_GET["action"] == 'test') |
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && LDAP_ADMIN_DN && LDAP_ADMIN_PASS && $_GET["action"] == 'test') |
374 |
{ |
{ |
375 |
$ds = dolibarr_ldap_connect(); |
$ds = dolibarr_ldap_connect(); |
376 |
/* |
|
377 |
if ($ds) |
if ($ds) |
378 |
{ |
{ |
379 |
print "connexion au serveur ldap réussie<br>"; |
print img_picto('','info'); |
380 |
|
print "connexion au serveur ldap réussie<br>"; |
381 |
} |
} |
382 |
else |
else |
383 |
|
{ |
384 |
|
print img_picto('','alerte'); |
385 |
|
|
386 |
|
print "connexion au serveur ldap échouée"; |
387 |
|
print "<br>"; |
388 |
|
print ldap_error($ds); |
389 |
|
print "<br>"; |
390 |
|
} |
391 |
|
if ((dolibarr_ldap_getversion($ds) == 3)) |
392 |
|
{ |
393 |
|
print img_picto('','info'); |
394 |
|
print "Serveur ldap configuré en version 3<br>"; |
395 |
|
} |
396 |
|
else |
397 |
|
{ |
398 |
|
print img_picto('','info'); |
399 |
|
print "Serveur ldap configuré en version 2<br>"; |
400 |
|
} |
401 |
|
|
402 |
|
$bind = @dolibarr_ldap_bind($ds); |
403 |
|
|
404 |
|
if ($bind) |
405 |
|
{ |
406 |
|
print img_picto('','info'); |
407 |
|
print "connexion au dn $dn réussi<br>"; |
408 |
|
} |
409 |
|
else |
410 |
|
{ |
411 |
|
print img_picto('','alerte'); |
412 |
|
|
413 |
|
print "connexion au dn $dn raté : "; |
414 |
|
print ldap_error($ds); |
415 |
|
print "<br>"; |
416 |
|
} |
417 |
|
|
418 |
|
$unbind = @dolibarr_ldap_unbind($ds); |
419 |
|
|
420 |
|
if ($bind) |
421 |
{ |
{ |
422 |
print "connexion au serveur ldap échouée"; |
print img_picto('','info'); |
423 |
print img_picto('','alerte'); |
print "déconnection du dn $dn réussi<br>"; |
424 |
print "<br>"; |
} |
425 |
} |
else |
426 |
if ((dolibarr_ldap_getversion($ds) == 3)) |
{ |
427 |
{ |
print img_picto('','alerte'); |
428 |
print "Serveur ldap configuré en version 3<br>"; |
|
429 |
} |
print "déconnection du dn $dn raté"; |
430 |
else |
print "<br>"; |
431 |
{ |
} |
|
print "Serveur ldap configuré en version 2<br>"; |
|
|
} |
|
|
*/ |
|
|
$bind = @dolibarr_ldap_bind($ds); |
|
|
|
|
|
if ($bind) |
|
|
{ |
|
|
print "connexion au dn $dn réussi<br>"; |
|
|
} |
|
|
else |
|
|
{ |
|
|
print "connexion au dn $dn raté"; |
|
|
print img_picto('','alerte'); |
|
|
print "<br>"; |
|
|
} |
|
|
|
|
|
$unbind = @dolibarr_ldap_unbind($ds); |
|
|
|
|
|
if ($bind) |
|
|
{ |
|
|
print "déconnection du dn $dn réussi<br>"; |
|
|
} |
|
|
else |
|
|
{ |
|
|
print "déconnection du dn $dn raté"; |
|
|
print img_picto('','alerte'); |
|
|
print "<br>"; |
|
|
} |
|
432 |
} |
} |
433 |
|
|
434 |
$db->close(); |
$db->close(); |