HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

Automatically put in the user's name and email in a request w/ LDAP


This assumes you already have a working LDAP for your portal using the blackbox. See:

The first problem is the BlackBoxPortal.php doesn’t save anything to the sessions it only returns the user’s email address. To override this I added it to the $_SESSION.

$_SESSION['adldap']['displayname'] = $userinfo[0]["displayname"][0];
$_SESSION['adldap']['email'] = $userinfo[0]["mail"][0];

So it looks like:

function BlackBoxPortal($username, $password){

    //create the AD LDAP connection
    $adldap = new adLDAP\adLDAP();
    //authenticate a user
    if ($adldap->authenticate($username,$password))
        $userinfo = $adldap->user()->info( $username, array("mail","displayname"));
        $_SESSION['adldap']['displayname'] = $userinfo[0]["displayname"][0];
        $_SESSION['adldap']['email'] = $userinfo[0]["mail"][0];
        return $userinfo[0]["mail"][0];
        return false;


There might be a better way to save these values but I can’t find any good documentation on it.

Next in the request.tpl.php I changed the following:

<input type="text" name="sEmail" size="40" maxlength="250" value="<?php echo $this->request_sEmail ?>" />


<input type="text" name="sEmail" size="40" maxlength="250" disabled value="<?php echo $_SESSION['adldap']['email'] /*$this->request_sEmail*/ ?>" />

This will change the value to use $_SESSION and disable the field so the user can’t change it. You can remove disable if you want but I wanted to pin my users to using what is in LDAP.

Then I changed:

<input type="text" name="fullname" size="40" maxlength="100" value="<?php echo $this->request_fullname ?>" />


<input type="text" name="fullname" size="40" maxlength="100" disabled value="<?php echo $_SESSION['adldap']['displayname'] /*$this->request_fullname*/ ?>" />

This did pretty much the same thing as email.

If you wanted to do phone number of any other LDAP attributes you can, you just need to pull them in and save them. See: