// Author: Jon Belanger // Date: Nov. 2004 // comments: linked to in display_users.php and edit_users.php // start the session session_start(); include("functions.php"); include("gui.php"); // check if the session username or seclevel are not set // this would occur if the user was trying to get here without logging in if (! $_SESSION['username'] | ! $_SESSION['seclevel']) { redirect("logout.php"); exit(1); } // check if the seclevel is user, if so check if the user that is // getting the password changed is the same as the session user // (user that is logged in) // if not logout if ($_SESSION['seclevel']=="user") { if ($_GET['uid']!=$_SESSION['username']) { redirect("logout.php"); exit(1); } } // check if the seclevel is expert // if so check if the user that is getting the password changed // is not another expert or admin. Experts can only change their own password // or other user level users. // If conditions are not met, redirect back to display_users.php with error message if ($_SESSION['seclevel']=="expert") { // temp connection to ldap to retrieve description of user that is getting // password changed $ds=connect_to_ldap($_SESSION['server'],$_SESSION['port'], $_SESSION['ssl'], 3); if ($ds) { // bind anonymously to server, the @ symbol supresses error messages if (@ldap_bind($ds)) { $stufftoget=array('description'); $sr=ldap_list($ds, $_SESSION['userbase'], "uid=".$_GET['uid'], $stufftoget); $info=ldap_get_entries($ds, $sr); if ( $info[0]['description'][0] == "expert" & $_GET['uid']!=$_SESSION['username']) { redirect("display_users.php?error=Can't change the password of other experts!"); } elseif ( $info[0]['description'][0] == "admin" ) { redirect("display_users.php?error=Can't change the password of admins!"); } } else { echo "Cannot bind anonymously to ldap server!"; exit(1); } } // close ldap connection ldap_close($ds); } // send the meta headers and actually html header to client browser display_meta($_SESSION['version']." - Change Password"); display_header("Change Password"); ?>
| // the interface menu options change slightly depending on your seclevel. This handles // the changes if ($_SESSION['seclevel']!="user") { ?> Main - Edit Users - Change Password } else { ?> Edit User - Change Password } ?> |
| // display errors redirected back to this page if ($_GET["error"]) { echo "** ".$_GET["error"]; } else { echo " "; } ?> |