gpt4 book ai didi

c# - WindowsPrincipal.IsInRole() 未返回预期结果

转载 作者:行者123 更新时间:2023-11-30 18:45:20 25 4
gpt4 key购买 nike

所以这是我当前的代码:

List<string> rowGroups = GetFileGroups((int)row.Cells["document_security_type"].Value);
bool found = false;
System.Security.Principal.WindowsPrincipal p = new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent());

foreach (string group in rowGroups)
{
if (p.IsInRole(group))
{
found = true;
break;
}
}

这是几个月前由某人完成的,我很难理解为什么它不起作用。该公司最近刚刚从一个域名转移到另一个域名。所以我很好奇 p.IsInRole("String") 函数将使用哪个域 Controller 。我假设无论计算机使用什么,它都会使用默认 DC。

奇怪的是,办公室中运行此程序的计算机可能位于 2 个独立的域中。在List<string>对象,我有两个域都可能。因此它可以包含诸如“domainA\groupA”、“domainA\userB”、domainB\groupC 和/或“domainB\userD”之类的项。

所以我的主要问题是 IsInRole 函数永远不会返回 true。我知道应该这样做,我什至对 domainA\Domain 用户进行了测试,但仍然返回错误。

有什么想法吗?更改代码是可能的,但不是想要的。我不是 100% 我什至可以编译它...

最佳答案

我必须指出,你真的在​​你的字符串中正确地转义了你的'\'字符吗?如“domainA\\groupA”?

关于c# - WindowsPrincipal.IsInRole() 未返回预期结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/284500/

25 4 0
文章推荐: c# - GUI 事件记录器和回放
文章推荐: javascript - 父
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com