我有一个程序可以做到这一点。这是代码的相关部分:
NTAccount ntuser = new NTAccount(strUser);
SecurityIdentifier sID = (SecurityIdentifier) ntuser.Translate(typeof(SecurityIdentifier));
strSID = sID.ToString();
Run Code Online (Sandbox Code Playgroud)
您将需要导入两个命名空间:
using System.DirectoryServices;
using System.Security.Principal;
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。
然后Registry.Users.SetValue与 SID string\path 一起使用来设置注册表值。
如果您正在编辑已注销的配置文件,尤其是漫游配置文件,这可能无法按预期工作。
| 归档时间: |
|
| 查看次数: |
6271 次 |
| 最近记录: |