LdapTools\Utilities\LdapUtilities::isValidLdapObjectDn PHP Метод

isValidLdapObjectDn() публичный статический Метод

Given a string, try to determine if it is a valid distinguished name for a LDAP object. This is a somewhat unsophisticated approach. A regex might be a better solution, but would probably be rather difficult to get right.
public static isValidLdapObjectDn ( string $dn ) : boolean
$dn string
Результат boolean
    public static function isValidLdapObjectDn($dn)
    {
        return ($pieces = ldap_explode_dn($dn, 1)) && isset($pieces['count']) && $pieces['count'] > 2;
    }

Usage Example

Пример #1
0
 /**
  * Given a value try to determine how to get its full distinguished name.
  *
  * @param string $value
  * @return string $dn
  * @throws AttributeConverterException
  */
 protected function getDnFromValue($value)
 {
     $options = $this->getOptionsArray();
     $toSelect = isset($options['select']) ? $options['select'] : 'dn';
     if ($value instanceof LdapObject && !$value->has($toSelect)) {
         throw new AttributeConverterException(sprintf('The LdapObject must have a "%s" defined when used in "%s".', $toSelect, $this->getAttribute()));
     } elseif ($value instanceof LdapObject) {
         $value = $value->get($toSelect);
     } elseif (!LdapUtilities::isValidLdapObjectDn($value) && !is_null($this->getLdapConnection())) {
         $value = $this->getAttributeFromLdapQuery($value, $toSelect);
     }
     return $value;
 }
All Usage Examples Of LdapTools\Utilities\LdapUtilities::isValidLdapObjectDn