CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:04 -04:00
parent 514777e8d2
commit b11cbd8159
4546 changed files with 138 additions and 51 deletions

View file

@ -0,0 +1,485 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Node
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Attribute
*/
require_once 'Zend/Ldap/Attribute.php';
/**
* @see Zend_Ldap_Dn
*/
require_once 'Zend/Ldap/Dn.php';
/**
* Zend_Ldap_Node_Abstract provides a bas eimplementation for LDAP nodes
*
* @category Zend
* @package Zend_Ldap
* @subpackage Node
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Ldap_Node_Abstract implements ArrayAccess, Countable
{
protected static $_systemAttributes=array('createtimestamp', 'creatorsname',
'entrycsn', 'entrydn', 'entryuuid', 'hassubordinates', 'modifiersname',
'modifytimestamp', 'structuralobjectclass', 'subschemasubentry',
'distinguishedname', 'instancetype', 'name', 'objectcategory', 'objectguid',
'usnchanged', 'usncreated', 'whenchanged', 'whencreated');
/**
* Holds the node's DN.
*
* @var Zend_Ldap_Dn
*/
protected $_dn;
/**
* Holds the node's current data.
*
* @var array
*/
protected $_currentData;
/**
* Constructor.
*
* Constructor is protected to enforce the use of factory methods.
*
* @param Zend_Ldap_Dn $dn
* @param array $data
* @param boolean $fromDataSource
*/
protected function __construct(Zend_Ldap_Dn $dn, array $data, $fromDataSource)
{
$this->_dn = $dn;
$this->_loadData($data, $fromDataSource);
}
/**
* @param array $data
* @param boolean $fromDataSource
* @throws Zend_Ldap_Exception
*/
protected function _loadData(array $data, $fromDataSource)
{
if (array_key_exists('dn', $data)) {
unset($data['dn']);
}
ksort($data, SORT_STRING);
$this->_currentData = $data;
}
/**
* Reload node attributes from LDAP.
*
* This is an online method.
*
* @param Zend_Ldap $ldap
* @return Zend_Ldap_Node_Abstract Provides a fluid interface
* @throws Zend_Ldap_Exception
*/
public function reload(Zend_Ldap $ldap = null)
{
if ($ldap !== null) {
$data = $ldap->getEntry($this->_getDn(), array('*', '+'), true);
$this->_loadData($data, true);
}
return $this;
}
/**
* Gets the DN of the current node as a Zend_Ldap_Dn.
*
* This is an offline method.
*
* @return Zend_Ldap_Dn
*/
protected function _getDn()
{
return $this->_dn;
}
/**
* Gets the DN of the current node as a Zend_Ldap_Dn.
* The method returns a clone of the node's DN to prohibit modification.
*
* This is an offline method.
*
* @return Zend_Ldap_Dn
*/
public function getDn()
{
$dn = clone $this->_getDn();
return $dn;
}
/**
* Gets the DN of the current node as a string.
*
* This is an offline method.
*
* @param string $caseFold
* @return string
*/
public function getDnString($caseFold = null)
{
return $this->_getDn()->toString($caseFold);
}
/**
* Gets the DN of the current node as an array.
*
* This is an offline method.
*
* @param string $caseFold
* @return array
*/
public function getDnArray($caseFold = null)
{
return $this->_getDn()->toArray($caseFold);
}
/**
* Gets the RDN of the current node as a string.
*
* This is an offline method.
*
* @param string $caseFold
* @return string
*/
public function getRdnString($caseFold = null)
{
return $this->_getDn()->getRdnString($caseFold);
}
/**
* Gets the RDN of the current node as an array.
*
* This is an offline method.
*
* @param string $caseFold
* @return array
*/
public function getRdnArray($caseFold = null)
{
return $this->_getDn()->getRdn($caseFold);
}
/**
* Gets the objectClass of the node
*
* @return array
*/
public function getObjectClass()
{
return $this->getAttribute('objectClass', null);
}
/**
* Gets all attributes of node.
*
* The collection contains all attributes.
*
* This is an offline method.
*
* @param boolean $includeSystemAttributes
* @return array
*/
public function getAttributes($includeSystemAttributes = true)
{
$data = array();
foreach ($this->getData($includeSystemAttributes) as $name => $value) {
$data[$name] = $this->getAttribute($name, null);
}
return $data;
}
/**
* Returns the DN of the current node. {@see getDnString()}
*
* @return string
*/
public function toString()
{
return $this->getDnString();
}
/**
* Cast to string representation {@see toString()}
*
* @return string
*/
public function __toString()
{
return $this->toString();
}
/**
* Returns an array representation of the current node
*
* @param boolean $includeSystemAttributes
* @return array
*/
public function toArray($includeSystemAttributes = true)
{
$attributes = $this->getAttributes($includeSystemAttributes);
return array_merge(array('dn' => $this->getDnString()), $attributes);
}
/**
* Returns a JSON representation of the current node
*
* @param boolean $includeSystemAttributes
* @return string
*/
public function toJson($includeSystemAttributes = true)
{
return json_encode($this->toArray($includeSystemAttributes));
}
/**
* Gets node attributes.
*
* The array contains all attributes in its internal format (no conversion).
*
* This is an offline method.
*
* @param boolean $includeSystemAttributes
* @return array
*/
public function getData($includeSystemAttributes = true)
{
if ($includeSystemAttributes === false) {
$data = array();
foreach ($this->_currentData as $key => $value) {
if (!in_array($key, self::$_systemAttributes)) {
$data[$key] = $value;
}
}
return $data;
} else {
return $this->_currentData;
}
}
/**
* Checks whether a given attribute exists.
*
* If $emptyExists is false empty attributes (containing only array()) are
* treated as non-existent returning false.
* If $emptyExists is true empty attributes are treated as existent returning
* true. In this case method returns false only if the attribute name is
* missing in the key-collection.
*
* @param string $name
* @param boolean $emptyExists
* @return boolean
*/
public function existsAttribute($name, $emptyExists = false)
{
$name = strtolower($name);
if (isset($this->_currentData[$name])) {
if ($emptyExists) return true;
return count($this->_currentData[$name])>0;
}
else return false;
}
/**
* Checks if the given value(s) exist in the attribute
*
* @param string $attribName
* @param mixed|array $value
* @return boolean
*/
public function attributeHasValue($attribName, $value)
{
return Zend_Ldap_Attribute::attributeHasValue($this->_currentData, $attribName, $value);
}
/**
* Gets a LDAP attribute.
*
* This is an offline method.
*
* @param string $name
* @param integer $index
* @return mixed
* @throws Zend_Ldap_Exception
*/
public function getAttribute($name, $index = null)
{
if ($name == 'dn') {
return $this->getDnString();
}
else {
return Zend_Ldap_Attribute::getAttribute($this->_currentData, $name, $index);
}
}
/**
* Gets a LDAP date/time attribute.
*
* This is an offline method.
*
* @param string $name
* @param integer $index
* @return array|integer
* @throws Zend_Ldap_Exception
*/
public function getDateTimeAttribute($name, $index = null)
{
return Zend_Ldap_Attribute::getDateTimeAttribute($this->_currentData, $name, $index);
}
/**
* Sets a LDAP attribute.
*
* This is an offline method.
*
* @param string $name
* @param mixed $value
* @return null
* @throws BadMethodCallException
*/
public function __set($name, $value)
{
throw new BadMethodCallException();
}
/**
* Gets a LDAP attribute.
*
* This is an offline method.
*
* @param string $name
* @return array
* @throws Zend_Ldap_Exception
*/
public function __get($name)
{
return $this->getAttribute($name, null);
}
/**
* Deletes a LDAP attribute.
*
* This method deletes the attribute.
*
* This is an offline method.
*
* @param string $name
* @return null
* @throws BadMethodCallException
*/
public function __unset($name)
{
throw new BadMethodCallException();
}
/**
* Checks whether a given attribute exists.
*
* Empty attributes will be treated as non-existent.
*
* @param string $name
* @return boolean
*/
public function __isset($name)
{
return $this->existsAttribute($name, false);
}
/**
* Sets a LDAP attribute.
* Implements ArrayAccess.
*
* This is an offline method.
*
* @param string $name
* @param mixed $value
* @return null
* @throws BadMethodCallException
*/
public function offsetSet($name, $value)
{
throw new BadMethodCallException();
}
/**
* Gets a LDAP attribute.
* Implements ArrayAccess.
*
* This is an offline method.
*
* @param string $name
* @return array
* @throws Zend_Ldap_Exception
*/
public function offsetGet($name)
{
return $this->getAttribute($name, null);
}
/**
* Deletes a LDAP attribute.
* Implements ArrayAccess.
*
* This method deletes the attribute.
*
* This is an offline method.
*
* @param string $name
* @return null
* @throws BadMethodCallException
*/
public function offsetUnset($name)
{
throw new BadMethodCallException();
}
/**
* Checks whether a given attribute exists.
* Implements ArrayAccess.
*
* Empty attributes will be treated as non-existent.
*
* @param string $name
* @return boolean
*/
public function offsetExists($name)
{
return $this->existsAttribute($name, false);
}
/**
* Returns the number of attributes in node.
* Implements Countable
*
* @return int
*/
public function count()
{
return count($this->_currentData);
}
}

