isValidGuid() public static method

Determine whether a value is in valid GUID format.
public static isValidGuid ( string $value ) : boolean
$value string
return boolean
 /**
  * {@inheritdoc}
  */
 public function getUsername($username)
 {
     if (LdapUtilities::isValidGuid($username)) {
         $username = '******' . $username . '}';
     } elseif (!(LdapUtilities::isValidSid($username) || $this->isValidUserDn($username) || $this->isInUpnForm($username))) {
         $username = parent::getUsername($username);
     }
     return $username;
 }
 /**
  * {@inheritdoc}
  */
 public function toLdap($guid)
 {
     $guid = strtolower($guid) === self::AUTO ? LdapUtilities::uuid4() : $guid;
     if (!LdapUtilities::isValidGuid($guid)) {
         throw new AttributeConverterException(sprintf('The value "%s" is not a valid GUID.', $guid));
     }
     $guid = (new GUID($guid))->toBinary();
     if ($this->getOperationType() == self::TYPE_SEARCH_TO) {
         $guid = implode('', preg_filter('/^/', '\\', str_split(bin2hex($guid), 2)));
     }
     return $guid;
 }
示例#3
0
 /**
  * @param string $guid
  */
 protected function decodeFromBinary($guid)
 {
     $hex = unpack('H*hex', $guid)['hex'];
     $guidStrings = [];
     foreach ($this->guidSections as $section) {
         $guidStrings[] = $this->parseSection($hex, $section);
     }
     $guid = implode('-', $guidStrings);
     if (!LdapUtilities::isValidGuid($guid)) {
         throw new \UnexpectedValueException(sprintf('The GUID with value "%s" is not valid.', $guid));
     }
     $this->guid = $guid;
 }
示例#4
0
 /**
  * @param LdapQueryBuilder $query
  * @param string $value
  * @return bOr
  */
 protected function getQueryOrStatement(LdapQueryBuilder $query, $value)
 {
     $bOr = $query->filter()->bOr();
     $opType = AttributeConverterInterface::TYPE_SEARCH_TO;
     if (LdapUtilities::isValidGuid($value)) {
         $bOr->add($query->filter()->eq('objectGuid', (new ConvertWindowsGuid())->setOperationType($opType)->toLdap($value)));
     } elseif (LdapUtilities::isValidSid($value)) {
         $bOr->add($query->filter()->eq('objectSid', (new ConvertWindowsSid())->setOperationType($opType)->toLdap($value)));
     }
     return $bOr;
 }