Exemple #1
0
 /**
  * Split an multivalued RDN value into an Array
  *
  * A RDN can contain multiple values, spearated by a plus sign.
  * This function returns each separate ocl=value pair of the RDN part.
  *
  * If no multivalued RDN is detected, a array containing only
  * the original rdn part is returned.
  *
  * For example, the multivalued RDN 'OU=Sales+CN=J. Smith' is exploded to:
  * <kbd>array([0] => 'OU=Sales', [1] => 'CN=J. Smith')</kbd>
  *
  * The method trys to be smart if it encounters unescaped "+" characters, but may fail,
  * so ensure escaped "+"es in attr names and attr values.
  *
  * [BUG] If you use string mode and have a multivalued RDN with unescaped plus characters
  *       and there is a unescaped plus sign at the end of an value followed by an
  *       attribute name containing an unescaped plus, then you will get wrong splitting:
  *         $rdn = 'OU=Sales+C+N=J. Smith';
  *       returns:
  *         array('OU=Sales+C', 'N=J. Smith');
  *       The "C+" is treaten as value of the first pair instead as attr name of the second pair.
  *       To prevent this, escape correctly.
  *
  * @param string $rdn Part of an (multivalued) escaped RDN (eg. ou=foo OR ou=foo+cn=bar)
  *
  * @static
  * @return array Array with the components of the multivalued RDN or Error
  */
 function split_rdn_multival($rdn)
 {
     $rdns = preg_split('/(?<!\\\\)\\+/', $rdn);
     $rdns = Net_LDAP_Util::_correct_dn_splitting($rdns, '+');
     return array_values($rdns);
 }