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 @@ +

{'Ldap_Login Plugin'|@translate}

+ +
+ +

{'All LDAP users can use their ldap password everywhere on piwigo if needed.'|@translate}

+ +
+ + {if (!extension_loaded('ldap'))} +

{'Warning: LDAP Extension missing.'|@translate}

+
+ {/if} + +
+ {'Ldap server host connection'|@translate} + +
    +
  • + +
    + +
  • + +
  • + +
  • + +
  • + +
    + +
  • +
+ {'If empty, localhost and standard protocol ports will be used in configuration.'|@translate} +
+ +
+ {'Ldap attributes'|@translate} +
    +
  • + +
    + +
  • + +
  • + +
    + +
  • +
  • + +
    + +
  • +
+
+ +
+ {'Ldap connection credentials'|@translate} +
    +
  • + +
    + +
  • + +
  • + +
    + +
  • +
+ {'Let the fields blank if the ldap accept anonymous connections.'|@translate} +
+ +

+ +

+
+ +
+
+{'Ldap_Login Test'|@translate} +{'You must save the settings with the Save button just up there before testing here.'|@translate} +
    +
  • + +
    + +
  • + +
  • + +
    + +
  • +
+ + {if (!empty($LD_CHECK_LDAP))} + {$LD_CHECK_LDAP} + {/if} + +
+

+ +
+
diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..df13f7e --- /dev/null +++ b/admin/index.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/admin/ldap_login_plugin_admin.php b/admin/ldap_login_plugin_admin.php new file mode 100644 index 0000000..07c9104 --- /dev/null +++ b/admin/ldap_login_plugin_admin.php @@ -0,0 +1,22 @@ +config['host'] = $_POST['HOST']; + $me->config['basedn'] = $_POST['BASEDN']; + $me->config['pref'] = $_POST['PREF']; + $me->save_config(); +} + +global $template; +$template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/ldap_login_plugin_admin.tpl') ); + +$template->assign('HOST', $me->config['host']); +$template->assign('BASEDN', $me->config['basedn']); +$template->assign('PREF', $me->config['pref']); + +$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); +?> \ No newline at end of file diff --git a/admin/ldap_login_plugin_admin.tpl b/admin/ldap_login_plugin_admin.tpl new file mode 100644 index 0000000..4ece27e --- /dev/null +++ b/admin/ldap_login_plugin_admin.tpl @@ -0,0 +1,24 @@ +
+

Ldap_Login PlugIn

+
+ +

Configuration du plugin Ldap_Login

+ +
+
+ Ldap_Login PlugIn + +
+ +
+ +
+ +

+
\ 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} + +
+

{'Ldap_Login Plugin'|@translate}

+
+ +{"If the LDAP doesn't furnish the mail address, users can set it up in the profile page."|@translate} +
+ +
+ {'Ldap_Login configuration'|@translate} + +

+ {if $ALLOW_NEWUSERS} + + {else} + + {/if} + {'Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'|@translate} +

+ +

+ {if $ADVERTISE_ADMINS} + + {else} + + {/if} + {'Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'|@translate} +

+ +

+ {if $SEND_CASUAL_MAIL} + + {else} + + {/if} + {'Do you want to send mail to the new users, like casual piwigo users receive ?'|@translate} +

+ +
+ +

+ +

+
\ No newline at end of file