Yohaheho
asked on
Convert SID to HEX
I have a SID that I want to convert to Hex.
I found the following script on the web but it isnt' working.
Set oConvert = CreateObject("ADs.ArrayCon
objSid="S-1-5-21-603733758
strHexSid = oConvert.CvOctetStr2vHexSt
WScript.Echo strhexsid
When I execute the above script I receive error box.
Script: C:\sidtohex.vbs
Line: 3
Char: 1
Error: ActiveX component can't vreate object: 'ADs.ArrayConvert'
Code: 800A01AD
Source: Microsoft VBScript runtime error
If anyone could let me know what I'm doing wrong or if any dlls need to be registered or what ever I need to do I'd appreciate is.
Or if you could tell me how to pull a users SID in an NT4 domain in a Hex format that will work as well.
ASKER
I placed the files in the system32 directory and I registered ADs.dll
I now get the following error.
Script: C:\sidtohex.vbs
Line: 5
Char: 1
Error: Type mismatch
Code: 800A000D
Source: ADs
I now get the following error.
Script: C:\sidtohex.vbs
Line: 5
Char: 1
Error: Type mismatch
Code: 800A000D
Source: ADs
ASKER
Actually if I can pull the SID from an NT4 domain in Binary, Decimal or Hex.
Or convert a SID S-1-5-21-603733758-2039161 187-552280 1-19473 to Binary, Decimal or Hex
That would solve the problem.
Or convert a SID S-1-5-21-603733758-2039161
That would solve the problem.
http://froosh.wordpress.com/2005/10/21/hex-sid-to-decimal-sid-translation/
this was a site i used to convert an old SID to Decimal
this was a site i used to convert an old SID to Decimal
ASKER
Sakuya su,
I found that site but was unable to make heads or tails of it.
If you post the script you used I can place my own SID in it and run it.
Thanks
I found that site but was unable to make heads or tails of it.
If you post the script you used I can place my own SID in it and run it.
Thanks
have you included that ADs.dll to your project in references(library reference)?
If not try to include it through menu Project->References.
If not try to include it through menu Project->References.
ASKER
I should have listed in the beginning that I not a programmer.
I'm not sure what you mean by Project->References.
The above lines of code are all that exist in the .vbs
There is no larger program that this is a piece of.
I registered the ADs.dll from the system32 directory.
All I need is for this to convert the SID to either Binary, Decimal or Hex.
Or pull the SID from an NT4 domain in Binary, Decimal or Hex.
Thanks
I'm not sure what you mean by Project->References.
The above lines of code are all that exist in the .vbs
There is no larger program that this is a piece of.
I registered the ADs.dll from the system32 directory.
All I need is for this to convert the SID to either Binary, Decimal or Hex.
Or pull the SID from an NT4 domain in Binary, Decimal or Hex.
Thanks
yous SID in the xample come out as:
010500000000000515000000FE 3EFC236321 8B79714554 00114C0000
in Hex
If you want please let me know your email and I'll give you the Converter I made, which converts string to Hex, it can be modded to do the otherway round too and maybe to add Endian Format, its from the code I showed oyu in the ealier post
010500000000000515000000FE
in Hex
If you want please let me know your email and I'll give you the Converter I made, which converts string to Hex, it can be modded to do the otherway round too and maybe to add Endian Format, its from the code I showed oyu in the ealier post
ASKER
Sakuya su,
That sounds great. Please email it to:
Yohaheho@yahoo.com
I'm not at work now but will try it tomorrow then award the points.
Thanks
That sounds great. Please email it to:
Yohaheho@yahoo.com
I'm not at work now but will try it tomorrow then award the points.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you want a string value that contains the Hex representation of a SID, or an actual number variable in your VB program? SIDs are quite large in memory, and VB doesn't handle numbers larger than 32 bit signed.
If you just want a string, that's pretty straightforward. Since Sakuya's going to email you a solution, I won't spend time on writing one right now. I only have a function to convert in the other direction handy (from Hex to SDDL). For giggles, I'll post that one:
Function HexStrToSDDL(strSid)
' Function to convert hex Sid to decimal (SDDL) Sid.
Dim arrbytSid, lngTemp, i, j, nSubDWords
Dim nLowIndex, nHighIndex
ReDim arrbytSid(Len(strSid) / 2 - 1)
For j = 0 To UBound(arrbytSid)
arrbytSid(j) = CInt("&H" & Mid(strSid, 2 * j + 1, 2))
Next
' Read revision, authority identifier, and number of subauthority identifier DWORDs
nSubDWords = arrbytSid(1)
lngTemp = arrbytSid(2)
lngTemp = lngTemp * 256 + arrbytSid(3)
lngTemp = lngTemp * 256 + arrbytSid(4)
lngTemp = lngTemp * 256 + arrbytSid(5)
lngTemp = lngTemp * 256 + arrbytSid(6)
lngTemp = lngTemp * 256 + arrbytSid(7)
HexStrToSDDL = "S-" & CStr(arrbytSid(0)) & "-" & CStr(lngTemp)
' Read subauthority values (little-endian DWORDs)
For i = 0 To (nSubDWords - 1)
nLowIndex = (4 * i) + 8
nHighIndex = nLowIndex + 3
If (nHighIndex > UBound(arrbytSid)) Then nHighIndex = UBound(arrbytSid)
lngTemp = 0
For j = nHighIndex To nLowIndex Step -1
lngTemp = lngTemp * 256 + arrbytSid(j)
Next
HexStrToSDDL = HexStrToSDDL & "-" & CStr(lngTemp)
Next
End Function
If you just want a string, that's pretty straightforward. Since Sakuya's going to email you a solution, I won't spend time on writing one right now. I only have a function to convert in the other direction handy (from Hex to SDDL). For giggles, I'll post that one:
Function HexStrToSDDL(strSid)
' Function to convert hex Sid to decimal (SDDL) Sid.
Dim arrbytSid, lngTemp, i, j, nSubDWords
Dim nLowIndex, nHighIndex
ReDim arrbytSid(Len(strSid) / 2 - 1)
For j = 0 To UBound(arrbytSid)
arrbytSid(j) = CInt("&H" & Mid(strSid, 2 * j + 1, 2))
Next
' Read revision, authority identifier, and number of subauthority identifier DWORDs
nSubDWords = arrbytSid(1)
lngTemp = arrbytSid(2)
lngTemp = lngTemp * 256 + arrbytSid(3)
lngTemp = lngTemp * 256 + arrbytSid(4)
lngTemp = lngTemp * 256 + arrbytSid(5)
lngTemp = lngTemp * 256 + arrbytSid(6)
lngTemp = lngTemp * 256 + arrbytSid(7)
HexStrToSDDL = "S-" & CStr(arrbytSid(0)) & "-" & CStr(lngTemp)
' Read subauthority values (little-endian DWORDs)
For i = 0 To (nSubDWords - 1)
nLowIndex = (4 * i) + 8
nHighIndex = nLowIndex + 3
If (nHighIndex > UBound(arrbytSid)) Then nHighIndex = UBound(arrbytSid)
lngTemp = 0
For j = nHighIndex To nLowIndex Step -1
lngTemp = lngTemp * 256 + arrbytSid(j)
Next
HexStrToSDDL = HexStrToSDDL & "-" & CStr(lngTemp)
Next
End Function
ASKER
Sakuya,
Works like a champ.
Thanks a lot
Yohaheho
Works like a champ.
Thanks a lot
Yohaheho
no problem, if you ever want the source code let me know
Sakuya Su,
Could you please send me the source code for the script that will convert a SID to hex format?
Please email it to me at david@txsys.com
Thanks
Could you please send me the source code for the script that will convert a SID to hex format?
Please email it to me at david@txsys.com
Thanks
Sadly I no longer have the original source, it was done overnight and the HDD corrupted about 3 or 4 months ago
SAMPLE: ARRAYCONVERT.EXE Variant Conversion Functions
http://support.microsoft.com/kb/q250344/