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
## 010500000000000515000000BB0B4815C33A022074381B7409 050000 2 8576
You can use the binascii module to convert the raw
bytes of the sid to hex.
binascii.b2a_hex(buffer(MySid))
Roger
"LittlePython" <Li**********@lost.com> wrote in message news:Y6Ehg.6441$im3.3067@trnddc01... 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 ## 010500000000000515000000BB0B4815C33A022074381B7409 050000
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Thx Roger, I have been off line for a few days. I am sorry not to reply
earlier. I will try this, but I am not sure what "buffer" does ( I am a
newbie to python).
"Roger Upole" <ru****@hotmail.com> wrote in message
news:11*************@sp6iad.superfeed.net... You can use the binascii module to convert the raw bytes of the sid to hex.
binascii.b2a_hex(buffer(MySid))
Roger
"LittlePython" <Li**********@lost.com> wrote in message
news:Y6Ehg.6441$im3.3067@trnddc01...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 ## 010500000000000515000000BB0B4815C33A022074381B7409 050000
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael Satterwhite |
last post by:
OK, I'll admit I've been doing it wrong (using session_register()), so I'm
trying to correct my ways, but...
My script starts with
<?php
session_start();
?>
In the body of my page a link as...
|
by: Mariusz Sakowski |
last post by:
I'm writing class which will be able to store large numbers (my
ambition is to make it able to operand on thousands of bits) and
perform various operations on it (similiar to those available with...
|
by: Marius Cabas |
last post by:
Hi, I'm a beginner so don't shoot ;)
I'm reading a wave file into a byte and I'm trying to convert the result
to String but the converted string is altered, so if I'm generating a new
wave file...
|
by: dlarock |
last post by:
I wrote the following to do an MD5 hash. However, I have a problem (I
think) with the conversion from the Byte MD5 hash back to string.
Watching this through the debugger it appears as if the...
|
by: Mr X |
last post by:
One of my employer's products, written in VB6, reads and writes binary
files. We are shortly going to port to VB.NET (framework version 2.0) and
will need to be able to read and write these binary...
|
by: Gaurav Agarwal |
last post by:
Hi All,
Am looking for a python script that can convert fileformats to txt
format. Am unable to find anything in python. Currently the InfoCon
projects looks pretty good to use, but it is return...
|
by: sypi |
last post by:
Hi,
I'd need to construnct an EXEC statement in my script I am pretty much stuck with data conversion. I need to compare a binary variable with a SID value to an actual SID found in ..sysusers.
...
|
by: VictorG |
last post by:
Hello,
The below C# code works fine in obtaining the windows user's account
SID when the user is local to the machine. It throws a "Not Found"
exception when trying top obtain the SID for a...
|
by: abhishekbrave |
last post by:
I hava xml code in following format. My aim is to convert this show the data present here in tabular format to a HTML page.
<table bid="18" sid="7" ref="REF_17" x="0" y="80" h="50" w="607"...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |