<?php function login_check() { if (isset($_SESSION['IWP_loggedIn']) && $_SESSION['IWP_loggedIn'] === true && isset($_SESSION["IWPUser"])) { return true; } else { return false; } } function do_login($username, $password, $redirect) { $un = 'DOMAIN\\' . $username; // Needs the domain ie. mydomain\username $pw = $password; if (empty($un)) { header("Location: http://example.com/sandboxPHP/login.php?error=Username cannot be blank"); exit(); } if (empty($pw)) { header("Location: http://example.com/sandboxPHP/login.php?error=Password cannot be blank"); exit(); } $server = "example.com"; //IP or name of server here if (!($ldap = ldap_connect($server))) { header("Location: http://example.com/sandboxPHP/login.php?error=Could Not Connect To Server"); // can change these error messages exit(); } if (!ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3)) { header("Location: http://example.com/sandboxPHP/login.php?error=Protocol Error with LDAP"); exit(); } if (!($res = @ldap_bind($ldap, $un, $pw))) { header("Location: http://example.com/sandboxPHP/login.php?error=Bind Error with LDAP"); exit(); } else { $_SESSION["IWP_loggedIn"] = true; $_SESSION["IWPUser"] = $un; // Make sure to use appended username with Domain echo $_SESSION["IWPUser"]; //header("Location: " . $redirect); } } function do_logout($redirect) { session_destroy(); header("Location: " . $redirect); } ?>
<?php session_start(); echo $_SESSION["IWPUser"]; require('functions.php'); if(login_check() === false) { echo 'issue'; //header("Location: "); exit(); } else { // rest of your page below } ?>
<?php // Start session to track this users identity session_start(); // Make sure they are logged in, if not redirect to login // IWP_loggedIn is boolean, 'true' if (!$_SESSION['IWP_loggedIn']) { // Redirect to the secure content header("Location: http://example.com/login.php"); // Make sure that code below does not get executed when we redirect exit(); } else { //talk to ArcGIS Server/Web Adaptor to tell it the users credentials } ?>
<!DOCTYPE html> <html> <head> <title>Secure Access</title> </head> <body> <?php // Start session to track this users identity session_start(); // Make sure they aren't already in a session; if so, redirect to GIS Home // IWP_loggedIn is boolean, 'true'; if there is a session, credentials are already stored if ($_SESSION['IWP_loggedIn']) { // Redirect to the secure content (ArcGIS JavaScript app with secured ArcGIS Server services) // header("Location: http://example.com/gis.php"); // TEST MODE: print the authorized user name echo $_SERVER['LOGON_USER']; // Make sure that code below does not get executed when we redirect exit(); } else { // If no session is started and no authentication has been performed if (empty($_SERVER["LOGON_USER"])) { // If user is not in intranet, or browser is not enabled for SSO // IIS/browser prompt for credentials; this message is a stand-in for now echo "<h1>Please login with your credentials to access GIS data</h1>"; // Create session logged-in variable to track user $_SESSION['IWP_loggedIn'] = TRUE; // Store credentials (how do I pass on username/password or key to the next site?) $_SESSION["IWPUser"] = $_SERVER["LOGON_USER"]; //Redirect, credentials passed via PHP session // header("Location: http://example.com/gis.php"); // TEST MODE: print the authorized user name echo $_SERVER['LOGON_USER']; // Make sure that code below does not get executed when we redirect exit(); } // If user is on intranet and browser is enabled for SSO, automatic login occurs // "LOGON USER" field will be filled, auto-redirect to map if (!empty($_SERVER["LOGON_USER"])) { echo "Oh Joy!!!"; // Create session logged-in variable to track user $_SESSION['IWP_loggedIn'] = TRUE; // Store credentials (how do I pass on username/password or key to the next site?) $_SESSION["IWPUser"] = $_SERVER["LOGON_USER"]; // Redirect, credentials passed via PHP session // header("Location: http://example.com/gis.php"); // TEST MODE: print the authorized user name echo $_SERVER['LOGON_USER']; // Make sure that code below does not get executed when we redirect exit(); } } ?> </body> </html>
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.