locked
Limit Active Directory search results RRS feed

  • Question

  • I have some code that builds a treeview and replicates our AD structure - this runs fine.

    One issue i found is when searching through the DirectoryEntries it lists all items where i would like to limit them to Organisational Units only. I thought or using the DirectorySearcher but it seems that i would have two operations running at the same time probably doing the same thing but returning slightly different results just to limit to show what i need. Is there a way to tie DirectoryEntries/Entry with a DirectorySeracher to limit results to Organisation Units or is there a way to do this another way and still have it displayed under a treeview?

    Thanks

    Wednesday, February 2, 2011 8:44 AM

Answers

  • From what I can tell it looks like the objectClass attribute is 'organizationalUnit', so if you add that to your search filter you should only come back with OUs.
    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Mike Feng Friday, February 11, 2011 6:35 AM
    Monday, February 7, 2011 1:45 PM

All replies

  • Hi Pure,

    Thank you for posting in MSDN Forum. I’m sorry I am late.

    I still have some questions, although you had given much details.  How about “two operations running” is?

    About search AD, these threads maybe can help you.
    Organizational Units in Active directory are like directories in a file structure.  They help you organize the AD into logical units. http://www.coldelm.com/Active-Directory/VB-Net-Programming-Organizational-Units.aspx
    Accessing LDAP User list using VB.NET: http://www.codeproject.com/KB/IP/LDAP_Using_VBnet.aspx
    Maybe you need more information about Directory Entries: http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentries.aspx
    Active Directory time limit: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/212092af-6e33-4af3-8144-a7a6a931c715/

    I hope these can help you.

    Best Regards


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 7, 2011 2:41 AM
  • Thanks for you reply, Ill read up on the links posted to see if i can make use of them.

    "it seems that i would have two operations running at the same time probably doing the same thing but returning slightly different results"

    What i am saying is i have some code that is copying our AD structure into a TreeView. This works just as intended, but also displays other items that i would like to remove. An example of what i would like to remove is the BuiltIn container (not remove from Active Directory but just from my TreeView node).

    Reading up on this, it seems if i want to limit these results i need to use the DirectorySearcher which allows me to set a filter and this then returns exactly what i would like to display. But display them in a TreeView and searching the DirectorySearcher in my opinion means its running two operations (one - copy and replicating our AD structure, two - iterating through the directorySearcher - just to get similar results).

    So in short i was asking if it was possible to replicate our AD structure in a treeview but having a filter set?

    Thanks

    Monday, February 7, 2011 11:40 AM
  • From what I can tell it looks like the objectClass attribute is 'organizationalUnit', so if you add that to your search filter you should only come back with OUs.
    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Mike Feng Friday, February 11, 2011 6:35 AM
    Monday, February 7, 2011 1:45 PM
  • Hi Pure,

     

    Any update?

     

    How about your problem now? If you need some help, please feel free to let us know. If it works, you can share your solutions & experience here, it will be very beneficial for other community members who have similar questions. Thanks.

     

    Best Regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 9, 2011 9:58 AM