Skip to content

Instantly share code, notes, and snippets.

@yon2004
Last active September 5, 2023 06:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yon2004/997509f3074aed0f282d8161bf4efc58 to your computer and use it in GitHub Desktop.
Save yon2004/997509f3074aed0f282d8161bf4efc58 to your computer and use it in GitHub Desktop.
Convert AD BASE64 SID to SDDL format and back.
#Convert from Base64 to SID
[byte[]]$sid = [System.Convert]::FromBase64String("AQUAAAAAAAUVAAAAuwkCIyAUg1vk+E/VWQQAAA==")
$si = New-Object Security.Principal.SecurityIdentifier($sid,0)
$si.ToString()
#Convert from SID to Base64 (Needed for squid)
$sidconvert = New-Object Security.Principal.SecurityIdentifier("S-1-5-21-587336123-1535317024-3578788068-1112")
$sid_out = New-Object 'byte[]' $sidconvert.BinaryLength
$sidconvert.GetBinaryForm($sid_out,0)
[System.Convert]::ToBase64String($sid_out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment