0011960: print with 300 dpi by default
[tine20] / tine20 / Tinebase / ActiveDirectory / DomainConfigurationTrait.php
1 <?php
2 /**
3  * ActiveDirectory generic trait
4  *
5  * @package     Tinebase
6  * @subpackage  ActiveDirectory
7  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
8  * @author      Philipp Schüle <p.schuele@metaways.de>
9  * @copyright   Copyright (c) 2016 Metaways Infosystems GmbH (http://www.metaways.de)
10  *
11  */
12
13 /**
14  * ActiveDirectory trait for reading domain configuration
15  * - can be used by User/Group AD controllers
16  *
17  * @package     Tinebase
18  * @subpackage  ActiveDirectory
19  *
20  */
21 trait Tinebase_ActiveDirectory_DomainConfigurationTrait
22 {
23     /**
24      * AD domain config
25      *
26      * @var array
27      */
28     protected $_domainConfig = null;
29
30     /**
31      * fetch domain config with domain sid and name
32      *
33      * @throws Tinebase_Exception_Backend_Ldap
34      * @throws Zend_Ldap_Exception
35      * @return array
36      *
37      * TODO cache this longer?
38      */
39     public function getDomainConfiguration()
40     {
41         if ($this->_domainConfig === null) {
42             $this->_domainConfig = $this->getLdap()->search(
43                 'objectClass=domain',
44                 $this->getLdap()->getFirstNamingContext(),
45                 Zend_Ldap::SEARCH_SCOPE_BASE
46             )->getFirst();
47
48             $this->_domainConfig['domainSidBinary'] = $this->_domainConfig['objectsid'][0];
49             $this->_domainConfig['domainSidPlain'] = Tinebase_Ldap::decodeSid($this->_domainConfig['objectsid'][0]);
50
51             $domainNameParts = array();
52             $keys = null; // not really needed
53             Zend_Ldap_Dn::explodeDn($this->_domainConfig['distinguishedname'][0], $keys, $domanNameParts);
54             $this->_domainConfig['domainName'] = implode('.', $domainNameParts);
55         }
56
57         return $this->_domainConfig;
58     }
59 }