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

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

      <tfoot id='se7gL'></tfoot>
        <bdo id='se7gL'></bdo><ul id='se7gL'></ul>

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

        递归查询 LDAP 组成员资格

        Recursively querying LDAP group membership(递归查询 LDAP 组成员资格)

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

            <tbody id='EWkuH'></tbody>
          <tfoot id='EWkuH'></tfoot>
            • <bdo id='EWkuH'></bdo><ul id='EWkuH'></ul>

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

                  问题描述

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

                  I'm writing an MVC-based (.NET 4.0) website that requires login credentials from my corporate LDAP server. What my code requires is to allow only the users that are part of a certain group. As an example, I could be looking for users that are part of the "Corporate IT" group. My credentials could be part of the "System Admins" group which is a subgroup of "Corporate IT". I'm using Forms Authentication.

                  当用户登录时,我将如何递归检查用户属于哪个组?

                  How would I recursively check what group a user is under when they log in?

                  推荐答案

                  对于通过搜索此类查询来到这里的其他人,这是我在我的应用程序中的做法:

                  For anybody else coming here from a search for this type of query, here is how I did it in my application:

                  关键是 1.2.840.113556.1.4.1941 扩展搜索过滤器.由于此特定过滤器仅适用于 DN,因此我首先获取要检查的用户的 DN,然后查询组以查看此特定用户是否是链中任何组的成员.

                  The key is 1.2.840.113556.1.4.1941 extended search filter. Since this particular filter works with DNs only, I first get hold of DN of the user I want to check and then query groups to see if this particular user is a member of any of groups in chain.

                  internal const string UserNameSearchFilter = "(&(objectCategory=user)(objectClass=user)(|(userPrincipalName={0})(samAccountName={0})))";
                  internal const string MembershipFilter = "(&(objectCategory=group)(objectClass=group)(cn=MyGroup)(member:1.2.840.113556.1.4.1941:={0}))";
                  
                  using (var de = new DirectoryEntry(AppSettings.LDAPRootContainer, AppSettings.AdminUser, AppSettings.AdminPassword, AuthenticationTypes.FastBind))
                  using (var ds = new DirectorySearcher(de) { Filter = string.Format(UserNameSearchFilter, username) })
                  {
                  
                      ds.PropertiesToLoad.AddRange(new[] { "distinguishedName" });
                  
                      var user = ds.FindOne();
                  
                      if (user != null)
                          using (var gds = new DirectorySearcher(de) { PropertyNamesOnly = true, Filter = string.Format(MembershipFilter, user.Properties["distinguishedName"][0] as string) })
                          {
                               gds.PropertiesToLoad.AddRange(new[] { "objectGuid" });
                               return gds.FindOne() != null;
                          }
                  }
                  

                  这篇关于递归查询 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 是否相等(按值,而不是按引用)?)
                      <tbody id='rrsG7'></tbody>

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

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

                          <legend id='rrsG7'><style id='rrsG7'><dir id='rrsG7'><q id='rrsG7'></q></dir></style></legend><tfoot id='rrsG7'></tfoot>