diff --git a/admin/configuration.php b/admin/configuration.php new file mode 100644 index 0000000..53fe66a --- /dev/null +++ b/admin/configuration.php @@ -0,0 +1,75 @@ +set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/configuration.tpl') ); +$template->assign( + array( + 'PLUGIN_ACTION' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration', + 'PLUGIN_CHECK' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration', + )); + +$me = new Ldap(); +$me->load_config(); +//$me = get_plugin_data($plugin_id); + +$template->assign('HOST', $me->config['host']); +$template->assign('BASEDN', $me->config['basedn']); // racine ! +$template->assign('PORT', $me->config['port']); +$template->assign('LD_ATTR', $me->config['ld_attr']); +$template->assign('LD_GROUP', $me->config['ld_group']); +$template->assign('LD_USE_SSL', $me->config['ld_use_ssl']); +$template->assign('LD_BINDPW', $me->config['ld_bindpw']); +$template->assign('LD_BINDDN', $me->config['ld_binddn']); + +if (isset($_POST['save'])){ + $me->config['host'] = $_POST['HOST']; + $me->config['basedn'] = $_POST['BASEDN']; + $me->config['port'] = $_POST['PORT']; + $me->config['ld_attr'] = $_POST['LD_ATTR']; + $me->config['ld_group'] = $_POST['LD_GROUP']; + $me->config['ld_binddn'] = $_POST['LD_BINDDN']; + $me->config['ld_bindpw'] = $_POST['LD_BINDPW']; + + if (isset($_POST['LD_USE_SSL'])){ + $me->config['ld_use_ssl'] = True; + } else { + $me->config['ld_use_ssl'] = False; + } +} + +// Save LDAP configuration +if (isset($_POST['save'])){ + $me->save_config(); +} + +// Checki LDAP configuration +$me->ldap_conn(); +if (isset($_POST['check_ldap'])){ + //$me->write_log("[function]> admin"); + //$check = $me->ldap_name($_POST['USERNAME']); + $username = $me->ldap_search_dn($_POST['USERNAME']); + //$me->write_log("[admin]> bind=".$username); + $error=$me->check_ldap(); + if($error==1 && $username) { + if ($me->ldap_bind_as($username,$_POST['PASSWORD'])){ + if($me->check_ldap_group_membership($username,$me->config['ld_group'])){ + $template->assign('LD_CHECK_LDAP','
Configuration LDAP OK : '.$username.'
'); + } else { + $template->assign('LD_CHECK_LDAP','Credentials OK, Check GroupMembership for: '.$username.'
'); + } + } + else { + $template->assign('LD_CHECK_LDAP','Binding OK, but check credentials on server '.$me->config['uri'].' for user '.$username.'
'); + } + } elseif($error==1 && !$username){ + $template->assign('LD_CHECK_LDAP','Error : Binding OK, but no valid DN found on server '.$me->config['uri'].' for user '.$_POST['USERNAME'].'
'); + } elseif($error && $username){ + $template->assign('LD_CHECK_LDAP','Error : Binding OK, but check credentials on '.$me->config['uri'].' for user '.$_POST['USERNAME'].'
'); + } else { + $template->assign('LD_CHECK_LDAP','Error : '.$error.' for binding on server '.$me->config['uri'].' for user '.$_POST['USERNAME'].', check your binding!
'); + } +} + +$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); +?> diff --git a/admin/configuration.tpl b/admin/configuration.tpl new file mode 100644 index 0000000..072613a --- /dev/null +++ b/admin/configuration.tpl @@ -0,0 +1,114 @@ +{'All LDAP users can use their ldap password everywhere on piwigo if needed.'|@translate}
+ + + + +Configuration du plugin Ldap_Login
+ + \ No newline at end of file diff --git a/admin/newusers.php b/admin/newusers.php new file mode 100644 index 0000000..e54aceb --- /dev/null +++ b/admin/newusers.php @@ -0,0 +1,52 @@ +set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/newusers.tpl') ); +$template->assign( + array( + 'PLUGIN_NEWUSERS' => get_root_url().'admin.php?page=plugin-Ldap_Login-newusers', + )); + +$me = new Ldap(); +$me->load_config(); +//$me = get_plugin_data($plugin_id); + +$template->assign('ALLOW_NEWUSERS', $me->config['allow_newusers']); +$template->assign('ADVERTISE_ADMINS', $me->config['advertise_admin_new_ldapuser']); +$template->assign('SEND_CASUAL_MAIL', $me->config['send_password_by_mail_ldap']); + +if (isset($_POST['save'])){ + + if (isset($_POST['ALLOW_NEWUSERS'])){ + $me->config['allow_newusers'] = True; + } else { + $me->config['allow_newusers'] = False; + } + + if (isset($_POST['ADVERTISE_ADMINS'])){ + $me->config['advertise_admin_new_ldapuser'] = True; + } else { + $me->config['advertise_admin_new_ldapuser'] = False; + } + + if (isset($_POST['SEND_CASUAL_MAIL'])){ + $me->config['send_password_by_mail_ldap'] = True; + } else { + $me->config['send_password_by_mail_ldap'] = False; + } +} + +// Save LDAP configuration +if (isset($_POST['save'])){ + $me->save_config(); +} + +// do we allow to create new piwigo users in case of auth along the ldap ? +// does he have to belong an ldap group ? +// does ldap groups give some power ? +// what do we do when there's no mail in the ldap ? +// do we send mail to admins ? + +$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); +?> \ No newline at end of file diff --git a/admin/newusers.tpl b/admin/newusers.tpl new file mode 100644 index 0000000..ec9d9a6 --- /dev/null +++ b/admin/newusers.tpl @@ -0,0 +1,54 @@ +{literal} + +{/literal} + +