LdapTools\Security\SID::decodeFromBinary PHP Method

decodeFromBinary() protected method

Parse the binary form of a SID into its respective parts that make it up.
protected decodeFromBinary ( string $value )
$value string
    protected function decodeFromBinary($value)
    {
        $sid = @unpack('C1rev/C1count/x2/N1id', $value);
        if (!isset($sid['id']) || !isset($sid['rev'])) {
            throw new \UnexpectedValueException('The revision level or identifier authority was not found when decoding the SID.');
        }
        $this->revisionLevel = $sid['rev'];
        $this->identifierAuthority = $sid['id'];
        $subs = isset($sid['count']) ? $sid['count'] : 0;
        // The sub-authorities depend on the count, so only get as many as the count, regardless of data beyond it
        for ($i = 0; $i < $subs; $i++) {
            $this->subAuthorities[] = unpack('V1sub', hex2bin(substr(bin2hex($value), 16 + $i * 8, 8)))['sub'];
        }
    }