Forum Discussion
NicoLemarchand
4 years agoRegular Visitor
Getting GID or SID fom Active Directory
Hi, I'm facing a problem I'm not able to solve alone. I analyse usage of a web app thanks to a powerBi dashboard. Currently, as all the logs of my app identifies users with their SID, I shall ...
TrentoTrent
2 years agoFrequent Visitor
Built a custom Power M function that transforms the objectSid binary into it's string representation - Based off of: c# - How to convert SID to String in .net - Stack Overflow
This will work for SIDs as defined in to the best of my knowledge: Security identifiers | Microsoft Learn
(objectSid as binary) =>
let
buffered_binary = Binary.Buffer(objectSid),
binary_length = Binary.Length(buffered_binary),
version = BinaryFormat.Byte(Binary.Range(buffered_binary,0,1)),
number_of_sub_authorities = BinaryFormat.Byte(Binary.Range(buffered_binary,1,1)),
identifier_authority = BinaryFormat.UnsignedInteger64(Binary.Combine({Binary.FromList({0,0}), Binary.Range(buffered_binary,2,6)})),
UnsignedInteger32_le = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger32, ByteOrder.LittleEndian),
result = List.Generate(()=> [x=0, y=if number_of_sub_authorities > 0 then Text.From(UnsignedInteger32_le(Binary.Range(buffered_binary,8,4))) else ""], each [x] < number_of_sub_authorities, each [x = [x]+1, y = Text.From(UnsignedInteger32_le(Binary.Range(buffered_binary,8 + 4*([x]+1),4)))], each [y]),
sub_auth_string = if number_of_sub_authorities > 0 then "-" & Text.Combine(result, "-") else ""
in
"S-" & Text.From(version) & "-" & Text.From(identifier_authority) & sub_auth_string