Converting an SID byte array into an SID string

Hello Decisions,

The Active Directory module provides steps to retrieve data from MS Active Directory servers, including querying an account by its SID. These steps can return the Object SID as a base-64 encoded string or a byte array, but there's no way to convert the Object SID byte array into a SID string. This gap complicates the coordination of local accounts with Active Directory.

Is there a way to convert an SID byte array into a SID string?

Comments

  • Hey,

    Thanks for using the Decisions Community Forum!


    This is something you can absolutely do with the use of the PowerShell Module!

    To accomplish this, first ensure you have the PowerShell module installed correctly, here are the steps to Install the module: https://documentation.decisions.com/v9/docs/installing-modules-decisions#from-the-platform

    Once the module is installed, you'll need to create a PowerShell script step, you can follow this documentations example to set this up, I'll provide you with what to put in the fields next:

    https://documentation.decisions.com/docs/powershell#example

    In the fields, you'll want to input this information:

    ScriptName: An Identifiable name

    Inputs: base64String

    Script: (Don't include the first and last single quote)

    '

    $byteArray = [System.Convert]::FromBase64String($base64String)

    if ($byteArray.Length -lt 28) {

      Return "Error: The byte array length is too short for a valid SID."

    } else {

      $sid = [System.Security.Principal.SecurityIdentifier]::new($byteArray, 0)

      $SIDString = $sid.Value

      Return $SIDString

    }

    '

    Outputs: Leave this blank, and hit Save.


    Once you've created this script, create a flow, and place the script step you just created into it, you can find the step in the toolbox > Integration > Powershell > Name of script folder > Your script step. The step itself will want an input for the base64String, which you can declare as a constant, or feed a value into it.

    This should resolve your conversion.

    Regards,

    Levi | Decisions Support

Sign In or Register to comment.