<i id='XVCrg'><tr id='XVCrg'><dt id='XVCrg'><q id='XVCrg'><span id='XVCrg'><b id='XVCrg'><form id='XVCrg'><ins id='XVCrg'></ins><ul id='XVCrg'></ul><sub id='XVCrg'></sub></form><legend id='XVCrg'></legend><bdo id='XVCrg'><pre id='XVCrg'><center id='XVCrg'></center></pre></bdo></b><th id='XVCrg'></th></span></q></dt></tr></i><div id='XVCrg'><tfoot id='XVCrg'></tfoot><dl id='XVCrg'><fieldset id='XVCrg'></fieldset></dl></div>

        <bdo id='XVCrg'></bdo><ul id='XVCrg'></ul>

      <legend id='XVCrg'><style id='XVCrg'><dir id='XVCrg'><q id='XVCrg'></q></dir></style></legend>

      <small id='XVCrg'></small><noframes id='XVCrg'>

      1. <tfoot id='XVCrg'></tfoot>

        C# ActiveDirectory LDAP 组查询

        C# ActiveDirectory LDAP Group Querying(C# ActiveDirectory LDAP 组查询)
          <tbody id='ulTU4'></tbody>
      2. <legend id='ulTU4'><style id='ulTU4'><dir id='ulTU4'><q id='ulTU4'></q></dir></style></legend>

        <small id='ulTU4'></small><noframes id='ulTU4'>

            • <bdo id='ulTU4'></bdo><ul id='ulTU4'></ul>

                <i id='ulTU4'><tr id='ulTU4'><dt id='ulTU4'><q id='ulTU4'><span id='ulTU4'><b id='ulTU4'><form id='ulTU4'><ins id='ulTU4'></ins><ul id='ulTU4'></ul><sub id='ulTU4'></sub></form><legend id='ulTU4'></legend><bdo id='ulTU4'><pre id='ulTU4'><center id='ulTU4'></center></pre></bdo></b><th id='ulTU4'></th></span></q></dt></tr></i><div id='ulTU4'><tfoot id='ulTU4'></tfoot><dl id='ulTU4'><fieldset id='ulTU4'></fieldset></dl></div>
                  <tfoot id='ulTU4'></tfoot>
                  本文介绍了C# ActiveDirectory LDAP 组查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  基本上我想要做的是,我有一个 ASP.Net Web 应用程序,它使用表单身份验证和一些自定义代码将其链接到 ActiveDirectory(非常类似于 这 有效).

                  Basically what I'm trying to do is, I have an ASP.Net web application that's using Forms Authentication with some custom code to link it to ActiveDirectory (very similar to how this works).

                  但是,每当我在域控制器中查询用户组时,它只返回他们明确所在的组,而不是子组(id est,有一个用户所属的特定安全组,比如组 A,即我想要的组的成员,比如组 B,用户显式在组 A 中,但仅隐式在组 B 中,因为组 A 是组 B 的成员.

                  However, whenever I query the domain controller for the users groups it only returns the groups that they're explicitly in and not subgroups (id est, there's a specific Security Group that the user belongs to, say group A, that is a member of the group I want, say group B, the user is explicitly in group A, but only implicitly in group B because group A is a member of group B).

                  我已阅读 tokenGroups 查询可以帮助我,但目前我没有办法解析该数据.

                  I've read the tokenGroups querying could help me out here but currently I don't have a way to parse that data.

                  但是,如果我可以通过 LDAP 查询传递某些组,并且如果该用户是否在该组中,域控制器只给我一个布尔值(真/假),那么最可取的是.

                  However what would be most preferable is if I could pass certain groups via an LDAP query and have the Domain controller just give me a boolean (true/false) if that user is within that group or not.

                  有什么建议吗?

                  推荐答案

                  是的,通常"的 user.Properties["memberOf"] 只返回直接成员资格.

                  Yes, the "usual" user.Properties["memberOf"] only returns direct memberships.

                  如果您使用的是 .NET 3.5,则可以使用更现代的基于主体"的方法:

                  If you're using .NET 3.5 however, you can use the more modern "principal-based" methods:

                  using(PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
                  {
                      using(Principal p = Principal.FindByIdentity(ctx, "yourUserName"))
                      {
                          var groups = p.GetGroups();
                  
                          using (groups)
                          {
                              foreach (Principal group in groups)
                              {
                                  Console.WriteLine(group.SamAccountName + "-" + group.DisplayName);
                              }
                          }
                      }
                  }
                  

                  此方法(向您的项目添加对System.DirectoryServices.AccountManagement"程序集的引用)应该可以工作,并且还可以提供用户的主要组及其嵌套组成员身份.

                  This method (add a reference to the "System.DirectoryServices.AccountManagement" assembly to your project) should work and deliver the user's primary group and its nested group memberships as well.

                  如果您使用的是 .NET 2.0/3.0 并且无法升级,则通过阅读tokenGroups"属性来使用该方法是最好的方法 - 请参阅 Ryan Dunn 的优秀博客中有关如何执行所有这些操作的详细信息发布,枚举 .NET 中的令牌组 (tokenGroups).

                  If you're on .NET 2.0/3.0 and can't move up, using the approach by reading the "tokenGroups" attribute is the best approach - see the details about how to do all of this in Ryan Dunn's excellent blog post, Enumerating Token Groups (tokenGroups) in .NET.

                  马克

                  这篇关于C# ActiveDirectory LDAP 组查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
                • <small id='qlPD6'></small><noframes id='qlPD6'>

                  • <bdo id='qlPD6'></bdo><ul id='qlPD6'></ul>
                      <tbody id='qlPD6'></tbody>
                  • <tfoot id='qlPD6'></tfoot>
                        <legend id='qlPD6'><style id='qlPD6'><dir id='qlPD6'><q id='qlPD6'></q></dir></style></legend>

                            <i id='qlPD6'><tr id='qlPD6'><dt id='qlPD6'><q id='qlPD6'><span id='qlPD6'><b id='qlPD6'><form id='qlPD6'><ins id='qlPD6'></ins><ul id='qlPD6'></ul><sub id='qlPD6'></sub></form><legend id='qlPD6'></legend><bdo id='qlPD6'><pre id='qlPD6'><center id='qlPD6'></center></pre></bdo></b><th id='qlPD6'></th></span></q></dt></tr></i><div id='qlPD6'><tfoot id='qlPD6'></tfoot><dl id='qlPD6'><fieldset id='qlPD6'></fieldset></dl></div>