[27036] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | global $template; |
---|
| 5 | $template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/configuration.tpl') ); |
---|
| 6 | $template->assign( |
---|
| 7 | array( |
---|
[27284] | 8 | 'PLUGIN_ACTION' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration', |
---|
| 9 | 'PLUGIN_CHECK' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration', |
---|
[27036] | 10 | )); |
---|
| 11 | |
---|
| 12 | $me = new Ldap(); |
---|
| 13 | $me->load_config(); |
---|
| 14 | //$me = get_plugin_data($plugin_id); |
---|
| 15 | |
---|
| 16 | $template->assign('HOST', $me->config['host']); |
---|
| 17 | $template->assign('BASEDN', $me->config['basedn']); // racine ! |
---|
| 18 | $template->assign('PORT', $me->config['port']); |
---|
| 19 | $template->assign('LD_ATTR', $me->config['ld_attr']); |
---|
| 20 | $template->assign('LD_USE_SSL', $me->config['ld_use_ssl']); |
---|
| 21 | $template->assign('LD_BINDPW', $me->config['ld_bindpw']); |
---|
| 22 | $template->assign('LD_BINDDN', $me->config['ld_binddn']); |
---|
| 23 | |
---|
| 24 | if (isset($_POST['save'])){ |
---|
| 25 | $me->config['host'] = $_POST['HOST']; |
---|
| 26 | $me->config['basedn'] = $_POST['BASEDN']; |
---|
| 27 | $me->config['port'] = $_POST['PORT']; |
---|
| 28 | $me->config['ld_attr'] = $_POST['LD_ATTR']; |
---|
| 29 | $me->config['ld_binddn'] = $_POST['LD_BINDDN']; |
---|
| 30 | $me->config['ld_bindpw'] = $_POST['LD_BINDPW']; |
---|
| 31 | |
---|
| 32 | if (isset($_POST['LD_USE_SSL'])){ |
---|
| 33 | $me->config['ld_use_ssl'] = True; |
---|
| 34 | } else { |
---|
| 35 | $me->config['ld_use_ssl'] = False; |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | // Save LDAP configuration |
---|
| 40 | if (isset($_POST['save'])){ |
---|
| 41 | $me->save_config(); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | // Check LDAP configuration |
---|
| 45 | if (isset($_POST['check_ldap'])){ |
---|
| 46 | $check = $me->ldap_name($_POST['USERNAME']); |
---|
| 47 | $error = $me->check_ldap(); |
---|
| 48 | |
---|
| 49 | if ($me->ldap_bind_as($_POST['USERNAME'],$_POST['PASSWORD'])){ |
---|
| 50 | $template->assign('LD_CHECK_LDAP','<p style="color:green;">Configuration LDAP OK : '.$check.'</p>'); |
---|
| 51 | } |
---|
| 52 | else { |
---|
| 53 | $template->assign('LD_CHECK_LDAP','<p style="color:red;">Error :'.$error.' test '.$me->config['uri'].' '.$check.'</p>'); |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 58 | ?> |
---|