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
ppr
(Peter Preuss)
October 13, 2023, 12:03pm
2
gary.cobden:
ObjectSID
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
Anil_G
(Anil Gorthi)
October 13, 2023, 12:22pm
4
@gary.cobden
Try this
Convert.ToBase64String(bytearray)
Cheers
ppr
(Peter Preuss)
October 13, 2023, 12:33pm
6
Assign Activity
strMySID = new System.Security.Principal.SecurityIdentifier(arrSIDBytes , 0).Value
with:
arrSIDBytes is a Byte Array, representing the ObjectSID
Validation Immediate panel:
vs.
ppr
(Peter Preuss)
October 13, 2023, 1:15pm
7
@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
ppr
(Peter Preuss)
October 17, 2023, 1:11pm
11
give a try at
Assign Activity:
arrSIDBytes | DataType: Byte Array - Byte() =
DirectCast(varSid, Byte() )
@ppr
Thank you; thats resolved it
Much appreciated
system
(system)
Closed
October 20, 2023, 1:18pm
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.