我从注册表中读取了 SID 列表,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
。
在给定 C# 中的 SID 字符串的情况下,如何解析显示用户名(例如 DOMAIN\user
、BUILT-IN\user
)?
最佳答案
刚在 pinvoke.net 上找到它.
替代托管 API: 在 .Net 2.0 中可用:
using System.Security.Principal;
// convert the user sid to a domain\name
string account = new SecurityIdentifier(stringSid).Translate(typeof(NTAccount)).ToString();
关于c# - 通过 SID 解析显示用户名的最佳方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/380031/