File indexing completed on 2024-12-22 05:36:48

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Ldap
0017  * @subpackage Schema
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * @see Zend_Ldap_Node_Abstract
0025  */
0026 // require_once 'Zend/Ldap/Node/Abstract.php';
0027 
0028 /**
0029  * Zend_Ldap_Node_Schema provides a simple data-container for the Schema node.
0030  *
0031  * @category   Zend
0032  * @package    Zend_Ldap
0033  * @subpackage Schema
0034  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0035  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0036  */
0037 class Zend_Ldap_Node_Schema extends Zend_Ldap_Node_Abstract
0038 {
0039     const OBJECTCLASS_TYPE_UNKNOWN    = 0;
0040     const OBJECTCLASS_TYPE_STRUCTURAL = 1;
0041     const OBJECTCLASS_TYPE_ABSTRACT   = 3;
0042     const OBJECTCLASS_TYPE_AUXILIARY  = 4;
0043 
0044     /**
0045      * Factory method to create the Schema node.
0046      *
0047      * @param  Zend_Ldap $ldap
0048      * @return Zend_Ldap_Node_Schema
0049      * @throws Zend_Ldap_Exception
0050      */
0051     public static function create(Zend_Ldap $ldap)
0052     {
0053         $dn = $ldap->getRootDse()->getSchemaDn();
0054         $data = $ldap->getEntry($dn, array('*', '+'), true);
0055         switch ($ldap->getRootDse()->getServerType()) {
0056             case Zend_Ldap_Node_RootDse::SERVER_TYPE_ACTIVEDIRECTORY:
0057                 /**
0058                  * @see Zend_Ldap_Node_Schema_ActiveDirectory
0059                  */
0060                 // require_once 'Zend/Ldap/Node/Schema/ActiveDirectory.php';
0061                 return new Zend_Ldap_Node_Schema_ActiveDirectory($dn, $data, $ldap);
0062             case Zend_Ldap_Node_RootDse::SERVER_TYPE_OPENLDAP:
0063                 /**
0064                  * @see Zend_Ldap_Node_RootDse_ActiveDirectory
0065                  */
0066                 // require_once 'Zend/Ldap/Node/Schema/OpenLdap.php';
0067                 return new Zend_Ldap_Node_Schema_OpenLdap($dn, $data, $ldap);
0068             case Zend_Ldap_Node_RootDse::SERVER_TYPE_EDIRECTORY:
0069             default:
0070                 return new self($dn, $data, $ldap);
0071         }
0072     }
0073 
0074     /**
0075      * Constructor.
0076      *
0077      * Constructor is protected to enforce the use of factory methods.
0078      *
0079      * @param  Zend_Ldap_Dn $dn
0080      * @param  array        $data
0081      * @param  Zend_Ldap    $ldap
0082      */
0083     protected function __construct(Zend_Ldap_Dn $dn, array $data, Zend_Ldap $ldap)
0084     {
0085         parent::__construct($dn, $data, true);
0086         $this->_parseSchema($dn, $ldap);
0087     }
0088 
0089     /**
0090      * Parses the schema
0091      *
0092      * @param  Zend_Ldap_Dn $dn
0093      * @param  Zend_Ldap    $ldap
0094      * @return Zend_Ldap_Node_Schema Provides a fluent interface
0095      */
0096     protected function _parseSchema(Zend_Ldap_Dn $dn, Zend_Ldap $ldap)
0097     {
0098         return $this;
0099     }
0100 
0101     /**
0102      * Gets the attribute Types
0103      *
0104      * @return array
0105      */
0106     public function getAttributeTypes()
0107     {
0108         return array();
0109     }
0110 
0111     /**
0112      * Gets the object classes
0113      *
0114      * @return array
0115      */
0116     public function getObjectClasses()
0117     {
0118         return array();
0119     }
0120 }