Loading...
Changes Saved.
Error Occurred!

KnowledgeBase

Login Sources

Most people use a variety of programs on their website; one to manage their forum, another to handle trouble tickets, another still to send their email.  An often-requested feature is to use one or another of these programs to authenticate, so that users don't have to maintain more than one login system.  We're glad to say that KnowledgeBuilder (3.x) and SupportTrio (3.x) now support Login Sources, which allow you to do exactly that.

Login sources are bridges, in a sense, between our application and the login system of another.  It allows us to ask the other system if a user exists there, and given a password, if a user should be allowed to log in.  If it works for the other system, we then allow you to log into our application.

For any login source to work, you usually have to tell it how to access the other system.  If the other system uses MySQL, you'll have to enter its connection information, for example.  If you want to use LDAP, you'll have to enter the connection information for that.  You can then check the Enabled box on the login source (once you edit it), and move it up or down in the order of sources to try--you are allowed multiple sources, which our application will try in order until it finds a matching user.

CREATING A LOGIN SOURCE

To create a login source, your best bet is to make a copy of an existing source.  The connection files are located in /ac_global/loginsource.  Make a copy of vBulletin.php, for instance, and save it as something else.  Then change the value of $loginident to reflect the name you want this source to be called.  Whatever you use for the value of $loginident must also be used at the beginning of your class name; e.g., if your $loginident is assigned as "abc", then your class should be named "abcLoginSource".  The $loginvars variable defines which fields will be shown on the screen: your choices are host, user, pass, dbname, port, and basedn (the latter is for LDAP), and the list of what will be used is comma-separated.

There are three functions you need to change:

- connect() will connect our application to the external system.  The member variable $this->source is an array you can use to access things like the host name and port number, but you will need to modify the connect method to do whatever you need with that information to actually contact the other system.

- info($user) will return information on the username given.  The return value should be an array, and it should contain four keys: "username", "first_name", "last_name", and "email".  The reason for naming them so is because those are precisely the columns which we will be synchronizing in our application inside the acp_globalauth table.

- authok($user, $pass) will return true or false based on the given username and password.  True should indicate that this user could log into the external system, and false conversely will indicate that the user could not.




Related Articles