Created
July 20, 2010 20:02
-
-
Save fables-tales/483477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A class for doing LDAP authentication using the secure token system | |
* implements SecureTokenAuth | |
* @author Sam Phippen <[email protected]> | |
* | |
*/ | |
class LDAPAuth extends SecureTokenAuth { | |
private $ldapManager; | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
public function checkAuthentication($username, $password) | |
{ | |
$config = Configuration::getInstance(); | |
$this->ldapManager = new LDAPManager($config->getConfig("ldap.host"), $username, $password); | |
return $this->ldapManager->getAuthed(); | |
} | |
public function getTeams($username) | |
{ | |
$config = Configuration::getInstance(); | |
$ldapManager = new LDAPManager($config->getConfig("ldap.host"), "ide", $config->getConfig("ldap.ideuser.password")); | |
$groups = $this->ldapManager->getGroupsForUser($username); | |
$teams = array(); | |
foreach ($groups as $group) | |
{ | |
if (stripos($group["cn"], "team")) | |
{ | |
$teams[] = substr($group["cn"],4,count($group["cn"])-4); | |
} | |
} | |
return $teams; | |
} | |
public function displayNameForGroup($group) | |
{ | |
} | |
public function displayNameForUser($user) | |
{ | |
if ($this->ldapManager->getAuthed()) { | |
$info = $this->ldapManager->getUserInfo($user); | |
return $info["name.first"] . " " . $info["name.last"]; | |
} | |
else | |
{ | |
throw new Exception("you aren't authed to ldap", E_LDAP_NOT_AUTHED); | |
} | |
} | |
public function emailForUser($user) | |
{ | |
if ($this->ldapManager->getAuthed()) | |
{ | |
$info = $this->ldapManager->getUserInfo($user); | |
return $info["email"]; | |
} | |
else | |
{ | |
throw new Exception("you aren't authed to ldap", E_LDAP_NOT_AUTHED); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment