Determine if user is in AD group for .NET 4.0 application

后端 未结 2 692
不知归路
不知归路 2020-12-14 20:58

I am trying to determine if a user is a member of an Active Directory (AD) group for an internal ASP.NET 4.0 application. The code below throws an \"Attempted to access an

相关标签:
2条回答
  • 2020-12-14 21:16

    Could this bug be your problem?

    I've solved the same problems using this workaround:

               using (DirectoryEntry rootDse = new DirectoryEntry("LDAP://rootdse"))
            {
                var dnsName = rootDse.Properties["dnsHostName"].Value.ToString();
                using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, dnsName)) {}
    
    0 讨论(0)
  • 2020-12-14 21:40

    Same issue here.

    It appears to be a bug in ADSI that was resolved with a hotfix. Windows 7 SP1 and Windows Server 2008 R2 SP1 don't include the fix, so it will need to be manually deployed on your development machines and server environments.

    http://support.microsoft.com/kb/2683913

    0 讨论(0)
提交回复
热议问题