I'm building a website which was protected by SSO.
I plan to create a php file when SSO login callback, I will get the SSOID and user related info in http head. then auto login drupal or create a new user programatically.
Here's my code:

<?php

require 'includes/bootstrap.inc';
require
'modules/user/user.module';

function
getSSOID(){
   .......
}

function
getUserEmail(){
    .......
}

function
createUser($username,$pwd,$email) {
 
$edit = array(
   
'name' => $username,
   
'pass' => $pwd,
   
'mail' => $email,
   
'status' => 1,
   
'language' => 'en',
   
'init' => 'admin@drupal.com',
   
'roles' => array(2 => 'authenticated user'),
  );
 
user_save(NULL, $edit);
}


$ssoid = getSSOID();
$useremail = getUserEmail();
$user = user_load_by_name($ssoid);

if(!
$user){
   
// User doesn't exist
   
createUser($ssoid,"",$useremail);
}
else {
   
// User exists
   
drupal_session_regenerate();
}
//write a redirect code if necessary
$url="http://localhost:8080/drupal718/";
header("Location: $url");
?>

I'm new to drupal, I can not make this to work....anyone can help me....thanks in advance!

Comments

Its' kind of urgent....anyone

Its' kind of urgent....anyone can help?

New Bird

nobody click here