exit(1);
}
-require_once INSTALLDIR.'/plugins/Authorization/AuthorizationPlugin.php';
require_once 'Net/LDAP2.php';
class LdapAuthorizationPlugin extends AuthorizationPlugin
public $attributes = array();
function onInitializePlugin(){
- parent::onInitializePlugin();
if(!isset($this->host)){
throw new Exception("must specify a host");
}
$ldap->setErrorHandling(PEAR_ERROR_RETURN);
$err=$ldap->bind();
if (Net_LDAP2::isError($err)) {
- common_log(LOG_WARNING, 'Could not connect to LDAP server: '.$err->getMessage());
+ throw new Exception('Could not connect to LDAP server: '.$err->getMessage());
return false;
}
if($config == null) $this->default_ldap=$ldap;
if($ldap==null) {
$ldap = $this->ldap_get_connection();
}
+ if(! $ldap) {
+ throw new Exception("Could not connect to LDAP");
+ }
$filter = Net_LDAP2_Filter::create($this->attributes['username'], 'equals', $username);
$options = array(
'attributes' => $attributes
return false;
}
}
+
+ function onPluginVersion(&$versions)
+ {
+ $versions[] = array('name' => 'LDAP Authorization',
+ 'version' => STATUSNET_VERSION,
+ 'author' => 'Craig Andrews',
+ 'homepage' => 'http://status.net/wiki/Plugin:LdapAuthorization',
+ 'rawdescription' =>
+ _m('The LDAP Authorization plugin allows for StatusNet to handle authorization through LDAP.'));
+ return true;
+ }
}