View file

@ -0,0 +1,209 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Node
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ChildrenIterator.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node
*/
require_once 'Zend/Ldap/Node.php';
/**
* Zend_Ldap_Node_ChildrenIterator provides an iterator to a collection of children nodes.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Node
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_ChildrenIterator implements Iterator, Countable, RecursiveIterator, ArrayAccess
{
/**
* An array of Zend_Ldap_Node objects
*
* @var array
*/
private $_data;
/**
* Constructor.
*
* @param array $data
* @return void
*/
public function __construct(array $data)
{
$this->_data = $data;
}
/**
* Returns the number of child nodes.
* Implements Countable
*
* @return int
*/
public function count()
{
return count($this->_data);
}
/**
* Return the current child.
* Implements Iterator
*
* @return Zend_Ldap_Node
*/
public function current()
{
return current($this->_data);
}
/**
* Return the child'd RDN.
* Implements Iterator
*
* @return string
*/
public function key()
{
return key($this->_data);
}
/**
* Move forward to next child.
* Implements Iterator
*/
public function next()
{
next($this->_data);
}
/**
* Rewind the Iterator to the first child.
* Implements Iterator
*/
public function rewind()
{
reset($this->_data);
}
/**
* Check if there is a current child
* after calls to rewind() or next().
* Implements Iterator
*
* @return boolean
*/
public function valid()
{
return (current($this->_data)!==false);
}
/**
* Checks if current node has children.
* Returns whether the current element has children.
*
* @return boolean
*/
public function hasChildren()
{
if ($this->current() instanceof Zend_Ldap_Node) {
return $this->current()->hasChildren();
} else {
return false;
}
}
/**
* Returns the children for the current node.
*
* @return Zend_Ldap_Node_ChildrenIterator
*/
public function getChildren()
{
if ($this->current() instanceof Zend_Ldap_Node) {
return $this->current()->getChildren();
} else {
return null;
}
}
/**
* Returns a child with a given RDN.
* Implements ArrayAccess.
*
* @param string $rdn
* @return Zend_Ldap_node
*/
public function offsetGet($rdn)
{
if ($this->offsetExists($rdn)) {
return $this->_data[$rdn];
} else {
return null;
}
}
/**
* Checks whether a given rdn exists.
* Implements ArrayAccess.
*
* @param string $rdn
* @return boolean
*/
public function offsetExists($rdn)
{
return (array_key_exists($rdn, $this->_data));
}
/**
* Does nothing.
* Implements ArrayAccess.
*
* @param string $name
* @return null
*/
public function offsetUnset($name) { }
/**
* Does nothing.
* Implements ArrayAccess.
*
* @param string $name
* @param mixed $value
* @return null
*/
public function offsetSet($name, $value) { }
/**
* Get all children as an array
*
* @return array
*/
public function toArray()
{
$data = array();
foreach ($this as $rdn => $node) {
$data[$rdn] = $node;
}
return $data;
}
}

View file

@ -0,0 +1,67 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Node
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Collection.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Collection
*/
require_once 'Zend/Ldap/Collection.php';
/**
* Zend_Ldap_Node_Collection provides a collecion of nodes.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Node
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_Collection extends Zend_Ldap_Collection
{
/**
* Creates the data structure for the given entry data
*
* @param array $data
* @return Zend_Ldap_Node
*/
protected function _createEntry(array $data)
{
/**
* @see Zend_Ldap_Node
*/
require_once 'Zend/Ldap/Node.php';
$node = Zend_Ldap_Node::fromArray($data, true);
$node->attachLdap($this->_iterator->getLdap());
return $node;
}
/**
* Return the child key (DN).
* Implements Iterator and RecursiveIterator
*
* @return string
*/
public function key()
{
return $this->_iterator->key();
}
}

View file

