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

Determine whether a value is in SID format.
public static isValidSid ( string $value ) : boolean
$value string
Результат boolean
Пример #1
0
 /**
  * {@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;
 }
Пример #2
0
 /**
  * @param string $sid The SID in string, short name, or binary form.
  */
 public function __construct($sid)
 {
     if (LdapUtilities::isValidSid($sid)) {
         $this->decodeFromString($sid);
     } elseif (array_key_exists(strtoupper($sid), self::SHORT_NAME)) {
         $this->decodeFromString(self::SHORT_NAME[strtoupper($sid)]);
     } else {
         $this->decodeFromBinary($sid);
     }
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function toLdap($sid)
 {
     if (!LdapUtilities::isValidSid($sid)) {
         throw new AttributeConverterException(sprintf('Expected a string SID but got "%s".', $sid));
     }
     $sid = (new SID($sid))->toBinary();
     if ($this->getOperationType() == self::TYPE_SEARCH_TO) {
         // All hex parts must have a leading backslash for the search.
         $sid = '\\' . implode('\\', str_split(bin2hex($sid), '2'));
     }
     return $sid;
 }
Пример #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;
 }
Пример #5
0
 /**
  * @param string $sid
  * @param string $type
  * @return SID
  * @throws SddlParserException
  */
 protected function getSid($sid, $type)
 {
     $sid = strtoupper($sid);
     // This is a SID short name, or explicit SID, that requires no domain SID lookup...
     if (array_key_exists($sid, SID::SHORT_NAME) || LdapUtilities::isValidSid($sid)) {
         $sid = new SID($sid);
         // This is a SID that requires a domain SID or root domain SID lookup...
     } elseif (array_key_exists($sid, SID::SHORT_NAME_DOMAIN) || array_key_exists($sid, SID::SHORT_NAME_ROOT_DOMAIN)) {
         $sid = $this->getWellKnownDomainSid($sid, array_key_exists($sid, SID::SHORT_NAME_ROOT_DOMAIN));
     } else {
         throw new SddlParserException(sprintf('The value "%s" is not a valid SID for the %s.', $sid, $type));
     }
     return $sid;
 }