Jump to content

Using adLDAP to Login Users over an Active Directory


alexander.john

Recommended Posts

Hello,

 

I am tasked to create a shop to sell old hardware for our employees. Boss said we should be able to login via the already existing active diretory.

 

I looked at a number of shopping platforms and finally settled for prestashop.

 

At first I looked into using a SSO solution via kerebrus but boss didn't like it.

A solution he liked more would be via something like adLDAP (http://adldap.sourceforge.net/).

 

Sadly, what seemed doable to me at first confuses me after I looked at how prestashop does the authentification.

 

Frankly, I'm lost here.

 

I was expecting something simple like this:

 

<?php
//log them out
$logout = $_GET['logout'];
if ($logout == "yes") { //destroy the session
session_start();
$_SESSION = array();
session_destroy();
}
//force the browser to use ssl (STRONGLY RECOMMENDED!!!!!!!!)
if ($_SERVER["SERVER_PORT"] != 443){
header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
exit();
}
//you should look into using PECL filter or some form of filtering here for POST variables
$username = strtoupper($_POST["username"]); //remove case sensitivity on the username
$password = $_POST["password"];
$formage = $_POST["formage"];
if ($_POST["oldform"]) { //prevent null bind
if ($username != NULL && $password != NULL){
 //include the class and create a connection
 include (dirname(__FILE__) . "/../src/adLDAP.php");
	try {
  $adldap = new adLDAP();
	}
	catch (adLDAPException $e) {
		echo $e;
		exit();  
	}

 //authenticate the user
 if ($adldap->authenticate($username, $password)){
  //establish your session and redirect
  session_start();
  $_SESSION["username"] = $username;
		$_SESSION["userinfo"] = $adldap->user()->info($username);
  $redir = "Location: https://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/menu.php";
  header($redir);
  exit;
 }
}
$failed = 1;
}
?>

 

But I guess I was a little naive there.

 

 

Does anybody know how I could make Prestashop play together with adLDAP?

 

Thanks in advance :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...