schema() public method

Returns a schema object
public schema ( string $dn = null ) : Horde_Ldap_Schema
$dn string Subschema entry dn.
return Horde_Ldap_Schema Horde_Ldap_Schema object
Exemplo n.º 1
0
 /**
  * Sets the internal attributes array.
  *
  * This method fetches the values for the attributes from the server.  The
  * attribute syntax will be checked so binary attributes will be returned
  * as binary values.
  *
  * Attributes may be passed directly via the $attributes parameter to setup
  * this entry manually. This overrides attribute fetching from the server.
  *
  * @param array $attributes Attributes to set for this entry.
  */
 protected function _loadAttributes(array $attributes = null)
 {
     /* Fetch attributes from the server. */
     if (is_null($attributes) && is_resource($this->_entry) && is_resource($this->_link)) {
         /* Fetch schema. */
         if ($this->_ldap instanceof Horde_Ldap) {
             try {
                 $schema = $this->_ldap->schema();
             } catch (Horde_Ldap_Exception $e) {
                 $schema = null;
             }
         }
         /* Fetch attributes. */
         $attributes = array();
         for ($attr = @ldap_first_attribute($this->_link, $this->_entry); $attr; $attr = @ldap_next_attribute($this->_link, $this->_entry)) {
             /* Standard function to fetch value. */
             $func = 'ldap_get_values';
             /* Try to get binary values as binary data. */
             if ($schema instanceof Horde_Ldap_Schema && $schema->isBinary($attr)) {
                 $func = 'ldap_get_values_len';
             }
             /* Fetch attribute value (needs error checking?) . */
             $attributes[$attr] = $func($this->_link, $this->_entry, $attr);
         }
     }
     /* Set attribute data directly, if passed. */
     if (is_array($attributes) && count($attributes) > 0) {
         if (isset($attributes['count']) && is_numeric($attributes['count'])) {
             unset($attributes['count']);
         }
         foreach ($attributes as $k => $v) {
             /* Attribute names should not be numeric. */
             if (is_numeric($k)) {
                 continue;
             }
             /* Map generic attribute name to real one. */
             $this->_map[Horde_String::lower($k)] = $k;
             /* Attribute values should be in an array. */
             if (false == is_array($v)) {
                 $v = array($v);
             }
             /* Remove the value count (comes from LDAP server). */
             if (isset($v['count'])) {
                 unset($v['count']);
             }
             $this->_attributes[$k] = $v;
         }
     }
     /* Save a copy for later use. */
     $this->_original = $this->_attributes;
 }
Exemplo n.º 2
0
 /**
  * Returns the syntax of an attribute, if necessary recursively.
  *
  * @param string $att  Attribute name.
  *
  * @return string  Attribute syntax.
  * @throws Turba_Exception
  */
 protected function _getSyntax($att)
 {
     $ldap = new Horde_Ldap($this->_convertParameters($this->_params));
     $schema = $ldap->schema();
     if (!isset($this->_syntaxCache[$att])) {
         $attv = $schema->get('attribute', $att);
         $this->_syntaxCache[$att] = isset($attv['syntax']) ? $attv['syntax'] : $this->_getSyntax($attv['sup'][0]);
     }
     return $this->_syntaxCache[$att];
 }
Exemplo n.º 3
0
 /**
  * Tests retrieval of schema through LDAP object.
  */
 public function testSchema()
 {
     $ldap = new Horde_Ldap(self::$ldapcfg['server']);
     $this->assertInstanceOf('Horde_Ldap_Schema', $ldap->schema());
 }