| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- $loginView = true;
- require_once("util.php");
- require_once("NTK/NTK.php");
- $action = var_get_post("action", "");
- $username = var_get_post("username", "");
- $password = var_get_post("password", "");
- if ($action == "login" && $username != "" && $password != "") {
- $ds = ldap_connect("ldap://".getenv('CLOUDRON_LDAP_HOST').":".getenv('CLOUDRON_LDAP_PORT'));
- if ($ds) {
- $r = ldap_bind($ds, getenv('CLOUDRON_LDAP_BIND_DN'), getenv('CLOUDRON_LDAP_BIND_PASSWORD'));
- if (!$r) {
- echo "LDAP bind failed";
- return;
- }
- $sr = ldap_search($ds, getenv('CLOUDRON_LDAP_USERS_BASE_DN'), "(username=".$username.")");
- $info = ldap_get_entries($ds, $sr);
- if ($info["count"] != 0) {
- $bindLogin = ldap_bind($ds, $info[0]["dn"], $password);
- if ($bindLogin) {
- login();
- } else {
- echo "Anmeldung fehlgeschlagen!";
- }
- } else {
- echo "Anmeldung fehlgeschlagen!";
- }
- ldap_close($ds);
- } else {
- echo "LDAP server connection failed";
- }
- }
- ?>
- <html>
- <head>
- <title> Login </title>
- <?php
- $main_box = new NTKVBox("main_box", 0, 0, False);
- $title_label = new NTKLabel("", "Mitarbeiter Login");
- $main_box->add($title_label, False, False, "background-color: #dfe7f3; vertical-align: middle; align: center;");
- $table = new NTKTable("table", 3, 2, False);
- $username_label = new NTKLabel("", "Username:");
- $table->add($username_label, 0, 0);
- $username_entry = new NTKEntry("username");
- $table->add($username_entry, 0, 1, 150);
- $onload .= "document.getElementById('username').focus();";
- $password_label = new NTKLabel("", "Passwort:");
- $table->add($password_label, 1, 0);
- $password_entry = new NTKPassword("password");
- $table->add($password_entry, 1, 1, 150);
- $submit_button = new NTKButton("submit", "Anmelden", "document.forms['customer'].submit();");
- $table->add($submit_button, 2, 1);
- $form = new NTKForm("login", "login.php", $table);
- $form->addAttribute("action", "login");
- $main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
- echo getHead();
- echo $main_box->getHtml();
- ?>
- </html>
|