. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 94.23.64.18 / Your IP :
216.73.216.185 [
Web Server : Apache System : Linux webm005.cluster107.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : villadal ( 6036) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/villadal/www/old/booked/plugins/Authentication/ActiveDirectory/ |
Upload File : |
<?php
/**
Copyright 2011-2014 Nick Korbel
This file is part of Booked Scheduler.
Booked Scheduler is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Booked Scheduler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
*/
require_once(ROOT_DIR . '/lib/Config/namespace.php');
class ActiveDirectoryOptions
{
private $_options = array();
public function __construct()
{
require_once(dirname(__FILE__) . '/ActiveDirectory.config.php');
Configuration::Instance()->Register(
dirname(__FILE__) . '/ActiveDirectory.config.php',
ActiveDirectoryConfig::CONFIG_ID);
}
public function AdLdapOptions()
{
$hosts = $this->GetHosts();
$this->SetOption('domain_controllers', $hosts);
$this->SetOption('ad_port', $this->GetConfig(ActiveDirectoryConfig::PORT), new IntConverter());
$this->SetOption('admin_username', $this->GetConfig(ActiveDirectoryConfig::USERNAME));
$this->SetOption('admin_password', $this->GetConfig(ActiveDirectoryConfig::PASSWORD));
$this->SetOption('base_dn', $this->GetConfig(ActiveDirectoryConfig::BASEDN));
$this->SetOption('use_ssl', $this->GetConfig(ActiveDirectoryConfig::USE_SSL, new BooleanConverter()));
$this->SetOption('account_suffix', $this->GetConfig(ActiveDirectoryConfig::ACCOUNT_SUFFIX));
$this->SetOption('ldap_version', $this->GetConfig(ActiveDirectoryConfig::VERSION), new IntConverter());
return $this->_options;
}
public function RetryAgainstDatabase()
{
return $this->GetConfig(ActiveDirectoryConfig::RETRY_AGAINST_DATABASE, new BooleanConverter());
}
public function Controllers()
{
return $this->GetHosts();
}
private function SetOption($key, $value)
{
if (empty($value))
{
$value = null;
}
$this->_options[$key] = $value;
}
private function GetConfig($keyName, $converter = null)
{
return Configuration::Instance()->File(ActiveDirectoryConfig::CONFIG_ID)->GetKey($keyName, $converter);
}
private function GetHosts()
{
$hosts = explode(',', $this->GetConfig(ActiveDirectoryConfig::DOMAIN_CONTROLLERS));
for ($i = 0; $i < count($hosts); $i++)
{
$hosts[$i] = trim($hosts[$i]);
}
return $hosts;
}
public function Attributes()
{
$attributes = $this->AttributeMapping();
return array_values($attributes);
}
public function AttributeMapping()
{
$attributes = array('sn' => 'sn',
'givenname' => 'givenname',
'mail' => 'mail',
'telephonenumber' => 'telephonenumber',
'physicaldeliveryofficename' => 'physicaldeliveryofficename',
'title' => 'title');
$configValue = $this->GetConfig(ActiveDirectoryConfig::ATTRIBUTE_MAPPING);
if (!empty($configValue))
{
$attributePairs = explode(',', $configValue);
foreach ($attributePairs as $attributePair)
{
$pair = explode('=', trim($attributePair));
$attributes[trim($pair[0])] = trim($pair[1]);
}
}
return $attributes;
}
}
?>