/**
  * The hashed sid, as stored on LDAP.
  *
  * @var string
  */
 private function getHashedSid()
 {
     if (!isset($this->server) || !$this->server instanceof SimpleLdapServer) {
         throw new Exception(t('Unable to get hashed SID. LDAP server does not exist.'));
     }
     if (!isset($this->hashedSid)) {
         // Search for this attribute.
         $result = $this->server->search($this->dn, 'objectclass=*', 'base', array($this->getSidAttribute()));
         // Clean up the result.
         $clean = SimpleLdap::clean($result);
         // Only set the value if we actually got a result.
         if (isset($clean[$this->dn][$this->getSidAttribute()][0])) {
             $this->hashedSid = $clean[$this->dn][$this->getSidAttribute()][0];
         }
     }
     return $this->hashedSid;
 }
 /**
  * Loads the server's rootDSE.
  *
  * @throw SimpleLdapException
  */
 protected function rootdse()
 {
     if (!is_array($this->rootdse)) {
         $attributes = array('vendorName', 'vendorVersion', 'namingContexts', 'altServer', 'supportedExtension', 'supportedControl', 'supportedSASLMechanisms', 'supportedLDAPVersion', 'subschemaSubentry', 'objectClass', 'rootDomainNamingContext');
         $result = SimpleLdap::clean($this->search('', 'objectclass=*', 'base', $attributes));
         $this->rootdse = $result[''];
     }
 }
 /**
  * Load the schema.
  *
  * Schema parsing can be slow, so only the attributes that are specified, and
  * are not already cached, are loaded.
  *
  * @param array $attributes
  *   A list of attributes to load. If not specified, all attributes are
  *   loaded.
  *
  * @throw SimpleLdapException
  */
 protected function load($attributes = NULL)
 {
     // If no attributes are specified, default to all attributes.
     if ($attributes === NULL) {
         $attributes = $this->attributes;
     }
     // Make sure $attributes is an array.
     if (!is_array($attributes)) {
         $attributes = array($attributes);
     }
     // Determine which attributes need to be loaded.
     $load = array();
     foreach ($attributes as $attribute) {
         $attribute = drupal_strtolower($attribute);
         if (!isset($this->schema[$attribute])) {
             $load[] = $attribute;
         }
     }
     // Load the attributes.
     if (!empty($load)) {
         $result = SimpleLdap::clean($this->server->search($this->dn, 'objectclass=*', 'base', $load));
         // Parse the schema.
         foreach ($load as $attribute) {
             $attribute = drupal_strtolower($attribute);
             $this->schema[$attribute] = array();
             // Get the values for each attribute.
             if (isset($result[$this->dn][$attribute])) {
                 foreach ($result[$this->dn][$attribute] as $value) {
                     $parsed = $this->parse($value);
                     $this->schema[$attribute][drupal_strtolower($parsed['name'])] = $parsed;
                 }
             }
         }
     }
 }