コード例 #1
0
 /**
  * Hash an sid, using the current hashing method.
  *
  * This method is intentionally private.
  */
 private function hashSid($sid)
 {
     $algorithm = variable_get('simple_ldap_sso_hashing_algorithm', 'sha');
     return SimpleLdap::hash($sid, $algorithm);
 }
コード例 #2
0
 /**
  * Magic __set() function.
  *
  * @param string $name
  *   The name of the attribute to set.
  * @param mixed $value
  *   The value to assigned to the given attribute.
  */
 public function __set($name, $value)
 {
     $attribute_pass = simple_ldap_user_variable_get('simple_ldap_user_attribute_pass');
     switch ($name) {
         // Read-only values.
         case 'attributes':
         case 'exists':
             break;
         case 'dn':
             if ($this->dn != $value) {
                 try {
                     // Validate the DN format before trying to use it.
                     SimpleLdap::ldap_explode_dn($value);
                     // Save the old DN, so a move operation can be done during save().
                     $this->move = $this->dn;
                     $this->dn = $value;
                 } catch (SimpleLdapException $e) {
                 }
             }
             break;
             // Look up the raw password from the internal reverse hash map. This
             // intentionally falls through to default:.
         // Look up the raw password from the internal reverse hash map. This
         // intentionally falls through to default:.
         case $attribute_pass:
             if (isset(self::$hash[$value[0]])) {
                 $algorithm = simple_ldap_user_variable_get('simple_ldap_user_password_hash');
                 $value = SimpleLdap::hash(self::$hash[$value[0]], $algorithm);
             } else {
                 // A plain text copy of the password is not available. Do not
                 // overwrite the existing value.
                 return;
             }
         default:
             // Make sure $value is an array.
             if (!is_array($value)) {
                 $value = array($value);
             }
             if (!array_key_exists('count', $value)) {
                 $value['count'] = count($value);
             }
             // Make sure $this->attributes[$name] is an array.
             if (!isset($this->attributes[$name])) {
                 $this->attributes[$name] = array();
             }
             // Compare the current value with the given value.
             $diff1 = @array_diff($this->attributes[$name], $value);
             $diff2 = @array_diff($value, $this->attributes[$name]);
             // Don't trigger a write if the only difference is the count field,
             // which may be missing from the $value array.
             unset($diff1['count']);
             unset($diff2['count']);
             // If there are any differences, update the current value.
             if (!empty($diff1) || !empty($diff2)) {
                 $this->attributes[$name] = $value;
                 $this->dirty[$name] = $value;
             }
     }
 }