splitAttributeString() public static method

The split will occur at the first unescaped '=' character.
public static splitAttributeString ( string $attr ) : array
$attr string An attribute-value string.
return array Indexed array: 0=attribute name, 1=attribute value.
Example #1
0
 /**
  * Returns the win32 AD epoch number of days the password may be unchanged.
  *
  * @return integer|boolean  Number of days or false if no limit.
  */
 protected function _getMaxPasswd()
 {
     $dn = Horde_Ldap_Util::explodeDN($this->_params['basedn']);
     $domaindn = array();
     foreach ($dn as $rdn) {
         $attribute = Horde_Ldap_Util::splitAttributeString($rdn);
         if ($attribute[0] == 'DC') {
             $domaindn[] = $rdn;
         }
     }
     $dn = Horde_Ldap_Util::canonicalDN($domaindn);
     $search = $this->_ldap->search($domaindn, 'objectClass=*');
     $entry = $search->shiftEntry();
     try {
         return $entry->getValue('maxPwdAge', 'single');
     } catch (Horde_Ldap_Exception $e) {
         return false;
     }
 }
Example #2
0
 /**
  * Tests attribute splitting ('foo=bar' => array('foo', 'bar'))
  */
 public function testSplitAttributeString()
 {
     $attr_str = 'foo=bar';
     // Properly.
     $expected = array('foo', 'bar');
     $split = Horde_Ldap_Util::splitAttributeString($attr_str);
     $this->assertEquals($expected, $split);
     // Escaped "=".
     $attr_str = "fo\\=o=b\\=ar";
     $expected = array('fo\\=o', 'b\\=ar');
     $split = Horde_Ldap_Util::splitAttributeString($attr_str);
     $this->assertEquals($expected, $split);
     // Escaped "=" and unescaped = later on.
     $attr_str = "fo\\=o=b=ar";
     $expected = array('fo\\=o', 'b=ar');
     $split = Horde_Ldap_Util::splitAttributeString($attr_str);
     $this->assertEquals($expected, $split);
 }