OK, wrapped it up as a UDF. If nobody finds fault with it I'll post it in the UDF section.
code:
break on
$SID = GetSID("WinNT://ff/lligetfa,USER")
? $SID
Get $_
Exit 1
function GetSID($adspath)
;Returns the ASCII Security Identifier (SID) of the ADSI object specified
;
; Requires:
; 1) Windows 2000 or WindowsNT/9x /w ADSI installed
; 2) ADsSecurity.DLL (from the ADSI SDK)
;
; Usage:
; $SID = GetSID("WinNT://@LDOMAIN/@USERID,USER")
dim $rev,$sidobj,$sid,$sac,$x
$GetSID=0
$sidobj=createobject("adssid")
$sidobj.setas(5,$adspath)
$sid=$sidobj.getas(1)
if not $sid
$sidobj=0
return
endif
$Rev=val(substr($sid,1,2))
; Extract the SubAuthority Count (SAC) from the SID
$SAC=val(substr($sid,3,2))
$GetSID="S-"+$Rev+"-"+$SAC
; Convert SID little-endian, just re-reverse the bytes and convert to decimal...
For $X=1 to $SAC
$GetSID=$GetSID+"-"+Val("&"+substr($sid,8*$X+15,2)+substr($sid,8*$X+13,2)+substr($sid,8*$X+11,2)+substr($sid,8*$X+9,2))
Next
$sidobj=0
EndFunction
Note: A revised (corrected version) of this code has been posted to GetSID() - Returns SID and converts it to string format
[ 04 May 2002, 20:23: Message edited by: LLigetfa ]