summaryrefslogtreecommitdiff
path: root/list_users.php
diff options
context:
space:
mode:
authorTristan Zur <tzur@web.web.ccwn.org>2014-03-27 22:27:47 +0100
committerTristan Zur <tzur@web.web.ccwn.org>2014-03-27 22:27:47 +0100
commitb62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch)
tree86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /list_users.php
Initial commit of intern.ccwn.org contentsHEADmaster
Diffstat (limited to 'list_users.php')
-rw-r--r--list_users.php121
1 files changed, 121 insertions, 0 deletions
diff --git a/list_users.php b/list_users.php
new file mode 100644
index 0000000..17d9e03
--- /dev/null
+++ b/list_users.php
@@ -0,0 +1,121 @@
+<?php
+require_once("ldap_config.php");
+
+$bind_rdn = "uid=".$_SERVER["PHP_AUTH_USER"].",".$baseDn;
+$bind_password = $_SERVER["PHP_AUTH_PW"];
+
+$ldap_ds = ldap_connect($hostname, $port) or die("Could not connect to LDAP");
+
+ldap_set_option($ldap_ds,LDAP_OPT_PROTOCOL_VERSION,3);
+
+$connected = @ldap_bind($ldap_ds, $bind_rdn, $bind_password);
+
+if ($connected) {
+$result = ldap_search($ldap_ds, $baseDn, "(uid=*)") or die ("Error in search query: ".ldap_error($ldap_ds));
+$data = ldap_get_entries($ldap_ds, $result);
+?>
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <title>LDAP Users</title>
+ <script type="text/javascript" src="js/prototype/prototype.js"></script>
+ <script type="text/javascript" src="js/prototype-window/javascripts/window.js"></script>
+ <link href="js/prototype-window/themes/default.css" rel="stylesheet" type="text/css"/>
+ <!-- Add this to have a specific theme--> <link href="js/prototype-window/themes/alphacube.css" rel="stylesheet" type="text/css"/>
+ <style type="text/css">
+ label, input, select { /* Alle Labels UND Formularelemente auswählen */
+ display: block;
+ float: left;
+ width: 250px; /* Breite.*/
+ }
+
+ label {
+ width: 100px;
+ text-align: right;
+ padding-right: 15px;
+ }
+
+ form br { /* Alle Zeilenumbrüche in Formularen auswählen */
+ clear: left; /* das floating der labels und inputs aufheben */
+ }
+
+ input#submit { /* den Submit-Button */
+ float: none;
+ width: auto;
+ }
+ </style>
+ <script type="text/javascript">
+ function openDialog(uid, title) {
+ Dialog.confirm($(uid+"_dialog").innerHTML,
+ {className: "alphacube",
+ width: 400,
+ title: title,
+ okLabel: "speichern",
+ cancelLabel: "abbrechen",
+ onOk: function(win) {
+ new Ajax.Request("modify_ldap_user.php", {
+ method: "post",
+ parameters: $(uid + "_form").serialize(true),
+ onSuccess: function(transport) {
+ var response = transport.responseText || "no response text";
+ alert("Success! \n\n" + response);
+ },
+ onFailure: function() {
+ $(uid + "_error").innerHTML = "something went wrong";
+ $(uid + "_error").show();
+ Windows.focusedWindow.updateHeight();
+ return false;
+ }
+ });
+ }
+ }
+ );
+ }
+ </script>
+ </head>
+ <body>
+ <p>Du bist eingeloggt als: <?php echo $_SERVER['PHP_AUTH_USER']; ?></p>
+ <?php
+ function cmp($a, $b) {
+ return strcmp($a["cn"][0], $b["cn"][0]);
+ }
+
+ usort($data, "cmp");
+
+ foreach ($data as $entry) {
+ $uid = $entry['uid'][0];
+ $dn = $entry["dn"];
+ ?>
+ <div id="<?=$uid?>_dialog" style="display:none">
+ <span id="<?=$uid?>_error" style="display:none; float: left; color: red">&nbsp;</span>
+ <form id="<?=$uid?>_form">
+ <?php
+ foreach ($entry as $key=>$value) {
+ if (is_numeric($key) || "objectclass" == $key || "count" == $key || "dn" == $key) {
+ continue;
+ }
+ ?>
+ <label for="<?=$uid?>_<?=$key?>"><?=$key?></label>
+ <input id="<?=$uid?>_<?=$key?>" name="<?=$key?>" type="text" value="<?=$value[0]?>"/><br/>
+ <?php
+ }
+ ?>
+ <label for="<?=$uid?>_resetPassword">Passwort zur&uuml;cksetzen</label> <input type="checkbox" value="yes" id="<?=$uid?>_resetPassword" name="resetPassword"/>
+ </form>
+ </div>
+ <a href="javascript:openDialog('<?=$uid?>', '<?=$dn?>')"><?=$entry['cn'][0]?></a><br/>
+ <?php
+ }
+ ?>
+ </body>
+</html>
+<?php
+} else {
+ if (49 == ldap_errno($ldap_ds)) {
+ echo "Falsches Passwort";
+ } else {
+ echo "LDAP Error: '".ldap_error($ldap_ds)."'";
+ }
+}
+?>