【发布时间】:2016-02-10 17:33:44
【问题描述】:
我有一台安装了 AD 的服务器。在此服务器中,我创建了一个用户并将他添加到“域管理员”组。
在 C# 中,我使用了 win32 函数 LogonUser 并使用添加到“域管理员”组的用户进行身份验证。身份验证成功,但是当我使用 WindowsIdentity 和 IdentityReference 检索所有组时,我没有得到“域管理员”Sid。
知道这是为什么吗?
这是我正在使用的代码:
if (LogonUser(username,
domainName,
password,
(int)LogonType.LOGON32_LOGON_INTERACTIVE,
(int)LogonProvider.LOGON32_PROVIDER_DEFAULT,
ref logonToken) != 0)
{
WindowsIdentity wi = new WindowsIdentity(logonToken);
foreach (IdentityReference oneGroup in wi.Groups)
{
GroupList.Add(oneGroup.Value);
}
return err;
}
注意 oneGroup.Value 保存用户所属组的 Sid。
【问题讨论】:
标签: c# active-directory ldap