【发布时间】:2014-12-24 17:14:29
【问题描述】:
我似乎无法找到某个用户是 DeployUsersProduction 组的成员。到目前为止,这是我所拥有的:
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public Modes GetDeployMode()
{
bool isProd = false;
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
if (windowsIdentity == null || windowsIdentity.Groups == null) { return Modes.DUS; }
foreach (IdentityReference identityReference in windowsIdentity.Groups)
{
try
{
var reference = identityReference;
string group = reference.Translate(typeof (NTAccount)).Value.Trim();
if (!String.Equals(group, "DeployUsersProduction", StringComparison.OrdinalIgnoreCase)) { continue; }
isProd = true;
break;
}
catch (Exception ex)
{
// Silent catch due to the [Some or all identity references could not be translated]
// error that sometimes occurs while trying to map an identity.
}
}
return isProd ? Modes.Prod : Modes.DUS;
}
据我所知,我的所有配置、spn、db、perms 等都是正确的。我只有一个用户应该返回 Modes.Prod 而不是。
【问题讨论】:
-
你有没有想过尝试使用
PrincipalContextPrincipal.GetGroups -
嗯 ...当我尝试添加
System.DirectoryServices.AccountManagement时,它甚至无法识别DirectoryServices命名空间。 -
您需要通过使用和右键单击引用来添加引用-->添加...等
-
呃……忘了那部分。在
Principal下面我没有看到GetGroups()方法,只有FindByIdentity() -
您是否查看了我最初评论中的链接..?
标签: c# asp.net wcf silverlight-5.0 windows-security