As you will know, KiXtart does not handle bytes which mean that manipulating binary objects (and/or files) is a bit of a problem.

Specifically I needed to convert a binary SID to it's string value.

To this end, I've created a series of UDFs which will allow the manipulation of byte arrays.

These UDFs require ADO 2.5 - I think that this is ubiquitous for Windows installations now, but if this is not the case then please let me know.

This example displays all groups and user with their associated SID:
Code:
Break ON

$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")

Dim $sDomain,$oDomain,$oGroup,$sGroupPath,$avSID,$aiBinarySID,$i

$sDomain="YOUR_DOMAIN_HERE"
$oDomain=GetObject("WinNT://"+$sDomain)
$oDomain.Filter="group",""
"GROUP SIDS: " ?
For Each $oGroup In $oDomain
$avSID=$oGroup.GetEx("objectSID")
$aiBinarySID=udfBytes2Array($avSID[0])
$oGroup.Name+", SID="+udfSID2String($aiBinarySID) ?
Next

$oDomain.Filter="user",""
"USER SIDS: " ?
For Each $oGroup In $oDomain
$avSID=$oGroup.GetEx("objectSID")
$aiBinarySID=udfBytes2Array($avSID[0])
$oGroup.Name+", SID="+udfSID2String($aiBinarySID) ?
Next

$oDomain=0
$oGroup=0
Exit 0

; Convert a SID in binary format to SDDL format
; Note, I cheat here with the 48 bit authority value.
; It works though ;)
Function udfSID2String($aiSID)
Dim $i,$dAuth

$udfSID2String="S-"+$aiSID[0]+"-"+$aiSID[1]+"-"+$aiSID[8]
For $i = 12 To UBound($aiSID) Step 4
$dAuth=CDbl($aiSid[$i+3])
$dAuth=$dAuth*256+CDbl($aiSid[$i+2])
$dAuth=$dAuth*256+CDbl($aiSid[$i+1])
$dAuth=$dAuth*256+CDbl($aiSid[$i+0])
$udfSID2String=$udfSID2String+"-"+CStr($dAuth)
Next
EndFunction



These are the binary / int conversion routines:
Code:
; Convert an array of bytes to an array of integers

Function udfBytes2Array($abBytes)
Dim $oStream,$adTypeBinary,$adTypeText,$i

$adTypeBinary=1

$oStream=CreateObject("ADODB.Stream")
If @ERROR Exit @ERROR EndIf

$oStream.Type=$adTypeBinary
$oStream.Open

$oStream.Write($abBytes)
$oStream.Position=0

Redim Preserve $udfBytes2Array[$oStream.Size-1]

For $i = 0 To UBound($udfBytes2Array)
$udfBytes2Array[$i]=Asc($oStream.Read(1))
Next

$oStream=0

Exit 0
EndFunction

; Convert an array of integers to an array of bytes
Function udfArray2Bytes($aiBytes,Optional $iBytesToConvert)
Dim $oStream,$adTypeBinary,$adTypeText,$i

$adTypeBinary=1
$adTypeText=2

If Not $iBytesToConvert $iBytesToConvert=UBound($aiBytes)+1 EndIf

$oStream=CreateObject("ADODB.Stream")
If @ERROR Exit @ERROR EndIf

$oStream.Type=$adTypeBinary
$oStream.Open

For $i = 1 To $iBytesToConvert
$oStream.Write(udfIntToByte($aiBytes[$i-1]))
Next

$oStream.Position=0
$oStream.Type=$adTypeBinary
$udfArray2Bytes=$oStream.Read($iBytesToConvert)

Exit 0
EndFunction

; Convert a single integer to a byte array
Function udfIntToByte($i)
Dim $oStream,$adTypeBinary,$adTypeText

$adTypeBinary=1
$adTypeText=2

$oStream=CreateObject("ADODB.Stream")
If @ERROR Exit @ERROR EndIf

$i=CInt($i) & 255

$oStream.Type=$adTypeText
$oStream.CharSet="unicode"
$oStream.Open
$oStream.WriteText(" "+Chr($i))
$oStream.Position=0
$oStream.Type=$adTypeBinary

If $i
$oStream.Position=$oStream.Size-2
Else
$oStream.Position=$oStream.Size-1
EndIf
$udfIntToByte=$oStream.Read(1)
Exit 0

EndFunction