@ -0,0 +1,158 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage RootDSE
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RootDse.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_Abstract
*/
require_once 'Zend/Ldap/Node/Abstract.php';
/**
* Zend_Ldap_Node_RootDse provides a simple data-container for the RootDSE node.
*
* @category Zend
* @package Zend_Ldap
* @subpackage RootDSE
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_RootDse extends Zend_Ldap_Node_Abstract
{
const SERVER_TYPE_GENERIC = 1;
const SERVER_TYPE_OPENLDAP = 2;
const SERVER_TYPE_ACTIVEDIRECTORY = 3;
const SERVER_TYPE_EDIRECTORY = 4;
/**
* Factory method to create the RootDSE.
*
* @param Zend_Ldap $ldap
* @return Zend_Ldap_Node_RootDse
* @throws Zend_Ldap_Exception
*/
public static function create(Zend_Ldap $ldap)
{
$dn = Zend_Ldap_Dn::fromString('');
$data = $ldap->getEntry($dn, array('*', '+'), true);
if (isset($data['domainfunctionality'])) {
/**
* @see Zend_Ldap_Node_RootDse_ActiveDirectory
*/
require_once 'Zend/Ldap/Node/RootDse/ActiveDirectory.php';
return new Zend_Ldap_Node_RootDse_ActiveDirectory($dn, $data);
} else if (isset($data['dsaname'])) {
/**
* @see Zend_Ldap_Node_RootDse_ActiveDirectory
*/
require_once 'Zend/Ldap/Node/RootDse/eDirectory.php';
return new Zend_Ldap_Node_RootDse_eDirectory($dn, $data);
} else if (isset($data['structuralobjectclass']) &&
$data['structuralobjectclass'][0] === 'OpenLDAProotDSE') {
/**
* @see Zend_Ldap_Node_RootDse_OpenLdap
*/
require_once 'Zend/Ldap/Node/RootDse/OpenLdap.php';
return new Zend_Ldap_Node_RootDse_OpenLdap($dn, $data);
} else {
return new self($dn, $data);
}
}
/**
* Constructor.
*
* Constructor is protected to enforce the use of factory methods.
*
* @param Zend_Ldap_Dn $dn
* @param array $data
*/
protected function __construct(Zend_Ldap_Dn $dn, array $data)
{
parent::__construct($dn, $data, true);
}
/**
* Gets the namingContexts.
*
* @return array
*/
public function getNamingContexts()
{
return $this->getAttribute('namingContexts', null);
}
/**
* Gets the subschemaSubentry.
*
* @return string|null
*/
public function getSubschemaSubentry()
{
return $this->getAttribute('subschemaSubentry', 0);
}
/**
* Determines if the version is supported
*
* @param string|int|array $versions version(s) to check
* @return boolean
*/
public function supportsVersion($versions)
{
return $this->attributeHasValue('supportedLDAPVersion', $versions);
}
/**
* Determines if the sasl mechanism is supported
*
* @param string|array $mechlist SASL mechanisms to check
* @return boolean
*/
public function supportsSaslMechanism($mechlist)
{
return $this->attributeHasValue('supportedSASLMechanisms', $mechlist);
}
/**
* Gets the server type
*
* @return int
*/
public function getServerType()
{
return self::SERVER_TYPE_GENERIC;
}
/**
* Returns the schema DN
*
* @return Zend_Ldap_Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSubschemaSubentry();
/**
* @see Zend_Ldap_Dn
*/
require_once 'Zend/Ldap/Dn.php';
return Zend_Ldap_Dn::fromString($schemaDn);
}
}

View file

@ -0,0 +1,247 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage RootDSE
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ActiveDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_RootDse
*/
require_once 'Zend/Ldap/Node/RootDse.php';
/**
* Zend_Ldap_Node_RootDse provides a simple data-container for the RootDSE node of
* an Active Directory server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage RootDSE
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_RootDse_ActiveDirectory extends Zend_Ldap_Node_RootDse
{
/**
* Gets the configurationNamingContext.
*
* @return string|null
*/
public function getConfigurationNamingContext()
{
return $this->getAttribute('configurationNamingContext', 0);
}
/**
* Gets the currentTime.
*
* @return string|null
*/
public function getCurrentTime()
{
return $this->getAttribute('currentTime', 0);
}
/**
* Gets the defaultNamingContext.
*
* @return string|null
*/
public function getDefaultNamingContext()
{
return $this->getAttribute('defaultNamingContext', 0);
}
/**
* Gets the dnsHostName.
*
* @return string|null
*/
public function getDnsHostName()
{
return $this->getAttribute('dnsHostName', 0);
}
/**
* Gets the domainControllerFunctionality.
*
* @return string|null
*/
public function getDomainControllerFunctionality()
{
return $this->getAttribute('domainControllerFunctionality', 0);
}
/**
* Gets the domainFunctionality.
*
* @return string|null
*/
public function getDomainFunctionality()
{
return $this->getAttribute('domainFunctionality', 0);
}
/**
* Gets the dsServiceName.
*
* @return string|null
*/
public function getDsServiceName()
{
return $this->getAttribute('dsServiceName', 0);
}
/**
* Gets the forestFunctionality.
*
* @return string|null
*/
public function getForestFunctionality()
{
return $this->getAttribute('forestFunctionality', 0);
}
/**
* Gets the highestCommittedUSN.
*
* @return string|null
*/
public function getHighestCommittedUSN()
{
return $this->getAttribute('highestCommittedUSN', 0);
}
/**
* Gets the isGlobalCatalogReady.
*
* @return string|null
*/
public function getIsGlobalCatalogReady()
{
return $this->getAttribute('isGlobalCatalogReady', 0);
}
/**
* Gets the isSynchronized.
*
* @return string|null
*/
public function getIsSynchronized()
{
return $this->getAttribute('isSynchronized', 0);
}
/**
* Gets the ldapServiceName.
*
* @return string|null
*/
public function getLdapServiceName()
{
return $this->getAttribute('ldapServiceName', 0);
}
/**
* Gets the rootDomainNamingContext.
*
* @return string|null
*/
public function getRootDomainNamingContext()
{
return $this->getAttribute('rootDomainNamingContext', 0);
}
/**
* Gets the schemaNamingContext.
*
* @return string|null
*/
public function getSchemaNamingContext()
{
return $this->getAttribute('schemaNamingContext', 0);
}
/**
* Gets the serverName.
*
* @return string|null
*/
public function getServerName()
{
return $this->getAttribute('serverName', 0);
}
/**
* Determines if the capability is supported
*
* @param string|string|array $oids capability(s) to check
* @return boolean
*/
public function supportsCapability($oids)
{
return $this->attributeHasValue('supportedCapabilities', $oids);
}
/**
* Determines if the control is supported
*
* @param string|array $oids control oid(s) to check
* @return boolean
*/
public function supportsControl($oids)
{
return $this->attributeHasValue('supportedControl', $oids);
}
/**
* Determines if the version is supported
*
* @param string|array $policies policy(s) to check
* @return boolean
*/
public function supportsPolicy($policies)
{
return $this->attributeHasValue('supportedLDAPPolicies', $policies);
}
/**
* Gets the server type
*
* @return int
*/
public function getServerType()
{
return self::SERVER_TYPE_ACTIVEDIRECTORY;
}
/**
* Returns the schema DN
*
* @return Zend_Ldap_Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSchemaNamingContext();
/**
* @see Zend_Ldap_Dn
*/
require_once 'Zend/Ldap/Dn.php';
return Zend_Ldap_Dn::fromString($schemaDn);
}
}

