If you’re interested. I ran into a different form of SID value it is a hex version. $ ad -u "Domain Users" UID: Domain Users SID: S-1-5-21-2385084637-1531931085-3623800711-513 S-1-5-15-8e2980dd-5b4f69cd-d7fecf87-201 GUID: a83ac89b-0e81-544a-8c6e-2cd07ef638aa Type: group In the above the first form is typically what I see however the second form is what I found from tools that I ran into for an EMC. So I added support to your python SID module. Feel free to include or ignore. Supporting this additional form was useful for me. $ diff ~/tools/ver/ad-0.0.1/bin/sid.py sid.py 11c11 < SID_HEX = 3 --- > 40,42d39 < elif sidtype == SID_HEX: < self._sid = self.hexStrsid(data) < return 50,53d46 < def hex(self): < '''Return hex version of sid''' < return self.bytehex(self._sid) < 152,168d144 < def bytehex(cls, strsid): < ''' < Encode a sid into hex form < strsid - SID to encode < ''' < tmp = cls.byte(strsid) < ret = 'S' < sid = [] < sid.append("%x" % cls.byteToLong(tmp[0:1])) < sid.append("%x" % cls.byteToLong(tmp[2:2+6], False)) < for i in range(8, len(tmp), 4): < sid.append("%x" % cls.byteToLong(tmp[i:i+4])) < for i in sid: < ret += '-' + str(i) < return ret < < @classmethod 183,198d158 < < @classmethod < def hexStrsid(cls, hexsid): < ''' < Decode a hex SID into string < hexsid - hex encoded sid < ''' < ret = 'S' < fields = hexsid.split("-") < fields = fields[1:] < sid = [] < for i in fields: < sid.append(int(i,16)) < for i in sid: < ret += '-' + str(i) < return ret [sid.py.txt](https://github.com/sspreitzer/python-sid/files/3759072/sid.py.txt)
Activity
sspreitzer commentedon Aug 11, 2020
Thanks for your work! Would you be open to open a Pull Request here?