| Server IP : 195.130.67.5 / Your IP : 216.73.216.231 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/Civil/includes/ |
Upload File : |
<?
////////////////////////////////////////////////////////////////////////////////////////
// Class: LdapConnector
// Purpose: Connect to an LDAP
///////////////////////////////////////////////////////////////////////////////////////
require_once('config.php');
class LdapConnector
{
public $ds;
public $dn;
public $filter;
// Function: __construct, Purpose: Connect and bind to ldap ***
public function __construct()
{
// Connect to ldap
$this->ds = ldap_connect(LDAP_SERVER, LDAP_PORT) or die("Could not connect to LDAP Server");
ldap_bind($this->ds, "cn=".LDAP_USER, LDAP_PASS) or die("Could not bind to LDAP server");
$this->dn = LDAP_DN;
}
// Function: __destruct, Purpose: Close the connection ***
public function __destruct() {
ldap_close($this->ds);
}
// Function: ldapSearch, Purpose: Execute an Ldap search ***
public function ldapSearch($filter, $attributes=array("*"), $attrsonly=0, $sizelimit=0)
{
$this->filter = $filter;
return @ldap_search($this->ds, $this->dn, $filter, $attributes, $attrsonly, $sizelimit);
}
// Function: getEntries, Purpose: Get array of query results ***
public function getEntries($result)
{
return ldap_get_entries($this->ds, $result);
}
// Function: sortResults, Purpose: Sort the result of a LDAP search ***
public function sortResults($result, $sortfilter)
{
ldap_sort($this->ds, $result, $sortfilter);
return $result;
}
}
?>