Zend_Ldap_Attribute::getAttribute PHP Method

getAttribute() public static method

Gets a LDAP attribute.
public static getAttribute ( array $data, string $attribName, integer $index = null ) : array | mixed
$data array
$attribName string
$index integer
return array | mixed
    public static function getAttribute(array $data, $attribName, $index = null)
    {
        $attribName = strtolower($attribName);
        if ($index === null) {
            if (!isset($data[$attribName])) {
                return array();
            }
            $retArray = array();
            foreach ($data[$attribName] as $v) {
                $retArray[] = self::_valueFromLdap($v);
            }
            return $retArray;
        } else {
            if (is_int($index)) {
                if (!isset($data[$attribName])) {
                    return null;
                } else {
                    if ($index >= 0 && $index < count($data[$attribName])) {
                        return self::_valueFromLdap($data[$attribName][$index]);
                    } else {
                        return null;
                    }
                }
            }
        }
        return null;
    }

Usage Example

Exemplo n.º 1
0
 public function testPasswordSettingCustomAttribute()
 {
     $data = array();
     Zend_Ldap_Attribute::setPassword($data, 'pa$$w0rd', Zend_Ldap_Attribute::PASSWORD_HASH_SHA, 'myAttribute');
     $password = Zend_Ldap_Attribute::getAttribute($data, 'myAttribute', 0);
     $this->assertNotNull($password);
 }
All Usage Examples Of Zend_Ldap_Attribute::getAttribute