<tfoot id='MNWFw'></tfoot>

  • <small id='MNWFw'></small><noframes id='MNWFw'>

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

        Active Directory 列出 OU

        Active Directory List OU#39;s(Active Directory 列出 OU)
        <tfoot id='w5gzz'></tfoot>

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

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

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

                    <tbody id='w5gzz'></tbody>
                  本文介绍了Active Directory 列出 OU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前有这个代码,

                          string defaultNamingContext;
                  
                          DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE");
                          defaultNamingContext = rootDSE.Properties["defaultNamingContext"].Value.ToString();
                          rootDSE = new DirectoryEntry("LDAP://" + defaultNamingContext);
                          //DirectoryEntry domain = new DirectoryEntry((string)"LDAP://" + defaultNamingContext);
                  
                          DirectorySearcher ouSearch = new DirectorySearcher(rootDSE,"(objectCategory=Organizational-Unit)", 
                                                   null, SearchScope.Subtree);
                  
                          MessageBox.Show(rootDSE.Path.ToString());
                          try
                          {
                              SearchResultCollection collectedResult = ouSearch.FindAll();
                              foreach (SearchResult temp in collectedResult)
                              {
                                  comboBox1.Items.Add(temp.Properties["name"][0]);
                                  DirectoryEntry ou = temp.GetDirectoryEntry();
                              }
                          }
                  

                  当我使用调试器时,我可以看到 rootDSE.Path 实际上指向正确的位置,在这种情况下 DC=gtp,DC=Local 但目录搜索器没有找到任何结果.有人可以帮忙吗?

                  When i use the debugger i can see that rootDSE.Path is infact pointing to the right place, in this case DC=g-t-p,DC=Local but the directory searcher doesn't find any results. Can anyone help?

                  推荐答案

                  Stephen - 我的错 - 由于某种原因,使用 objectCategory 的搜索不起作用.

                  Stephen - my bad - for some reason, the search using objectCategory doesn't work.

                  即使 objectCategory 显示为 CN=Organizational-Unit,在搜索时,您仍然需要使用与 objectClass 相同的值:

                  Even though the objectCategory is displayed as CN=Organizational-Unit, for searching, you still need to use the same value as for the objectClass:

                  所以尝试使用过滤器 (objectCategory=organizationalUnit) - 这绝对适合我!

                  So try to use the filter (objectCategory=organizationalUnit) - that definitely works for me!

                  更新:为了在搜索结果中获取一些属性(以便在组合框中显示它们),您需要在创建 DirectorySearcher 时包含这些属性:

                  UPDATE: in order to get some properties in your search result (in order to display them in the combo box), you need to include those when you create the DirectorySearcher:

                  DirectorySearcher ouSearch = new DirectorySearcher(rootDSE);
                  ouSearch.Filter = "(objectCategory=Organizational-Unit)";
                  ouSearch.SearchScope = SearchScope.Subtree;
                  
                  ouSearch.PropertiesToLoad.Add("name");
                  // add more properties if you want to ...
                  

                  有了这个,你肯定能够抓住 temp.Properties["name"][0] 并将其粘贴到组合框的项目列表中.

                  With this, you should definitely be able to grab the temp.Properties["name"][0] and stick it into the combobox's list of items.

                  我真的不明白你需要什么线

                  I don't really see what you need the line

                  DirectoryEntry ou = temp.GetDirectoryEntry();
                  

                  获取name属性后.....

                  after grabbing the name property .....

                  这篇关于Active Directory 列出 OU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='eFzOG'></tbody>

                      <tfoot id='eFzOG'></tfoot>

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

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

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