Conversion of Byte 28 Array to base64 (I think)

Hi Colleagues

I am using Active Directory Activities and need to extract the ObjectSID.
This is returned as a Byte[28] Array

I need to be able to view this in the standard SID format
eg - S-1-5-21-1234536710-1234581617-1234551691-12345

Anybody able to assist please

Can you try:

arrSIDBytes is a Byte Array, representing the ObjectSID

new System.Security.Principal.SecurityIdentifier(arrSIDBytes, 0);

@ppr

Sorry, not sure how to use this
How do I assign it to a variable

thx

@gary.cobden

Try this

Convert.ToBase64String(bytearray)

Cheers

Assign Activity
strMySID = new System.Security.Principal.SecurityIdentifier(arrSIDBytes , 0).Value
with:

arrSIDBytes is a Byte Array, representing the ObjectSID

Validation Immediate panel:


vs.
grafik

@gary.cobden
We assume that the case is cleared as we also validated the suggestion within the immediate panel. So lets close the topic by:

Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

@gary.cobden

To convert a Byte[28] array, which represents an ObjectSID, into the standard SID format, you can use the following one-liner in UiPath

Replace myByteArray with your actual Byte[28] array. This one-liner will convert the ObjectSID into the standard SID format.

New System.Security.Principal.SecurityIdentifier(myByteArray, 0).Value

cheers…!

1 Like

Hii @gary.cobden

using System.Security.Principal;

Replace byteData with your actual Byte[28] array
byte byteData = new byte[28]; // Replace with your actual data

SecurityIdentifier sid = new SecurityIdentifier(byteData, 0);
string sidString = sid.Value;

// The sidString now contains the SID in the standard format

Cheers…!

@ppr
Alas, despite your obvious solution, I have not been able to resolve in my project.
Please see attached image from my Project. varSID is Type Object and is returned from the Get Object Properties.
If I could conver this to a Byte Array I could probably resolve as per your solution

Thx

give a try at

Assign Activity:

arrSIDBytes | DataType: Byte Array - Byte() =
DirectCast(varSid, Byte() )

@ppr
Thank you; thats resolved it
Much appreciated

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.