如何添加计算机"描述"在列表框中以及名称(vb.net)

时间:2015-06-30 22:09:44

标签: vb.net visual-studio active-directory directorysearcher

因此,我设法从我阅读和编写的文档中提取此代码,以便从我们的Active Directory中获取计算机名称,但它提取的名称没有描述,我试图找出如何继续前进并学习如何在填充计算机名称的列表框中添加说明。

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

        If Me.ComboBox1.Text = "ALL" Then

            Dim entry As New DirectoryServices.DirectoryEntry("LDAP://OU=H-computers,DC=H,DC=LOCAL")
            Dim mySearcher As New System.DirectoryServices.DirectorySearcher(entry)
            Dim result As System.DirectoryServices.SearchResult
            Dim results As SearchResultCollection
            Dim RetArray As New Hashtable()

            mySearcher.PropertiesToLoad.Add("name")
            mySearcher.PropertiesToLoad.Add("userPrincipalName")

            mySearcher.Filter = "(&(objectCategory=computer))"
            results = mySearcher.FindAll

            Me.ListBox1.Items.Clear()


            For Each result In results
                Me.ListBox1.Items.Add(result.GetDirectoryEntry().Properties("name").Value)
                Me.ListBox1.MultiColumn = False

            Next



        End If

欢迎任何帮助

0 个答案:

没有答案