View file

@ -0,0 +1,102 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage RootDSE
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: OpenLdap.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_RootDse
*/
require_once 'Zend/Ldap/Node/RootDse.php';
/**
* Zend_Ldap_Node_RootDse provides a simple data-container for the RootDSE node of
* an OpenLDAP server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage RootDSE
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_RootDse_OpenLdap extends Zend_Ldap_Node_RootDse
{
/**
* Gets the configContext.
*
* @return string|null
*/
public function getConfigContext()
{
return $this->getAttribute('configContext', 0);
}
/**
* Gets the monitorContext.
*
* @return string|null
*/
public function getMonitorContext()
{
return $this->getAttribute('monitorContext', 0);
}
/**
* Determines if the control is supported
*
* @param string|array $oids control oid(s) to check
* @return boolean
*/
public function supportsControl($oids)
{
return $this->attributeHasValue('supportedControl', $oids);
}
/**
* Determines if the extension is supported
*
* @param string|array $oids oid(s) to check
* @return boolean
*/
public function supportsExtension($oids)
{
return $this->attributeHasValue('supportedExtension', $oids);
}
/**
* Determines if the feature is supported
*
* @param string|array $oids feature oid(s) to check
* @return boolean
*/
public function supportsFeature($oids)
{
return $this->attributeHasValue('supportedFeatures', $oids);
}
/**
* Gets the server type
*
* @return int
*/
public function getServerType()
{
return self::SERVER_TYPE_OPENLDAP;
}
}

View file

@ -0,0 +1,160 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage RootDSE
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: eDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_RootDse
*/
require_once 'Zend/Ldap/Node/RootDse.php';
/**
* Zend_Ldap_Node_RootDse provides a simple data-container for the RootDSE node of
* a Novell eDirectory server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage RootDSE
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_RootDse_eDirectory extends Zend_Ldap_Node_RootDse
{
/**
* Determines if the extension is supported
*
* @param string|array $oids oid(s) to check
* @return boolean
*/
public function supportsExtension($oids)
{
return $this->attributeHasValue('supportedExtension', $oids);
}
/**
* Gets the vendorName.
*
* @return string|null
*/
public function getVendorName()
{
return $this->getAttribute('vendorName', 0);
}
/**
* Gets the vendorVersion.
*
* @return string|null
*/
public function getVendorVersion()
{
return $this->getAttribute('vendorVersion', 0);
}
/**
* Gets the dsaName.
*
* @return string|null
*/
public function getDsaName()
{
return $this->getAttribute('dsaName', 0);
}
/**
* Gets the server statistics "errors".
*
* @return string|null
*/
public function getStatisticsErrors()
{
return $this->getAttribute('errors', 0);
}
/**
* Gets the server statistics "securityErrors".
*
* @return string|null
*/
public function getStatisticsSecurityErrors()
{
return $this->getAttribute('securityErrors', 0);
}
/**
* Gets the server statistics "chainings".
*
* @return string|null
*/
public function getStatisticsChainings()
{
return $this->getAttribute('chainings', 0);
}
/**
* Gets the server statistics "referralsReturned".
*
* @return string|null
*/
public function getStatisticsReferralsReturned()
{
return $this->getAttribute('referralsReturned', 0);
}
/**
* Gets the server statistics "extendedOps".
*
* @return string|null
*/
public function getStatisticsExtendedOps()
{
return $this->getAttribute('extendedOps', 0);
}
/**
* Gets the server statistics "abandonOps".
*
* @return string|null
*/
public function getStatisticsAbandonOps()
{
return $this->getAttribute('abandonOps', 0);
}
/**
* Gets the server statistics "wholeSubtreeSearchOps".
*
* @return string|null
*/
public function getStatisticsWholeSubtreeSearchOps()
{
return $this->getAttribute('wholeSubtreeSearchOps', 0);
}
/**
* Gets the server type
*
* @return int
*/
public function getServerType()
{
return self::SERVER_TYPE_EDIRECTORY;
}
}

View file

@ -0,0 +1,120 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Schema.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_Abstract
*/
require_once 'Zend/Ldap/Node/Abstract.php';
/**
* Zend_Ldap_Node_Schema provides a simple data-container for the Schema node.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_Schema extends Zend_Ldap_Node_Abstract
{
const OBJECTCLASS_TYPE_UNKNOWN = 0;
const OBJECTCLASS_TYPE_STRUCTURAL = 1;
const OBJECTCLASS_TYPE_ABSTRACT = 3;
const OBJECTCLASS_TYPE_AUXILIARY = 4;
/**
* Factory method to create the Schema node.
*
* @param Zend_Ldap $ldap
* @return Zend_Ldap_Node_Schema
* @throws Zend_Ldap_Exception
*/
public static function create(Zend_Ldap $ldap)
{
$dn = $ldap->getRootDse()->getSchemaDn();
$data = $ldap->getEntry($dn, array('*', '+'), true);
switch ($ldap->getRootDse()->getServerType()) {
case Zend_Ldap_Node_RootDse::SERVER_TYPE_ACTIVEDIRECTORY:
/**
* @see Zend_Ldap_Node_Schema_ActiveDirectory
*/
require_once 'Zend/Ldap/Node/Schema/ActiveDirectory.php';
return new Zend_Ldap_Node_Schema_ActiveDirectory($dn, $data, $ldap);
case Zend_Ldap_Node_RootDse::SERVER_TYPE_OPENLDAP:
/**
* @see Zend_Ldap_Node_RootDse_ActiveDirectory
*/
require_once 'Zend/Ldap/Node/Schema/OpenLdap.php';
return new Zend_Ldap_Node_Schema_OpenLdap($dn, $data, $ldap);
case Zend_Ldap_Node_RootDse::SERVER_TYPE_EDIRECTORY:
default:
return new self($dn, $data, $ldap);
}
}
/**
* Constructor.
*
* Constructor is protected to enforce the use of factory methods.
*
* @param Zend_Ldap_Dn $dn
* @param array $data
* @param Zend_Ldap $ldap
*/
protected function __construct(Zend_Ldap_Dn $dn, array $data, Zend_Ldap $ldap)
{
parent::__construct($dn, $data, true);
$this->_parseSchema($dn, $ldap);
}
/**
* Parses the schema
*
* @param Zend_Ldap_Dn $dn
* @param Zend_Ldap $ldap
* @return Zend_Ldap_Node_Schema Provides a fluid interface
*/
protected function _parseSchema(Zend_Ldap_Dn $dn, Zend_Ldap $ldap)
{
return $this;
}
/**
* Gets the attribute Types
*
* @return array
*/
public function getAttributeTypes()
{
return array();
}
/**
* Gets the object classes
*
* @return array
*/
public function getObjectClasses()
{
return array();
}
}

