Convert AAD Security Identifier to ObjectId

Welcome Forums General PowerShell Q&A Convert AAD Security Identifier to ObjectId

Viewing 1 reply thread
  • Author
    Posts
    • #217824
      Participant
      Topics: 1
      Replies: 1
      Points: 17
      Rank: Member

      Hi everyone,

      I’m trying a way to convert an azure active directory Sid into an ObjectId. The graph API contains a field which is called SecurityIdentifier but I don’t understand if there is a function to transform it into ObjectID.
      Thanks a lot for any information relating to my case.

    • #217944
      Participant
      Topics: 1
      Replies: 1
      Points: 17
      Rank: Member

      Hi, I resolved, here the function:
      function Convert-AzureSidToObjectId( $azureSid){
      $byteArray=[System.Byte[]]::CreateInstance([System.Byte],16)
      $place=0
      $blocks=$azureSid.Replace("S-1-12-1-","").Split("-",[System.StringSplitOptions]::RemoveEmptyEntries)
      foreach($i in $blocks){
      [Buffer]::BlockCopy([bitconverter]::GetBytes([int64]::Parse($i)),0,$byteArray,$place,4)
      $place += 4
      }
      [Guid]::new($byteArray)
      }

Viewing 1 reply thread
  • You must be logged in to reply to this topic.