1. <legend id='WfCLH'><style id='WfCLH'><dir id='WfCLH'><q id='WfCLH'></q></dir></style></legend>

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

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

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

        使用 OU 的部分路径在 Active Directory 中搜索 OU

        时间:2023-10-24
        <legend id='FtsPe'><style id='FtsPe'><dir id='FtsPe'><q id='FtsPe'></q></dir></style></legend>
        1. <i id='FtsPe'><tr id='FtsPe'><dt id='FtsPe'><q id='FtsPe'><span id='FtsPe'><b id='FtsPe'><form id='FtsPe'><ins id='FtsPe'></ins><ul id='FtsPe'></ul><sub id='FtsPe'></sub></form><legend id='FtsPe'></legend><bdo id='FtsPe'><pre id='FtsPe'><center id='FtsPe'></center></pre></bdo></b><th id='FtsPe'></th></span></q></dt></tr></i><div id='FtsPe'><tfoot id='FtsPe'></tfoot><dl id='FtsPe'><fieldset id='FtsPe'></fieldset></dl></div>

        2. <tfoot id='FtsPe'></tfoot>
            <bdo id='FtsPe'></bdo><ul id='FtsPe'></ul>

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

                  <tbody id='FtsPe'></tbody>
                • 本文介绍了使用 OU 的部分路径在 Active Directory 中搜索 OU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 AD Query 语法中有没有办法通过搜索其部分路径来找到 OU 的完整路径?

                  Is there a way in AD Query syntax, to find an OU's full path by searching on its partial path?

                  例如,我的 OU 的完整路径是:

                  For example, the full path to my OU is:

                  OU=Clerks,OU=OfficeA,OU=Administration,DC=domain,DC=local
                  

                  现在,我想尝试使用部分路径搜索并找到该对象:

                  Now, I'd like to try and search and find that object by using the partial path:

                  OU=Clerks,OU=OfficeA
                  

                  我希望能够搜索以下内容:

                  I'd like to be able to search something like:

                  (&(objectCategory=organizationalUnit)(path=Clerks/OfficeA*))
                  

                  我找不到任何有关如何完成此类操作的语法示例.我正在开发的程序要求我获得许多 OU 的路径,这些 OU 在最后两级 OU 中都有一个共同的结构,但是它们可以嵌套在域中的任何给定深度.如果我可以像这样搜索,那么只需通过最后两个 OU 嵌套级别搜索即可轻松获得完整路径.

                  I can't find any syntax examples of how to accomplish something like this. A program I'm developing requires that I get the paths to a lot of OU's which all have a common structure in the last two levels of OU's, however they can be nested at any given depth in the domain otherwise. If I can search somehow like this, it would be easy to get the full path just searching by the last two OU nested levels.

                  推荐答案

                  您想要做的事情存在于纯 LDAP 实现中,它是一个名为 ExtensibleMatch 的功能,似乎在 这篇维基文章.您还可以在这里找到一些有用的例子.

                  The thing you want to do exists on pure LDAP implementation it's a feature called ExtensibleMatch wich seems to be correctly explained in this wiki article . You will also found something helpfull examples here.

                  但它不存在于 Active-Directory 中

                  But it's not present in Active-Directory

                  所以这是一个用 C# 编写的方法,它利用 DirectoryEntryParent 属性.

                  So here is a method writen in C# that exploit the Parent propertie of a DirectoryEntry.

                     static List<DirectoryEntry> OuInTheFormOf(DirectoryEntry deBase, string ou1, string ou2)
                      {
                        List<DirectoryEntry> deList = null;
                  
                        /* Directory Search
                         */
                        DirectorySearcher dsLookFor = new DirectorySearcher(deBase);
                        dsLookFor.Filter = ou1;
                        dsLookFor.SearchScope = SearchScope.Subtree;
                        dsLookFor.PropertiesToLoad.Add("ou");
                  
                        SearchResultCollection srcOUs = dsLookFor.FindAll();
                  
                        if (srcOUs.Count != 0)
                        {
                          deList = new List<DirectoryEntry>();
                  
                          foreach (SearchResult srOU in srcOUs)
                          {
                            DirectoryEntry deOU = srOU.GetDirectoryEntry();
                            if (deOU.Parent.Name.ToUpper() == ou2.ToUpper())
                              deList.Add(deOU);
                          }
                        }
                        return deList;
                      }
                  

                  这里是用法:

                    /* Connection to Active Directory
                     */
                    DirectoryEntry deBase = new DirectoryEntry("LDAP://WM2008R2ENT:389/dc=dom,dc=fr");
                  
                    List<DirectoryEntry> l = OuInTheFormOf(deBase, "ou=Clerks", "ou=OfficeA");
                  
                    foreach (DirectoryEntry deTmp in l)
                    {
                      Console.WriteLine(deTmp.Properties["distinguishedName"].Value);
                    }
                  

                  这篇关于使用 OU 的部分路径在 Active Directory 中搜索 OU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:服务定位协议的示例客户端实现? 下一篇:如何在 ASP.NET 样板中使用 LDAP(免费启动模板)

                  相关文章

                    • <bdo id='sgaFQ'></bdo><ul id='sgaFQ'></ul>
                  1. <tfoot id='sgaFQ'></tfoot>

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

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

                    1. <legend id='sgaFQ'><style id='sgaFQ'><dir id='sgaFQ'><q id='sgaFQ'></q></dir></style></legend>