View file

@ -0,0 +1,103 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ActiveDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_Schema
*/
require_once 'Zend/Ldap/Node/Schema.php';
/**
* @see Zend_Ldap_Node_Schema_AttributeType_ActiveDirectory
*/
require_once 'Zend/Ldap/Node/Schema/AttributeType/ActiveDirectory.php';
/**
* @see Zend_Ldap_Node_Schema_ObjectClass_ActiveDirectory
*/
require_once 'Zend/Ldap/Node/Schema/ObjectClass/ActiveDirectory.php';
/**
* Zend_Ldap_Node_Schema_ActiveDirectory provides a simple data-container for the Schema node of
* an Active Directory server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_Schema_ActiveDirectory extends Zend_Ldap_Node_Schema
{
/**
* The attribute Types
*
* @var array
*/
protected $_attributeTypes = array();
/**
* The object classes
*
* @var array
*/
protected $_objectClasses = array();
/**
* Parses the schema
*
* @param Zend_Ldap_Dn $dn
* @param Zend_Ldap $ldap
* @return Zend_Ldap_Node_Schema Provides a fluid interface
*/
protected function _parseSchema(Zend_Ldap_Dn $dn, Zend_Ldap $ldap)
{
parent::_parseSchema($dn, $ldap);
foreach ($ldap->search('(objectClass=classSchema)', $dn,
Zend_Ldap::SEARCH_SCOPE_ONE) as $node) {
$val = new Zend_Ldap_Node_Schema_ObjectClass_ActiveDirectory($node);
$this->_objectClasses[$val->getName()] = $val;
}
foreach ($ldap->search('(objectClass=attributeSchema)', $dn,
Zend_Ldap::SEARCH_SCOPE_ONE) as $node) {
$val = new Zend_Ldap_Node_Schema_AttributeType_ActiveDirectory($node);
$this->_attributeTypes[$val->getName()] = $val;
}
return $this;
}
/**
* Gets the attribute Types
*
* @return array
*/
public function getAttributeTypes()
{
return $this->_attributeTypes;
}
/**
* Gets the object classes
*
* @return array
*/
public function getObjectClasses()
{
return $this->_objectClasses;
}
}

View file

@ -0,0 +1,104 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ActiveDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_Schema_Item
*/
require_once 'Zend/Ldap/Node/Schema/Item.php';
/**
* @see Zend_Ldap_Node_Schema_AttributeType_Interface
*/
require_once 'Zend/Ldap/Node/Schema/AttributeType/Interface.php';
/**
* Zend_Ldap_Node_Schema_AttributeType_ActiveDirectory provides access to the attribute type
* schema information on an Active Directory server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_Schema_AttributeType_ActiveDirectory extends Zend_Ldap_Node_Schema_Item
implements Zend_Ldap_Node_Schema_AttributeType_Interface
{
/**
* Gets the attribute name
*
* @return string
*/
public function getName()
{
return $this->ldapdisplayname[0];
}
/**
* Gets the attribute OID
*
* @return string
*/
public function getOid()
{
}
/**
* Gets the attribute syntax
*
* @return string
*/
public function getSyntax()
{
}
/**
* Gets the attribute maximum length
*
* @return int|null
*/
public function getMaxLength()
{
}
/**
* Returns if the attribute is single-valued.
*
* @return boolean
*/
public function isSingleValued()
{
}
/**
* Gets the attribute description
*
* @return string
*/
public function getDescription()
{
}
}

View file

@ -0,0 +1,75 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Zend_Ldap_Node_Schema_AttributeType_Interface provides a contract for schema attribute-types.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Ldap_Node_Schema_AttributeType_Interface
{
/**
* Gets the attribute name
*
* @return string
*/
public function getName();
/**
* Gets the attribute OID
*
* @return string
*/
public function getOid();
/**
* Gets the attribute syntax
*
* @return string
*/
public function getSyntax();
/**
* Gets the attribute maximum length
*
* @return int|null
*/
public function getMaxLength();
/**
* Returns if the attribute is single-valued.
*
* @return boolean
*/
public function isSingleValued();
/**
* Gets the attribute description
*
* @return string
*/
public function getDescription();
}

View file

@ -0,0 +1,129 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: OpenLdap.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_Schema_Item
*/
require_once 'Zend/Ldap/Node/Schema/Item.php';
/**
* @see Zend_Ldap_Node_Schema_AttributeType_Interface
*/
require_once 'Zend/Ldap/Node/Schema/AttributeType/Interface.php';
/**
* Zend_Ldap_Node_Schema_AttributeType_OpenLdap provides access to the attribute type
* schema information on an OpenLDAP server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_Schema_AttributeType_OpenLdap extends Zend_Ldap_Node_Schema_Item
implements Zend_Ldap_Node_Schema_AttributeType_Interface
{
/**
* Gets the attribute name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Gets the attribute OID
*
* @return string
*/
public function getOid()
{
return $this->oid;
}
/**
* Gets the attribute syntax
*
* @return string
*/
public function getSyntax()
{
if ($this->syntax === null) {
$parent = $this->getParent();
if ($parent === null) return null;
else return $parent->getSyntax();
} else {
return $this->syntax;
}
}
/**
* Gets the attribute maximum length
*
* @return int|null
*/
public function getMaxLength()
{
$maxLength = $this->{'max-length'};
if ($maxLength === null) {
$parent = $this->getParent();
if ($parent === null) return null;
else return $parent->getMaxLength();
} else {
return (int)$maxLength;
}
}
/**
* Returns if the attribute is single-valued.
*
* @return boolean
*/
public function isSingleValued()
{
return $this->{'single-value'};
}
/**
* Gets the attribute description
*
* @return string
*/
public function getDescription()
{
return $this->desc;
}
/**
* Returns the parent attribute type in the inhertitance tree if one exists
*
* @return Zend_Ldap_Node_Schema_AttributeType_OpenLdap|null
*/
public function getParent()
{
if (count($this->_parents) === 1) {
return $this->_parents[0];
}
}
}

