scripting@wanadoo.nl




StrSidToHexSid()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
15 June 2002 StrSidToHexSid()
AuthorHoward A. Bullock
Action Converts a Sid in string (S-1-5-21-...) format to Hex format.
SyntaxStrSidToHexSid ($StringSid) 
Parameters
  • $StringSid (Required / String) Valid sid in S-1-... format. Example: S-1-5-21-24139212-1035816195-1541859470-1401 
  • RemarksThis function converts sid formats. 
    ReturnsString of the sid converted to Hex format.
    Example: 010500000000000515000000CC557001034DBD3D8EE8E65B79050000 
    DependenciesPadStr() 
    Examples
    StrSidToHexSid("S-1-5-21-24139212-1035816195-1541859470-1401")
    
     
    Source
    FUNCTION StrSidToHexSid ($stringsid)
       DIM $i, $j, $parts, $sac, $sid, $x
       $sid = ""
       IF (Left($stringsid,4) = "S-1-")
          $parts = Split($stringsid, "-")
          $sid = $sid + padstr(DecToHex($parts[1]),0,2)  ;Authority
          $sac = UBound($parts) - 2                      ;Sub-Authority Count
          $sid = $sid + padstr($sac,0,2)
          $sid = $sid + padstr(DecToHex($parts[2]),0,12) ;Identifier-Authority (48 bits)
          FOR $i = 1 TO $sac                             ;Sub-Authorities
             $x = padstr(DecToHex($parts[$i+2]),0,8)
             FOR $j = 7 TO 1 STEP -2
                $sid = $sid + Substr($x,$j,2)
             NEXT
          NEXT
       ELSE
          ? "StrSidToHexSid - Invalid input"
          EXIT 1
       ENDIF
       $strsidtohexsid = $sid
       EXIT 0
    ENDFUNCTION ; - StrSidToHexSid -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter