Link to home
Start Free TrialLog in
Avatar of hamda000
hamda000Flag for Canada

asked on

displaying computer name in listbox without "CN".

I found this code and it is working for me.
I'm trying to display a list of computer from a specific OU but in the listbox, I got the real name with the Common Name prior to the real name.

EXemple:

CN=COMPUTER NAME

Here is my code
-------------------------------------------------------------------------------------------------------------------
Imports System
Imports System.Net
Imports System.DirectoryServices
Imports System.DirectoryServices.ActiveDirectory

Public Class frmMediaProjectorTest

Private Sub frmMediaProjectorTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
    End Sub
 

Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
        'Affiche la liste des ordinateurs du OU Médiatisation
       
        Dim domain As DirectoryEntry = New DirectoryEntry("LDAP://OU=ORDI-MEDIATISATION,ou=ORDINATEURS,OU=AD2008,DC=cegep-st-laurent,DC=qc,DC=ca")

        For Each child As DirectoryEntry In domain.Children
            'remplir la liste avec les nom des postes Médiatisation
            lstProjectors.Items.Add(child.Name).ToString()
        Next

    End Sub

   
    Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
        'Quitter le programme
        Me.Close()
    End Sub
End Class
ASKER CERTIFIED SOLUTION
Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hamda000

ASKER

Thank you very much. It works.