LdapTools\Security\SID::getShortName PHP Méthode

getShortName() public méthode

Get the SDDL short name for the SID, if it has one. If it does not this will return null.
public getShortName ( ) : string | null
Résultat string | null
    public function getShortName()
    {
        $sid = $this->toString();
        $rid = preg_match('/^S-1-5-21(-\\d+){2,}/', $sid) ? (string) array_slice($this->subAuthorities, -1)[0] : null;
        $domainSid = "S-1-5-21-{domainsid}-{$rid}";
        $shortName = null;
        if (in_array($sid, self::SHORT_NAME)) {
            $shortName = array_search($sid, self::SHORT_NAME);
        } elseif ($rid !== null && in_array($domainSid, self::SHORT_NAME_DOMAIN)) {
            $shortName = array_search($domainSid, self::SHORT_NAME_DOMAIN);
        } elseif ($rid !== null && in_array($domainSid, self::SHORT_NAME_ROOT_DOMAIN)) {
            $shortName = array_search($domainSid, self::SHORT_NAME_ROOT_DOMAIN);
        }
        return $shortName;
    }

Usage Example

 /**
  * Get the SDDL string format that represents this Security Descriptor and everything it contains.
  *
  * @param bool $canonicalize Whether or not to canonicalize the DACL
  * @return string
  */
 public function toSddl($canonicalize = true)
 {
     // These will always be present in the SDDL...
     $sddl = 'O:' . ($this->owner->getShortName() ?: $this->owner) . 'G:' . ($this->group->getShortName() ?: $this->group);
     foreach ([$this->dacl, $this->sacl] as $acl) {
         // It should be omitted if empty or not set...
         if ($acl && count($acl->getAces()) > 0) {
             $sddl .= $acl->getSddlIdentifier() . ':' . $this->getAclSddlFlags($acl);
             $sddl .= $acl instanceof Dacl ? $acl->toSddl($canonicalize) : $acl->toSddl();
         }
     }
     return $sddl;
 }