ldap_members.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  4. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  5. * Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
  6. * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/admin/ldap_members.php
  23. * \ingroup ldap member
  24. * \brief Page d'administration/configuration du module Ldap adherent
  25. */
  26. require("../main.inc.php");
  27. require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
  28. require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
  29. require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
  30. require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
  31. require_once(DOL_DOCUMENT_ROOT."/lib/ldap.lib.php");
  32. $langs->load("admin");
  33. $langs->load("errors");
  34. if (!$user->admin)
  35. accessforbidden();
  36. /*
  37. * Actions
  38. */
  39. if ($_GET["action"] == 'setvalue' && $user->admin)
  40. {
  41. $error=0;
  42. if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN',$_POST["user"],'chaine',0,'',$conf->entity)) $error++;
  43. if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
  44. // Members
  45. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME',$_POST["fieldfullname"],'chaine',0,'',$conf->entity)) $error++;
  46. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN',$_POST["fieldlogin"],'chaine',0,'',$conf->entity)) $error++;
  47. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA',$_POST["fieldloginsamba"],'chaine',0,'',$conf->entity)) $error++;
  48. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD',$_POST["fieldpassword"],'chaine',0,'',$conf->entity)) $error++;
  49. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED',$_POST["fieldpasswordcrypted"],'chaine',0,'',$conf->entity)) $error++;
  50. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
  51. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME',$_POST["fieldfirstname"],'chaine',0,'',$conf->entity)) $error++;
  52. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL',$_POST["fieldmail"],'chaine',0,'',$conf->entity)) $error++;
  53. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE',$_POST["fieldphone"],'chaine',0,'',$conf->entity)) $error++;
  54. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO',$_POST["fieldphoneperso"],'chaine',0,'',$conf->entity)) $error++;
  55. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE',$_POST["fieldmobile"],'chaine',0,'',$conf->entity)) $error++;
  56. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX',$_POST["fieldfax"],'chaine',0,'',$conf->entity)) $error++;
  57. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS',$_POST["fieldaddress"],'chaine',0,'',$conf->entity)) $error++;
  58. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP',$_POST["fieldzip"],'chaine',0,'',$conf->entity)) $error++;
  59. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN',$_POST["fieldtown"],'chaine',0,'',$conf->entity)) $error++;
  60. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY',$_POST["fieldcountry"],'chaine',0,'',$conf->entity)) $error++;
  61. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION',$_POST["fielddescription"],'chaine',0,'',$conf->entity)) $error++;
  62. if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE',$_POST["fieldbirthdate"],'chaine',0,'',$conf->entity)) $error++;
  63. if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS',$_POST["fieldstatus"],'chaine',0,'',$conf->entity)) $error++;
  64. if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', $_POST["fieldendlastsubscription"],'chaine',0,'',$conf->entity)) $error++;
  65. // Subscriptions
  66. if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', $_POST["fieldfirstsubscriptiondate"],'chaine',0,'',$conf->entity)) $error++;
  67. if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT',$_POST["fieldfirstsubscriptionamount"],'chaine',0,'',$conf->entity)) $error++;
  68. if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', $_POST["fieldlastsubscriptiondate"],'chaine',0,'',$conf->entity)) $error++;
  69. if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', $_POST["fieldlastsubscriptionamount"],'chaine',0,'',$conf->entity)) $error++;
  70. // This one must be after the others
  71. $valkey='';
  72. $key=$_POST["key"];
  73. if ($key) $valkey=$conf->global->$key;
  74. if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
  75. if ($error)
  76. {
  77. dol_print_error($db->error());
  78. }
  79. }
  80. /*
  81. * View
  82. */
  83. llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
  84. print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
  85. $head = ldap_prepare_head();
  86. // Test si fonction LDAP actives
  87. if (! function_exists("ldap_connect"))
  88. {
  89. $mesg=$langs->trans("LDAPFunctionsNotAvailableOnPHP");
  90. }
  91. if ($mesg) print '<div class="error">'.$mesg.'</div>';
  92. dol_fiche_head($head, 'members', $langs->trans("LDAPSetup"));
  93. print $langs->trans("LDAPDescMembers").'<br>';
  94. print '<br>';
  95. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
  96. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  97. $html=new Form($db);
  98. print '<table class="noborder" width="100%">';
  99. $var=true;
  100. print '<tr class="liste_titre">';
  101. print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembers").'</td>';
  102. print "</tr>\n";
  103. // DN Pour les adherents
  104. $var=!$var;
  105. print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberDn").'</span></td><td>';
  106. print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
  107. print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
  108. print '<td>&nbsp;</td>';
  109. print '</tr>';
  110. // List of object class used to define attributes in structure
  111. $var=!$var;
  112. print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberObjectClassList").'</span></td><td>';
  113. print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_OBJECT_CLASS.'">';
  114. print '</td><td>'.$langs->trans("LDAPMemberObjectClassListExample").'</td>';
  115. print '<td>&nbsp;</td>';
  116. print '</tr>';
  117. print '</table>';
  118. print '<br>';
  119. print '<table class="noborder" width="100%">';
  120. $var=true;
  121. print '<tr class="liste_titre">';
  122. print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
  123. print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
  124. print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
  125. print "</tr>\n";
  126. // Filtre
  127. // Common name
  128. $var=!$var;
  129. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
  130. print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_FIELD_FULLNAME.'">';
  131. print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
  132. print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_FULLNAME)?' checked="true"':'')."></td>";
  133. print '</tr>';
  134. // Name
  135. $var=!$var;
  136. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
  137. print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_MEMBER_FIELD_NAME.'">';
  138. print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
  139. print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_NAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_NAME)?' checked="true"':'')."></td>";
  140. print '</tr>';
  141. // Firstname
  142. $var=!$var;
  143. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
  144. print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME.'">';
  145. print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
  146. print '<td align="right">&nbsp;</td>';
  147. print '</tr>';
  148. // Login unix
  149. $var=!$var;
  150. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
  151. print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN.'">';
  152. print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
  153. print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_LOGIN)?' checked="true"':'')."></td>";
  154. print '</tr>';
  155. // Login samba
  156. $var=!$var;
  157. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
  158. print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA.'">';
  159. print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
  160. print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA)?' checked="true"':'')."></td>";
  161. print '</tr>';
  162. // Password not crypted
  163. $var=!$var;
  164. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
  165. print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD.'">';
  166. print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
  167. print '<td align="right">&nbsp;</td>';
  168. print '</tr>';
  169. // Password crypted
  170. $var=!$var;
  171. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
  172. print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED.'">';
  173. print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
  174. print '<td align="right">&nbsp;</td>';
  175. print '</tr>';
  176. // Mail
  177. $var=!$var;
  178. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
  179. print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_MEMBER_FIELD_MAIL.'">';
  180. print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
  181. print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_MAIL"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_MAIL)?' checked="true"':'')."></td>";
  182. print '</tr>';
  183. // Phone pro
  184. $var=!$var;
  185. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
  186. print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE.'">';
  187. print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
  188. print '<td align="right">&nbsp;</td>';
  189. print '</tr>';
  190. // Phone perso
  191. $var=!$var;
  192. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
  193. print '<input size="25" type="text" name="fieldphoneperso" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO.'">';
  194. print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
  195. print '<td align="right">&nbsp;</td>';
  196. print '</tr>';
  197. // Mobile
  198. $var=!$var;
  199. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
  200. print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_MEMBER_FIELD_MOBILE.'">';
  201. print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
  202. print '<td align="right">&nbsp;</td>';
  203. print '</tr>';
  204. // Fax
  205. $var=!$var;
  206. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
  207. print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_MEMBER_FIELD_FAX.'">';
  208. print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
  209. print '<td align="right">&nbsp;</td>';
  210. print '</tr>';
  211. // Address
  212. $var=!$var;
  213. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
  214. print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_MEMBER_FIELD_ADDRESS.'">';
  215. print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
  216. print '<td align="right">&nbsp;</td>';
  217. print '</tr>';
  218. // CP
  219. $var=!$var;
  220. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
  221. print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_MEMBER_FIELD_ZIP.'">';
  222. print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
  223. print '<td align="right">&nbsp;</td>';
  224. print '</tr>';
  225. // Ville
  226. $var=!$var;
  227. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
  228. print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_MEMBER_FIELD_TOWN.'">';
  229. print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
  230. print '<td align="right">&nbsp;</td>';
  231. print '</tr>';
  232. // Pays
  233. $var=!$var;
  234. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
  235. print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_MEMBER_FIELD_COUNTRY.'">';
  236. print '</td><td>&nbsp;</td>';
  237. print '<td align="right">&nbsp;</td>';
  238. print '</tr>';
  239. // Description
  240. $var=!$var;
  241. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
  242. print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION.'">';
  243. print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
  244. print '<td align="right">&nbsp;</td>';
  245. print '</tr>';
  246. // Date naissance
  247. $var=!$var;
  248. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldBirthdate").'</td><td>';
  249. print '<input size="25" type="text" name="fieldbirthdate" value="'.$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE.'">';
  250. print '</td><td>&nbsp;</td>';
  251. print '<td align="right">&nbsp;</td>';
  252. print '</tr>';
  253. // Status
  254. $var=!$var;
  255. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldStatus").'</td><td>';
  256. print '<input size="25" type="text" name="fieldstatus" value="'.$conf->global->LDAP_FIELD_MEMBER_STATUS.'">';
  257. print '</td><td>&nbsp;</td>';
  258. print '<td align="right">&nbsp;</td>';
  259. print '</tr>';
  260. // First subscription date
  261. $var=!$var;
  262. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstSubscriptionDate").'</td><td>';
  263. print '<input size="25" type="text" name="fieldfirstsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE.'">';
  264. print '</td><td>&nbsp;</td>';
  265. print '<td align="right">&nbsp;</td>';
  266. print '</tr>';
  267. // First subscription amount
  268. $var=!$var;
  269. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstSubscriptionAmount").'</td><td>';
  270. print '<input size="25" type="text" name="fieldfirstsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT.'">';
  271. print '</td><td>&nbsp;</td>';
  272. print '<td align="right">&nbsp;</td>';
  273. print '</tr>';
  274. // Last subscription date
  275. $var=!$var;
  276. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLastSubscriptionDate").'</td><td>';
  277. print '<input size="25" type="text" name="fieldlastsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE.'">';
  278. print '</td><td>&nbsp;</td>';
  279. print '<td align="right">&nbsp;</td>';
  280. print '</tr>';
  281. // Last subscription amount
  282. $var=!$var;
  283. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLastSubscriptionAmount").'</td><td>';
  284. print '<input size="25" type="text" name="fieldlastsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT.'">';
  285. print '</td><td>&nbsp;</td>';
  286. print '<td align="right">&nbsp;</td>';
  287. print '</tr>';
  288. // End last subscriptions
  289. $var=!$var;
  290. print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldEndLastSubscription").'</td><td>';
  291. print '<input size="25" type="text" name="fieldendlastsubscription" value="'.$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION.'">';
  292. print '</td><td>&nbsp;</td>';
  293. print '<td align="right">&nbsp;</td>';
  294. print '</tr>';
  295. $var=!$var;
  296. print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
  297. print '</table>';
  298. print '</form>';
  299. print '</div>';
  300. print info_admin($langs->trans("LDAPDescValues"));
  301. /*
  302. * Test de la connexion
  303. */
  304. if ($conf->global->LDAP_MEMBER_ACTIVE)
  305. {
  306. $butlabel=$langs->trans("LDAPTestSynchroMember");
  307. $testlabel='testmember';
  308. $key=$conf->global->LDAP_KEY_MEMBERS;
  309. $dn=$conf->global->LDAP_MEMBER_DN;
  310. $objectclass=$conf->global->LDAP_MEMBER_OBJECT_CLASS;
  311. show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass);
  312. }
  313. if (function_exists("ldap_connect"))
  314. {
  315. if ($_GET["action"] == 'testmember')
  316. {
  317. // Creation objet
  318. $object=new Adherent($db);
  319. $object->initAsSpecimen();
  320. // Test synchro
  321. $ldap=new Ldap();
  322. $result=$ldap->connect_bind();
  323. if ($result > 0)
  324. {
  325. $info=$object->_load_ldap_info();
  326. $dn=$object->_load_ldap_dn($info);
  327. $result1=$ldap->delete($dn); // To be sure to delete existing records
  328. $result2=$ldap->add($dn,$info,$user); // Now the test
  329. $result3=$ldap->delete($dn); // Clean what we did
  330. if ($result2 > 0)
  331. {
  332. print img_picto('','info').' ';
  333. print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
  334. }
  335. else
  336. {
  337. print img_picto('','error').' ';
  338. print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
  339. print ': '.$ldap->error;
  340. print '</font><br>';
  341. print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
  342. }
  343. print "<br>\n";
  344. print "LDAP input file used for test:<br><br>\n";
  345. print nl2br($ldap->dump_content($dn,$info));
  346. print "\n<br>";
  347. }
  348. else
  349. {
  350. print img_picto('','error').' ';
  351. print '<font class="error">'.$langs->trans("LDAPSynchroKO");
  352. print ': '.$ldap->error;
  353. print '</font><br>';
  354. print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
  355. }
  356. }
  357. }
  358. $db->close();
  359. llxFooter();
  360. ?>