Thursday, September 10, 2009

Quick & Dirty way to make applications SSO enabled

This is the quick & dirty way to make applciations SSO enabled. Next thing,You can use Server Variable 'AUTH_USER' as primary key to access LDAP server & retrieve Details of user.




function authenticate(){
$username = $_SERVER['AUTH_USER']; // Server Variable AUTH_USER is the key of this code.
$auth_user = array('user1','user2','user4','user5');
/* Keep adding users to this array or call a function to create this array from a flat Text file.
Alternatively you can write a SQL to get authenticate user. */
$domain = 'mydomain\\';
foreach ($auth_user as $item){
if($username == $domain.$item) { return 1;} }
return 0;
}
if(!authenticate()){print "Access Denied"; exit();}

No comments: