HomeAdmin ManualAuthenticationBlack Box Portal Authentication (customer portal login)

3.6. Black Box Portal Authentication (customer portal login)

Black box authentication allows you to integrate your organizations authentication system with HelpSpot. Configuration requires only a few simple steps.

Summary: Steps to enable BlackBox Authentication

Customizing the BlackBox function

In the root of your installation there's a folder called /custom_code. Within that folder is the BlackBoxPortal-base.php file. This file contains the empty BlackBox function:

function BlackBoxPortal($username, $password){

		Here's an example of how to return a valid user:
		return "john.smith@company.com";

	return false;


Customize this function to do authentication against your internal system by using the username and password provided. Here is an example of the function customized to authenticate against a MySQL database: (some security procedures left out for clarity)

function BlackBoxPortal($username, $password){

       $dblink = mysql_connect('localhost', 'mysql_user', 'mysql_password');
       mysql_select_db('database', $dblink);

       $username = mysql_real_escape_string($username);
       $password = mysql_real_escape_string($password);

       $result = mysql_query("SELECT email FROM users WHERE users = '$username' AND pass = '$password'", $dblink);
       $num_rows = mysql_num_rows($result);

       if(mysql_num_rows($result) == 1){
              $row = mysql_fetch_assoc($result);
              //An email must be returned
              return $row['email']; 
              return false;

Returning an email will authenticate the user and show them any requests for that email, while false denies access.

Using LDAP with Portal BlackBox authentication

Just like with the Staff BlackBox authentication, you can use LDAP. However, because HelpSpot needs an email address returned upon successful authentication (instead of simply "true"), we need to do a little more work. Using the above LDAP library, you can query the LDAP server for the user information. This usually contains an email address associated with the account (however that may change depending on your LDAP server).

To get started, follow the instructions on downloading the LDAP library. Then create the BlackBoxPortal.php file. The following is some sample code which shows retrieving a users email address from the LDAP server if they successfully authenticate.



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

Knowledge Tags


This page was: Helpful | Not Helpful