I want to convert the user SID to varChar, I have successfully converted a local SQL users SID to varChar, se the code below.
Q: SELECT SUSER_SID('MyUser')
A: 0x15489420B0A30543B2CD88D4EE4E6C37
Q: SELECT SUSER_SNAME(0x15489420B0A30543B2CD88D4EE4E6C37)
A: MyUser
Q: SELECT Convert(varChar, SUSER_SID('MyUser'))
A: H" °£C²ÍˆÔîNl7
Q: SELECT SUSER_SNAME(SUSER_SID('MyUser'))
A: MyUser
Q: SELECT SUSER_SNAME(convert(varBinary, convert(varChar, SUSER_SID('MyUser'))))
A: MyUser
Q: SELECT SUSER_SNAME(convert(varBinary, 'H" °£C²ÍˆÔîNl7'))
A: MyUser
But when I'm using the same code for a NT user I get the following result:
Q: SELECT SUSER_SID('MYDOMAIN\NTUSER')
A: 0x01050000000000051500000092580A58DE26026F7B204646EF030000
Q: SELECT SUSER_SNAME(0x01050000000000051500000092580A58DE26026F7B204646EF030000)
A: MYDOMAIN\NTUSER
Q: SELECT Convert(varChar, SUSER_SID('MYDOMAIN\NTUSER'))
A:
Q: SELECT SUSER_SNAME(SUSER_SID('MYDOMAIN\NTUSER'))
A: MYDOMAIN\NTUSER
Q: SELECT SUSER_SNAME(convert(varBinary, convert(varChar, SUSER_SID('MYDOMAIN\NTUSER'))))
A: MYDOMAIN\NTUSER
Q: SELECT SUSER_SNAME(convert(varBinary, ''))
A: NULL
Why is that?
I have tried with a few different NT Users but with the same result. Why can't I convert a NT Users SID to varChar?
Q: SELECT SUSER_SID('MyUser')
A: 0x15489420B0A30543B2CD88D4EE4E6C37
Q: SELECT SUSER_SNAME(0x15489420B0A30543B2CD88D4EE4E6C37)
A: MyUser
Q: SELECT Convert(varChar, SUSER_SID('MyUser'))
A: H" °£C²ÍˆÔîNl7
Q: SELECT SUSER_SNAME(SUSER_SID('MyUser'))
A: MyUser
Q: SELECT SUSER_SNAME(convert(varBinary, convert(varChar, SUSER_SID('MyUser'))))
A: MyUser
Q: SELECT SUSER_SNAME(convert(varBinary, 'H" °£C²ÍˆÔîNl7'))
A: MyUser
But when I'm using the same code for a NT user I get the following result:
Q: SELECT SUSER_SID('MYDOMAIN\NTUSER')
A: 0x01050000000000051500000092580A58DE26026F7B204646EF030000
Q: SELECT SUSER_SNAME(0x01050000000000051500000092580A58DE26026F7B204646EF030000)
A: MYDOMAIN\NTUSER
Q: SELECT Convert(varChar, SUSER_SID('MYDOMAIN\NTUSER'))
A:
Q: SELECT SUSER_SNAME(SUSER_SID('MYDOMAIN\NTUSER'))
A: MYDOMAIN\NTUSER
Q: SELECT SUSER_SNAME(convert(varBinary, convert(varChar, SUSER_SID('MYDOMAIN\NTUSER'))))
A: MYDOMAIN\NTUSER
Q: SELECT SUSER_SNAME(convert(varBinary, ''))
A: NULL
Why is that?
I have tried with a few different NT Users but with the same result. Why can't I convert a NT Users SID to varChar?