View file

@ -0,0 +1,163 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Item.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Zend_Ldap_Node_Schema_Item provides a base implementation for managing schema
* items like objectClass and attribute.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Ldap_Node_Schema_Item implements ArrayAccess, Countable
{
/**
* The underlying data
*
* @var array
*/
protected $_data;
/**
* Constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->setData($data);
}
/**
* Sets the data
*
* @param array $data
* @return Zend_Ldap_Node_Schema_Item Provides a fluid interface
*/
public function setData(array $data)
{
$this->_data = $data;
return $this;
}
/**
* Gets the data
*
* @return array
*/
public function getData()
{
return $this->_data;
}
/**
* Gets a specific attribute from this item
*
* @param string $name
* @return mixed
*/
public function __get($name)
{
if (array_key_exists($name, $this->_data)) {
return $this->_data[$name];
} else {
return null;
}
}
/**
* Checks whether a specific attribute exists.
*
* @param string $name
* @return boolean
*/
public function __isset($name)
{
return (array_key_exists($name, $this->_data));
}
/**
* Always throws BadMethodCallException
* Implements ArrayAccess.
*
* This method is needed for a full implementation of ArrayAccess
*
* @param string $name
* @param mixed $value
* @return null
* @throws BadMethodCallException
*/
public function offsetSet($name, $value)
{
throw new BadMethodCallException();
}
/**
* Gets a specific attribute from this item
*
* @param string $name
* @return mixed
*/
public function offsetGet($name)
{
return $this->__get($name);
}
/**
* Always throws BadMethodCallException
* Implements ArrayAccess.
*
* This method is needed for a full implementation of ArrayAccess
*
* @param string $name
* @return null
* @throws BadMethodCallException
*/
public function offsetUnset($name)
{
throw new BadMethodCallException();
}
/**
* Checks whether a specific attribute exists.
*
* @param string $name
* @return boolean
*/
public function offsetExists($name)
{
return $this->__isset($name);
}
/**
* Returns the number of attributes.
* Implements Countable
*
* @return int
*/
public function count()
{
return count($this->_data);
}
}

View file

@ -0,0 +1,115 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ActiveDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_Schema_Item
*/
require_once 'Zend/Ldap/Node/Schema/Item.php';
/**
* @see Zend_Ldap_Node_Schema_ObjectClass_Interface
*/
require_once 'Zend/Ldap/Node/Schema/ObjectClass/Interface.php';
/**
* Zend_Ldap_Node_Schema_ObjectClass_ActiveDirectory provides access to the objectClass
* schema information on an Active Directory server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_Schema_ObjectClass_ActiveDirectory extends Zend_Ldap_Node_Schema_Item
implements Zend_Ldap_Node_Schema_ObjectClass_Interface
{
/**
* Gets the objectClass name
*
* @return string
*/
public function getName()
{
return $this->ldapdisplayname[0];
}
/**
* Gets the objectClass OID
*
* @return string
*/
public function getOid()
{
}
/**
* Gets the attributes that this objectClass must contain
*
* @return array
*/
public function getMustContain()
{
}
/**
* Gets the attributes that this objectClass may contain
*
* @return array
*/
public function getMayContain()
{
}
/**
* Gets the objectClass description
*
* @return string
*/
public function getDescription()
{
}
/**
* Gets the objectClass type
*
* @return integer
*/
public function getType()
{
}
/**
* Returns the parent objectClasses of this class.
* This includes structural, abstract and auxiliary objectClasses
*
* @return array
*/
public function getParentClasses()
{
}
}

View file

@ -0,0 +1,83 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Zend_Ldap_Node_Schema_ObjectClass_Interface provides a contract for schema objectClasses.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Ldap_Node_Schema_ObjectClass_Interface
{
/**
* Gets the objectClass name
*
* @return string
*/
public function getName();
/**
* Gets the objectClass OID
*
* @return string
*/
public function getOid();
/**
* Gets the attributes that this objectClass must contain
*
* @return array
*/
public function getMustContain();
/**
* Gets the attributes that this objectClass may contain
*
* @return array
*/
public function getMayContain();
/**
* Gets the objectClass description
*
* @return string
*/
public function getDescription();
/**
* Gets the objectClass type
*
* @return integer
*/
public function getType();
/**
* Returns the parent objectClasses of this class.
* This includes structural, abstract and auxiliary objectClasses
*
* @return array
*/
public function getParentClasses();
}

View file

@ -0,0 +1,175 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: OpenLdap.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_Schema_Item
*/
require_once 'Zend/Ldap/Node/Schema/Item.php';
/**
* @see Zend_Ldap_Node_Schema_ObjectClass_Interface
*/
require_once 'Zend/Ldap/Node/Schema/ObjectClass/Interface.php';
/**
* Zend_Ldap_Node_Schema_ObjectClass_OpenLdap provides access to the objectClass
* schema information on an OpenLDAP server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_Schema_ObjectClass_OpenLdap extends Zend_Ldap_Node_Schema_Item
implements Zend_Ldap_Node_Schema_ObjectClass_Interface
{
/**
* All inherited "MUST" attributes
*
* @var array
*/
protected $_inheritedMust = null;
/**
* All inherited "MAY" attributes
*
* @var array
*/
protected $_inheritedMay = null;
/**
* Gets the objectClass name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Gets the objectClass OID
*
* @return string
*/
public function getOid()
{
return $this->oid;
}
/**
* Gets the attributes that this objectClass must contain
*
* @return array
*/
public function getMustContain()
{
if ($this->_inheritedMust === null) {
$this->_resolveInheritance();
}
return $this->_inheritedMust;
}
/**
* Gets the attributes that this objectClass may contain
*
* @return array
*/
public function getMayContain()
{
if ($this->_inheritedMay === null) {
$this->_resolveInheritance();
}
return $this->_inheritedMay;
}
/**
* Resolves the inheritance tree
*
* @return void
*/
protected function _resolveInheritance()
{
$must = $this->must;
$may = $this->may;
foreach ($this->getParents() as $p) {
$must = array_merge($must, $p->getMustContain());
$may = array_merge($may, $p->getMayContain());
}
$must = array_unique($must);
$may = array_unique($may);
$may = array_diff($may, $must);
sort($must, SORT_STRING);
sort($may, SORT_STRING);
$this->_inheritedMust = $must;
$this->_inheritedMay = $may;
}
/**
* Gets the objectClass description
*
* @return string
*/
public function getDescription()
{
return $this->desc;
}
/**
* Gets the objectClass type
*
* @return integer
*/
public function getType()
{
if ($this->structural) {
return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_STRUCTURAL;
} else if ($this->abstract) {
return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_ABSTRACT;
} else if ($this->auxiliary) {
return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_AUXILIARY;
} else {
return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_UNKNOWN;
}
}
/**
* Returns the parent objectClasses of this class.
* This includes structural, abstract and auxiliary objectClasses
*
* @return array
*/
public function getParentClasses()
{
return $this->sup;
}
/**
* Returns the parent object classes in the inhertitance tree if one exists
*
* @return array of Zend_Ldap_Node_Schema_ObjectClass_OpenLdap
*/
public function getParents()
{
return $this->_parents;
}
}

