[英]How can I get the SID of a user having from his/her username when the AD is not available?
I'm trying to get a user SID by using the following function:我正在尝试使用以下 function 获取用户 SID:
return new NTAccount(username).Translate(typeof(SecurityIdentifier)).ToString();
Although this function works almost in all cases, when the machine in which this function runs is isolated from the Active Directory this usually gives me a system exception with the following associated message:尽管此 function 几乎在所有情况下都有效,但当运行此 function 的计算机与 Active Directory 隔离时,这通常会给我一个系统异常,并显示以下相关消息:
The trust relationship between this workstation and the primary domain failed.
Is there a way to bypass this and permit the NTAccount function to work only by looking inside the locally available users?有没有办法绕过这个并允许 NTAccount function 仅通过查看本地可用用户来工作?
Doing some testing, when launching a command with the User associated with the input of the NTAccount, and after having launched the command successfully, the Translate command starts working without it being dependent on the AD.做一些测试,当使用与 NTAccount 的输入相关联的用户启动命令时,并且在成功启动命令后,Translate 命令开始工作,而不依赖于 AD。
I am trying to use that function in a custom credential provider in order to enable a custom 2FA and I need the SID (an unique identifier) to be used for user identification in my backend service.我正在尝试在自定义凭据提供程序中使用该 function 以启用自定义 2FA,并且我需要将 SID(唯一标识符)用于后端服务中的用户标识。
Have a look at registry path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
.查看注册表路径
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
。
There are SID
s of users (including system Accounts too).有用户的
SID
(也包括系统帐户)。
Then look at HKEY_USERS\<SID>\Volatile Environment
path.然后查看
HKEY_USERS\<SID>\Volatile Environment
路径。
Values USERDOMAIN
and USERNAME
wait for you.值
USERDOMAIN
和USERNAME
等着你。
Found here - Getting the Username from the HKEY_USERS values在这里找到 -从 HKEY_USERS 值中获取用户名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.