相关疑难解决方法(0)

查看用户是否是C#+ Asp.net中Active Directory组的一部分

我需要一种方法来查看用户是否是我的.Net 3.5 asp.net c#应用程序中的活动目录组的一部分.

我正在使用msdn的标准ldap身份验证示例,但我真的没有看到如何检查组.

c# asp.net active-directory active-directory-group .net-3.5

46
推荐指数
7
解决办法
8万
查看次数

使用.Net确定用户是否属于特定AD组

使用C#确定用户是否属于特定AD用户组的最佳方法是什么,而不必枚举所有用户的组.可以使用单个LDAP查询或搜索来完成吗?

.net active-directory

14
推荐指数
2
解决办法
4万
查看次数

GroupPrincipal.GetMembers在组(或子组,如果递归)包含ForeignSecurityPrincipal时失败

对于遇到同样问题的人来说,这不是一个问题.

发生以下错误:

System.DirectoryServices.AccountManagement.PrincipalOperationException: An error (87) occurred while enumerating the groups. The group's SID could not be resolved. 
at System.DirectoryServices.AccountManagement.SidList.TranslateSids(String target, IntPtr[] pSids) 
at System.DirectoryServices.AccountManagement.SidList.ctor(List`1 sidListByteFormat, String target, NetCred credentials) 
at System.DirectoryServices.AccountManagement.ADDNLinkedAttrSet.TranslateForeignMembers()
Run Code Online (Sandbox Code Playgroud)

运行以下代码并且组或子组包含ForeignSecurityPrincipal时:

private static void GetUsersFromGroup()
{
    var groupDistinguishedName = "CN=IIS_IUSRS,CN=Builtin,DC=Domain,DC=com";
    //NB: Exception thrown during iteration of members rather than call to GetMembers.    
    using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "Domain", "Username", "Password"))
    {
        using (GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity(ctx, IdentityType.DistinguishedName, groupDistinguishedName))
        {                    
            using (var searchResults = groupPrincipal.GetMembers(true))//Occurs when false also. …
Run Code Online (Sandbox Code Playgroud)

c# directoryservices active-directory

12
推荐指数
1
解决办法
1万
查看次数

递归查询LDAP组成员资格

我正在编写一个基于MVC(.NET 4.0)的网站,该网站需要我公司LDAP服务器的登录凭据.我的代码需要的是仅允许属于某个组的用户.例如,我可能正在寻找属于"企业IT"小组的用户.我的凭据可能是"系统管理员"组的一部分,该组是"企业IT"的子组.我正在使用表单身份验证.

如何以递归方式检查用户登录时所在的组?

c# ldap asp.net-mvc-3

5
推荐指数
3
解决办法
4236
查看次数