← Back to team overview

brainstorm-dev team mailing list archive

variably slow

 

Hi,

I've written a single sign on script for brainstorm which works on the premise that the userid and mail headers get sent through after authentication takes place (in our case via ldap).

Also note I had to apply a small patch http://drupal.org/files/issues/sess.patch which is detailed here => http://drupal.org/node/293612

The only drawkback I'm finding is that it can be quite slow on my site where I get about 5 hits a second during peak times. I noticed it's not just the single sign on either, but sometimes when I click on one of the most popular links, the page can be quite slow to come back. I'm using the current ubuntu brainstorm site version, and even that site is variably slow at times. 

There do not appear to be any resource issues on the box, so I'm guessing I need to tune something, or index a table in the database? Thanks for any help.

Ed.


<?php

include_once './includes/bootstrap.inc';
global $user;
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);  //  not sure if this is the bootstrap phase required

//some things to configure
$url="https://ideas.somdomain.com/";;
$db="brainstorm;
$dbhost="brainhost";
$dbuser="brainuser";
$dbpasswd="brainpass";

//user dummy password
$pass="dummypassword";
$hashpasswd="60da11eb799d6a8da47e5cd6e4aa2273";


//pick up the SSO headers
$name=$_SERVER['HTTP_SSO_UNIQUENAME'];
$mail=$_SERVER['HTTP_SSO_MAIL'];


//check sso values
if(empty($name)||empty($mail)){
        header  ("Location: ".$url."/error.html");
}


// Create user if they don't exist by looking to see if email address already registered
$dbconn = pg_connect("host=$dbhost dbname=$db user=$dbuser password=$dbpasswd") or die('Could not connect: ' . pg_last_error());
$query = "select count(*) from users where mail='".$mail."'";
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
$line = pg_fetch_array($result, null, PGSQL_ASSOC);
pg_free_result($result);
$userExist=(int)$line['count'];
if( $userExist < 1 ){
        $time=time();
        $query = "INSERT INTO users (name,pass,mail,theme,created,status,timezone,init,data) VALUES ('".$name."','".$passwd."','".$mail."','ubuntu-theme','
".$time."','1','0','".$mail."','a:0:{}')";
        $result = pg_query($query) or die('Query failed: ' . pg_last_error());
        pg_free_result($result);
}
pg_close($dbconn);

//Now do the drupal authentication
$user=user_authenticate($name, $pass);
if ($user){
    drupal_goto("$url");
}


?>


_________________________________________________________________
Are you a PC?  Upload your PC story and show the world 
http://clk.atdmt.com/UKM/go/122465942/direct/01/

Follow ups