first commit
This commit is contained in:
72
class_idee.php
Executable file
72
class_idee.php
Executable file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
#error_reporting(E_ALL | E_STRICT);
|
||||
header("content-type: text/html; charset=utf-8");
|
||||
|
||||
#echo "Domain: ".$_SESSION["global_domain"];
|
||||
|
||||
$_SESSION["global_domain"] = "hsnet";
|
||||
if($_SESSION["global_domain"] == "hsnet"){
|
||||
require_once("adLDAP/adLDAP_hsnet.php");
|
||||
}
|
||||
|
||||
if($_SESSION["global_domain"] == "studnet"){
|
||||
require_once("adLDAP/adLDAP_studnet.php");
|
||||
}
|
||||
|
||||
class idee extends adLDAP {
|
||||
|
||||
/**
|
||||
* Converts a username (samAccountName) to a objectsid BY ALI
|
||||
*
|
||||
* @param string $username The username to query
|
||||
* @return string
|
||||
*/
|
||||
public function username2osid($username) {
|
||||
if (!$this->_bind){ return (false); }
|
||||
if ($username === null){ return ("Missing compulsory field [username]"); }
|
||||
|
||||
$filter = "samaccountname=" . $username;
|
||||
$fields = array("objectSid");
|
||||
$sr = @ldap_search($this->_conn, $this->_base_dn, $filter, $fields);
|
||||
if (ldap_count_entries($this->_conn, $sr) > 0) {
|
||||
$entry = @ldap_first_entry($this->_conn, $sr);
|
||||
$osid = @ldap_get_values_len($this->_conn, $entry, 'objectSid');
|
||||
$strOSID = $this->binary2text($osid[0]);
|
||||
return ($strOSID);
|
||||
}
|
||||
else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function username2vorname($username){
|
||||
$userinfo = $idee->user_info($username2, array("givenname"));
|
||||
$userinfo = trim($userinfo[0]["givenname"][0]);
|
||||
return $userinfo;
|
||||
}
|
||||
|
||||
public function username2nachname($username){
|
||||
$userinfo = $idee->user_info($username2, array("sn"));
|
||||
$userinfo = trim($userinfo[0]["sn"][0]);
|
||||
return $userinfo;
|
||||
}
|
||||
|
||||
public function username2mail($username){
|
||||
$userinfo = $idee->user_info($username2, array("mail"));
|
||||
$userinfo = trim($userinfo[0]["mail"][0]);
|
||||
return $userinfo;
|
||||
}
|
||||
|
||||
public function username2department($username){
|
||||
$userinfo = $this->user_info($username, array("distinguishedname"));
|
||||
$distinguishedname = $userinfo[0]["distinguishedname"][0];
|
||||
$group = preg_split('/OU=/', $distinguishedname);
|
||||
$group = trim(str_replace(',', '', $group[1]));
|
||||
return $group;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user