Page 4 of 4 FirstFirst 1234
Results 121 to 125 of 125

Thread: Populate TreeView with Active Directory objects

  1. #121
    New Member
    Join Date
    Jan 2014
    Posts
    1

    Re: Populate TreeView with Active Directory objects

    Quote Originally Posted by chris128 View Post
    Active Directory TreeView / Select AD Container Dialog

    (I have a WPF version as well, if anyone wants that just let me know)
    Hi,

    i'm interessted in the wpf version. Where can i get it?

    Greetings

    Max

  2. #122
    New Member
    Join Date
    Jan 2014
    Posts
    1

    Re: Populate TreeView with Active Directory objects

    I just downloaded the AD Tree View control from this thread (Thread 38 has it attached), but it's version 1.3. Where can I find the latest version (1.5 or newer)?

    Thanks, Krissy

  3. #123
    New Member
    Join Date
    May 2015
    Posts
    1

    Re: Populate TreeView with Active Directory objects

    Hi

    I would be in trestles in the wpf version as well. Would you be able to send me the source files or code if possible?
    Many thanks
    Jamie

  4. #124
    Lively Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    72

    Re: Populate TreeView with Active Directory objects

    Amended version of original project with ability to show groups as well as containers/OUs - which is something I needed for my project

    As per example form checkboxes to set Boolean of true or false for ShowGroups and ShowOUs properties

    Defaults to false for ShowGroups and true for ShowOUs

    Code amended to also show correct icon for groups as well

    Changed from .NET 3.5 to .NET 4.5

    Hopefully may be of use to someone....

    SelectAdContainerDialog_revised.zip
    Last edited by wingers; Apr 16th, 2021 at 04:09 AM.

  5. #125
    New Member
    Join Date
    Oct 2021
    Posts
    1

    Re: Populate TreeView with Active Directory objects

    I know this is an old post but this library code still works great. I've added a few things after changing the target framework to 4.72 to speed up the load time (since I was only interested with targeting organizationalunit and container objects):

    In the AdTreeViewForm.vb file change the "LoadAdNodes" sub to this (or you could just add the entries I have highlighted to your sub):

    Code:
    Private Sub LoadAdNodes(ByVal RootNodeObject As Object)
            Dim RootNode As AdTreeNode = DirectCast(RootNodeObject, AdTreeNode)
            Dim Children As New List(Of AdTreeNode)
            Try
                Using RootDirectoryEntry As New DirectoryEntry("LDAP://" & _DomainController & ":389/" & RootNode.DistinguishedName)
                    RootDirectoryEntry.AuthenticationType = AuthenticationTypes.Secure
                    If Not String.IsNullOrEmpty(_Username) Then
                        RootDirectoryEntry.Username = _Username
                        RootDirectoryEntry.Password = _Password
                    End If
                    RootDirectoryEntry.Children.SchemaFilter.Add("organizationalUnit")
                    RootDirectoryEntry.Children.SchemaFilter.Add("container")
                    For Each ChildObject As DirectoryEntry In RootDirectoryEntry.Children
                            ChildObject.Children.SchemaFilter.Add("organizationalUnit")
                            ChildObject.Children.SchemaFilter.Add("container")
                            Try
                            Dim ChildObjectType As String = ChildObject.SchemaClassName
                            If ChildObjectType = "organizationalUnit" OrElse ChildObjectType = "container" Then
                                Dim ChildNode As New AdTreeNode
                                ChildNode.DisplayName = CStr(ChildObject.Properties("name").Value)
                                If ChildObjectType = "organizationalUnit" Then
                                    ChildNode.Type = AdTreeNode.AdObjectType.OU
                                ElseIf ChildObjectType = "container" Then
                                    ChildNode.Type = AdTreeNode.AdObjectType.Container
                                Else
                                    ChildNode.Type = AdTreeNode.AdObjectType.Unknown
                                End If
                                ChildNode.DistinguishedName = CStr(ChildObject.Properties("distinguishedName").Value).Replace("/", "\/")
                                For Each ChildChildObject As DirectoryEntry In ChildObject.Children
                                    ChildChildObject.Children.SchemaFilter.Add("organizationalUnit")
                                    ChildChildObject.Children.SchemaFilter.Add("container")
                                    Try
                                        If ChildChildObject.SchemaClassName = "organizationalUnit" OrElse ChildChildObject.SchemaClassName = "container" Then
                                            ChildNode.Nodes.Add(New AdTreeNode With {.DisplayName = "Loading..."})
                                            Exit For
                                        End If
                                    Finally
                                        ChildChildObject.Dispose()
                                    End Try
                                Next
                                Children.Add(ChildNode)
                            End If
                        Finally
                            ChildObject.Dispose()
                        End Try
                    Next
                End Using
                Children.Sort()
                LoadFinished(True, Nothing, DirectCast(RootNodeObject, AdTreeNode), Children)
            Catch ex As Exception
                LoadFinished(False, "The following error was encountered whilst trying to load the domain objects: " & ex.Message, Nothing, Nothing)
            End Try
        End Sub

Page 4 of 4 FirstFirst 1234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width