Schema.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Ldap
  17. * @subpackage Schema
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Ldap_Node_Abstract
  24. */
  25. require_once 'Zend/Ldap/Node/Abstract.php';
  26. /**
  27. * Zend_Ldap_Node_Schema provides a simple data-container for the Schema node.
  28. *
  29. * @category Zend
  30. * @package Zend_Ldap
  31. * @subpackage Schema
  32. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Ldap_Node_Schema extends Zend_Ldap_Node_Abstract
  36. {
  37. const OBJECTCLASS_TYPE_UNKNOWN = 0;
  38. const OBJECTCLASS_TYPE_STRUCTURAL = 1;
  39. const OBJECTCLASS_TYPE_ABSTRACT = 3;
  40. const OBJECTCLASS_TYPE_AUXILIARY = 4;
  41. /**
  42. * Factory method to create the Schema node.
  43. *
  44. * @param Zend_Ldap $ldap
  45. * @return Zend_Ldap_Node_Schema
  46. * @throws Zend_Ldap_Exception
  47. */
  48. public static function create(Zend_Ldap $ldap)
  49. {
  50. $dn = $ldap->getRootDse()->getSchemaDn();
  51. $data = $ldap->getEntry($dn, array('*', '+'), true);
  52. switch ($ldap->getRootDse()->getServerType()) {
  53. case Zend_Ldap_Node_RootDse::SERVER_TYPE_ACTIVEDIRECTORY:
  54. /**
  55. * @see Zend_Ldap_Node_Schema_ActiveDirectory
  56. */
  57. require_once 'Zend/Ldap/Node/Schema/ActiveDirectory.php';
  58. return new Zend_Ldap_Node_Schema_ActiveDirectory($dn, $data, $ldap);
  59. case Zend_Ldap_Node_RootDse::SERVER_TYPE_OPENLDAP:
  60. /**
  61. * @see Zend_Ldap_Node_RootDse_ActiveDirectory
  62. */
  63. require_once 'Zend/Ldap/Node/Schema/OpenLdap.php';
  64. return new Zend_Ldap_Node_Schema_OpenLdap($dn, $data, $ldap);
  65. case Zend_Ldap_Node_RootDse::SERVER_TYPE_EDIRECTORY:
  66. default:
  67. return new self($dn, $data, $ldap);
  68. }
  69. }
  70. /**
  71. * Constructor.
  72. *
  73. * Constructor is protected to enforce the use of factory methods.
  74. *
  75. * @param Zend_Ldap_Dn $dn
  76. * @param array $data
  77. * @param Zend_Ldap $ldap
  78. */
  79. protected function __construct(Zend_Ldap_Dn $dn, array $data, Zend_Ldap $ldap)
  80. {
  81. parent::__construct($dn, $data, true);
  82. $this->_parseSchema($dn, $ldap);
  83. }
  84. /**
  85. * Parses the schema
  86. *
  87. * @param Zend_Ldap_Dn $dn
  88. * @param Zend_Ldap $ldap
  89. * @return Zend_Ldap_Node_Schema Provides a fluent interface
  90. */
  91. protected function _parseSchema(Zend_Ldap_Dn $dn, Zend_Ldap $ldap)
  92. {
  93. return $this;
  94. }
  95. /**
  96. * Gets the attribute Types
  97. *
  98. * @return array
  99. */
  100. public function getAttributeTypes()
  101. {
  102. return array();
  103. }
  104. /**
  105. * Gets the object classes
  106. *
  107. * @return array
  108. */
  109. public function getObjectClasses()
  110. {
  111. return array();
  112. }
  113. }