'LDAP info',
'version' => '1.1',
'author' => '[http://WebDesignEssence.com/ Web Design Essence]',
'description' => '"ldapinfo" tag will show the information about the user from LDAP database',
'url' => 'http://WebDesignEssence.com/mediawiki/ldapinfo/',
);
class LDAPinfo
{
var $sn_source;
function LDAPinfo($source)
{
$this->sn_source = escapeshellcmd($source);
}
function parse()
{
global $wgLDAPDomainNames;
$ldapconn = $this->connect();
if (! $ldapconn) {
$this->printDebug("Failed to connect",1);
return 'Failed to connect to the LDAP server. '.$wgLDAPDomainNames[0];
}
$searchstring = $this->getSearchString($ldapconn,$this->sn_source);
$entry = @ldap_read($ldapconn, $searchstring, "objectclass=*");
@ldap_unbind();
if (!$entry) {
$this->printDebug("Did not find a matching user in LDAP",1);
return 'LDAP user "'.$this->sn_source.'" not found ';
}
$this->printDebug("Found a matching user in LDAP",1);
$entries = ldap_get_entries($ldapconn, $entry);
global $wikidbToken;
$logged_in=false;
if (isset($wikidbToken) && !empty($wikidbToken)) {
$logged_in=true;
}
global $wgParser;
$wgParser->disableCache();
$s='
';
$s.=$this->show_line('Company', $entries[0]['o'][0]);
if ($logged_in) {
$s.=$this->show_line('Division', $entries[0]['ou'][0]);
}
$s.=$this->show_line('Department', $entries[0]['businesscategory'][0]);
if ($logged_in) {
$s.=$this->show_line('Title', $entries[0]['title'][0]);
}
if ($logged_in) {
$s.=$this->show_line('Affiliation', $entries[0]['employeetype'][0]);
}
$s.=$this->show_line('Office phone', $entries[0]['telephonenumber'][0]);
if ($logged_in) {
$s.=$this->show_line('Room number', $entries[0]['roomnumber'][0]);
}
$s.=$this->show_line('E-Mail', $this->encrypt_mail($entries[0]['mail'][0]));
$s.=$this->show_line_weblink('Web page',$entries[0]['labeleduri'][0]);
$s.="
\n";
return $s;
}
# Show one line
function show_line($name, $value)
{
$val=ltrim(rtrim($value ));
if (empty($val)) {
return '';
}
return '
'.$name.': '.$val."
\n";
}
# Show one line: URL
function show_line_weblink($name, $value)
{
$val=ltrim(rtrim($value ));
if (empty($val)) {
return '';
}
return '