Converting binary sid's to a hex string



I am trying to create a hexstring of a NT4 user account sid which I can in
turn use to query an exchange 55 database. I believe I need to convert a
binary sid to a hex string. ADsSID com object will do this for me however it
is a little slow. Can anybody point me in the right direction to converting
a PySID to a hexstring.
Thx

import win32netcon
import win32net
import win32security
def report():
resume = 0
while 1:
filter = win32netcon.FILTER_NORMAL_ACCOUNT
data, total, resume = win32net.NetUserEnum('nt4pridc1', 20, filter,
resume)
for user in data:
MySid, string, int = win32security.LookupAccountName('nt4pridc1',
user['name'])
sString = win32security.ConvertSidToStringSid(MySid)
print MySid
print sString
if resume ==0:
break

report()
## sString prints = S-1-5-21-357043131-537017027-1947940980-1289
## MySid prints = PySID:S-1-5-21-357043131-537017027-1947940980-1289
## I need this , I believe this is a hex string of the SID
## 010500000000000515000000BB0B4815C33A022074381B7409050000


.



Relevant Pages

  • Re: How to retrieve a SID with vbscript ?
    ... I also have found that NameTranslate can convert from Sid to DN, ... Dim objUser, arrSid, strSidHex, objTrans, strUserDN, strSidDec ... ' Retrieve SID and convert to hex string, ...
    (microsoft.public.scripting.vbscript)
  • Re: Converting binary sids to a hex string
    ... binary sid to a hex string. ... print MySid ...
    (comp.lang.python)
  • ADMT - cant migrate sidhistory
    ... When trying to migrate an nt4 user account including the sid, ... done on the pdc or cannot contact the pdc. ... The account migrates but without sid history. ... The registry entry is in place. ...
    (microsoft.public.win2000.active_directory)
  • Re: Convert objectSID to string
    ... on how to do this properly so it works for any SID and not just on SIDs ... OctetStrToHexStr = OctetStrToHexStr _ ... ' Function to convert Hex string Sid to Decimal string Sid. ... Const BYTES_IN_32BITS = 4 ...
    (microsoft.public.windows.server.active_directory)
  • Re: Convert objectSID to string
    ... Around last september or so I worked with someone on one of the newsgroups on how to do this properly so it works for any SID and not just on SIDs with the assumption they have the same number of subauthorities that a domain SID has. ... OctetStrToHexStr = OctetStrToHexStr _ ... ' Function to convert Hex string Sid to Decimal string Sid. ... Const BYTES_IN_32BITS = 4 ...
    (microsoft.public.windows.server.active_directory)