View file

@ -0,0 +1,502 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: OpenLdap.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Ldap_Node_Schema
*/
require_once 'Zend/Ldap/Node/Schema.php';
/**
* @see Zend_Ldap_Node_Schema_AttributeType_OpenLdap
*/
require_once 'Zend/Ldap/Node/Schema/AttributeType/OpenLdap.php';
/**
* @see Zend_Ldap_Node_Schema_ObjectClass_OpenLdap
*/
require_once 'Zend/Ldap/Node/Schema/ObjectClass/OpenLdap.php';
/**
* Zend_Ldap_Node_Schema_OpenLdap provides a simple data-container for the Schema node of
* an OpenLDAP server.
*
* @category Zend
* @package Zend_Ldap
* @subpackage Schema
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Ldap_Node_Schema_OpenLdap extends Zend_Ldap_Node_Schema
{
/**
* The attribute Types
*
* @var array
*/
protected $_attributeTypes = null;
/**
* The object classes
*
* @var array
*/
protected $_objectClasses = null;
/**
* The LDAP syntaxes
*
* @var array
*/
protected $_ldapSyntaxes = null;
/**
* The matching rules
*
* @var array
*/
protected $_matchingRules = null;
/**
* The matching rule use
*
* @var array
*/
protected $_matchingRuleUse = null;
/**
* Parses the schema
*
* @param Zend_Ldap_Dn $dn
* @param Zend_Ldap $ldap
* @return Zend_Ldap_Node_Schema Provides a fluid interface
*/
protected function _parseSchema(Zend_Ldap_Dn $dn, Zend_Ldap $ldap)
{
parent::_parseSchema($dn, $ldap);
$this->_loadAttributeTypes();
$this->_loadLdapSyntaxes();
$this->_loadMatchingRules();
$this->_loadMatchingRuleUse();
$this->_loadObjectClasses();
return $this;
}
/**
* Gets the attribute Types
*
* @return array
*/
public function getAttributeTypes()
{
return $this->_attributeTypes;
}
/**
* Gets the object classes
*
* @return array
*/
public function getObjectClasses()
{
return $this->_objectClasses;
}
/**
* Gets the LDAP syntaxes
*
* @return array
*/
public function getLdapSyntaxes()
{
return $this->_ldapSyntaxes;
}
/**
* Gets the matching rules
*
* @return array
*/
public function getMatchingRules()
{
return $this->_matchingRules;
}
/**
* Gets the matching rule use
*
* @return array
*/
public function getMatchingRuleUse()
{
return $this->_matchingRuleUse;
}
/**
* Loads the attribute Types
*
* @return void
*/
protected function _loadAttributeTypes()
{
$this->_attributeTypes = array();
foreach ($this->getAttribute('attributeTypes') as $value) {
$val = $this->_parseAttributeType($value);
$val = new Zend_Ldap_Node_Schema_AttributeType_OpenLdap($val);
$this->_attributeTypes[$val->getName()] = $val;
}
foreach ($this->_attributeTypes as $val) {
if (count($val->sup) > 0) {
$this->_resolveInheritance($val, $this->_attributeTypes);
}
foreach ($val->aliases as $alias) {
$this->_attributeTypes[$alias] = $val;
}
}
ksort($this->_attributeTypes, SORT_STRING);
}
/**
* Parses an attributeType value
*
* @param string $value
* @return array
*/
protected function _parseAttributeType($value)
{
$attributeType = array(
'oid' => null,
'name' => null,
'desc' => null,
'obsolete' => false,
'sup' => null,
'equality' => null,
'ordering' => null,
'substr' => null,
'syntax' => null,
'max-length' => null,
'single-value' => false,
'collective' => false,
'no-user-modification' => false,
'usage' => 'userApplications',
'_string' => $value,
'_parents' => array());
$tokens = $this->_tokenizeString($value);
$attributeType['oid'] = array_shift($tokens); // first token is the oid
$this->_parseLdapSchemaSyntax($attributeType, $tokens);
if (array_key_exists('syntax', $attributeType)) {
// get max length from syntax
if (preg_match('/^(.+){(\d+)}$/', $attributeType['syntax'], $matches)) {
$attributeType['syntax'] = $matches[1];
$attributeType['max-length'] = $matches[2];
}
}
$this->_ensureNameAttribute($attributeType);
return $attributeType;
}
/**
* Loads the object classes
*
* @return void
*/
protected function _loadObjectClasses()
{
$this->_objectClasses = array();
foreach ($this->getAttribute('objectClasses') as $value) {
$val = $this->_parseObjectClass($value);
$val = new Zend_Ldap_Node_Schema_ObjectClass_OpenLdap($val);
$this->_objectClasses[$val->getName()] = $val;
}
foreach ($this->_objectClasses as $val) {
if (count($val->sup) > 0) {
$this->_resolveInheritance($val, $this->_objectClasses);
}
foreach ($val->aliases as $alias) {
$this->_objectClasses[$alias] = $val;
}
}
ksort($this->_objectClasses, SORT_STRING);
}
/**
* Parses an objectClasses value
*
* @param string $value
* @return array
*/
protected function _parseObjectClass($value)
{
$objectClass = array(
'oid' => null,
'name' => null,
'desc' => null,
'obsolete' => false,
'sup' => array(),
'abstract' => false,
'structural' => false,
'auxiliary' => false,
'must' => array(),
'may' => array(),
'_string' => $value,
'_parents' => array());
$tokens = $this->_tokenizeString($value);
$objectClass['oid'] = array_shift($tokens); // first token is the oid
$this->_parseLdapSchemaSyntax($objectClass, $tokens);
$this->_ensureNameAttribute($objectClass);
return $objectClass;
}
/**
* Resolves inheritance in objectClasses and attributes
*
* @param Zend_Ldap_Node_Schema_Item $node
* @param array $repository
*/
protected function _resolveInheritance(Zend_Ldap_Node_Schema_Item $node, array $repository)
{
$data = $node->getData();
$parents = $data['sup'];
if ($parents === null || !is_array($parents) || count($parents) < 1) return;
foreach ($parents as $parent) {
if (!array_key_exists($parent, $repository)) continue;
if (!array_key_exists('_parents', $data) || !is_array($data['_parents'])) {
$data['_parents'] = array();
}
$data['_parents'][] = $repository[$parent];
}
$node->setData($data);
}
/**
* Loads the LDAP syntaxes
*
* @return void
*/
protected function _loadLdapSyntaxes()
{
$this->_ldapSyntaxes = array();
foreach ($this->getAttribute('ldapSyntaxes') as $value) {
$val = $this->_parseLdapSyntax($value);
$this->_ldapSyntaxes[$val['oid']] = $val;
}
ksort($this->_ldapSyntaxes, SORT_STRING);
}
/**
* Parses an ldapSyntaxes value
*
* @param string $value
* @return array
*/
protected function _parseLdapSyntax($value)
{
$ldapSyntax = array(
'oid' => null,
'desc' => null,
'_string' => $value);
$tokens = $this->_tokenizeString($value);
$ldapSyntax['oid'] = array_shift($tokens); // first token is the oid
$this->_parseLdapSchemaSyntax($ldapSyntax, $tokens);
return $ldapSyntax;
}
/**
* Loads the matching rules
*
* @return void
*/
protected function _loadMatchingRules()
{
$this->_matchingRules = array();
foreach ($this->getAttribute('matchingRules') as $value) {
$val = $this->_parseMatchingRule($value);
$this->_matchingRules[$val['name']] = $val;
}
ksort($this->_matchingRules, SORT_STRING);
}
/**
* Parses an matchingRules value
*
* @param string $value
* @return array
*/
protected function _parseMatchingRule($value)
{
$matchingRule = array(
'oid' => null,
'name' => null,
'desc' => null,
'obsolete' => false,
'syntax' => null,
'_string' => $value);
$tokens = $this->_tokenizeString($value);
$matchingRule['oid'] = array_shift($tokens); // first token is the oid
$this->_parseLdapSchemaSyntax($matchingRule, $tokens);
$this->_ensureNameAttribute($matchingRule);
return $matchingRule;
}
/**
* Loads the matching rule use
*
* @return void
*/
protected function _loadMatchingRuleUse()
{
$this->_matchingRuleUse = array();
foreach ($this->getAttribute('matchingRuleUse') as $value) {
$val = $this->_parseMatchingRuleUse($value);
$this->_matchingRuleUse[$val['name']] = $val;
}
ksort($this->_matchingRuleUse, SORT_STRING);
}
/**
* Parses an matchingRuleUse value
*
* @param string $value
* @return array
*/
protected function _parseMatchingRuleUse($value)
{
$matchingRuleUse = array(
'oid' => null,
'name' => null,
'desc' => null,
'obsolete' => false,
'applies' => array(),
'_string' => $value);
$tokens = $this->_tokenizeString($value);
$matchingRuleUse['oid'] = array_shift($tokens); // first token is the oid
$this->_parseLdapSchemaSyntax($matchingRuleUse, $tokens);
$this->_ensureNameAttribute($matchingRuleUse);
return $matchingRuleUse;
}
/**
* Ensures that a name element is present and that it is single-values.
*
* @param array $data
*/
protected function _ensureNameAttribute(array &$data)
{
if (!array_key_exists('name', $data) || empty($data['name'])) {
// force a name
$data['name'] = $data['oid'];
}
if (is_array($data['name'])) {
// make one name the default and put the other ones into aliases
$aliases = $data['name'];
$data['name'] = array_shift($aliases);
$data['aliases'] = $aliases;
} else {
$data['aliases'] = array();
}
}
/**
* Parse the given tokens into a data structure
*
* @param array $data
* @param array $tokens
* @return void
*/
protected function _parseLdapSchemaSyntax(array &$data, array $tokens)
{
// tokens that have no value associated
$noValue = array('single-value',
'obsolete',
'collective',
'no-user-modification',
'abstract',
'structural',
'auxiliary');
// tokens that can have multiple values
$multiValue = array('must', 'may', 'sup');
while (count($tokens) > 0) {
$token = strtolower(array_shift($tokens));
if (in_array($token, $noValue)) {
$data[$token] = true; // single value token
} else {
$data[$token] = array_shift($tokens);
// this one follows a string or a list if it is multivalued
if ($data[$token] == '(') {
// this creates the list of values and cycles through the tokens
// until the end of the list is reached ')'
$data[$token] = array();
while ($tmp = array_shift($tokens)) {
if ($tmp == ')') break;
if ($tmp != '$') {
$data[$token][] = Zend_Ldap_Attribute::convertFromLdapValue($tmp);
}
}
} else {
$data[$token] = Zend_Ldap_Attribute::convertFromLdapValue($data[$token]);
}
// create a array if the value should be multivalued but was not
if (in_array($token, $multiValue) && !is_array($data[$token])) {
$data[$token] = array($data[$token]);
}
}
}
}
/**
* Tokenizes the given value into an array
*
* @param string $value
* @return array tokens
*/
protected function _tokenizeString($value)
{
$tokens = array();
$matches = array();
// this one is taken from PEAR::Net_LDAP2
$pattern = "/\s* (?:([()]) | ([^'\s()]+) | '((?:[^']+|'[^\s)])*)') \s*/x";
preg_match_all($pattern, $value, $matches);
$cMatches = count($matches[0]);
$cPattern = count($matches);
for ($i = 0; $i < $cMatches; $i++) { // number of tokens (full pattern match)
for ($j = 1; $j < $cPattern; $j++) { // each subpattern
$tok = trim($matches[$j][$i]);
if (!empty($tok)) { // pattern match in this subpattern
$tokens[$i] = $tok; // this is the token
}
}
}
if ($tokens[0] == '(') array_shift($tokens);
if ($tokens[count($tokens) - 1] == ')') array_pop($tokens);
return $tokens;
}
}