Convert SID to Username in C#

后端 未结 2 1998
不思量自难忘°
不思量自难忘° 2021-01-14 11:37

In .net, I can create a NTAccount using domain and username, and get it\'s SID.

But I cannot convert the SID back to NTAccount using translate function.

2条回答
  •  遥遥无期
    2021-01-14 11:56

    SecurityIdentifier.Translate() method works only on domain accounts so perhaps your computer not attached to domain. To resolve local SIDs into account name you can use Win32 API function LookupAccountSid() look here for example.

提交回复
热议问题