Avatar of Pollin
 asked on

SID convert to string

Does anybody knows how to convert a SID from byte to the string format   S-1-55-11..... ????

I am using

Dim userEntry As New System.DirectoryServices.DirectoryEntry(user1)

to retrieve the SID from AD but it is in byte type. I need to show it in a text box and compare it with another SID.

I tried to use

                Dim enc As New System.Text.ASCIIEncoding

but it show unreadable data and I need the format S-1-5-11

Thanks in advance
Visual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon

Have you tried

    Dim s As String = System.Text.Encoding.Default.GetString(userEntry.Properties("objectSid").Value)

(From:  https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21061244.html)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Hello ZeonFlash:

Thanks for your comment.
I tried with that funtion but it shows unreadable data, the same as the one I was using:

                Dim enc As New System.Text.ASCIIEncoding

it looks that there are characters with values higher than 127 than cannot be decoded.

Thnks anyway

Hello oleggold

Thanks a lot, these articles are the ones I was looking for.

You are a star!!!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy