Link to home
Start Free TrialLog in
Avatar of farhadtolooie
farhadtolooie

asked on

how I retreive computernameof clients in activedirectory ?

i wrote these :
Dim management_object As ManagementObject
        Dim m_local_domain_name As String
        Dim m_local_computer_name As String
        For Each management_object In queryCollection
            m_local_domain_name = management_object("Domain")
            m_local_computer_name = management_object("Name")
        Next management_object


        Dim a As DirectoryEntry = GetComputersInfoCollection("ioptc.org")
        Dim mySearcher As System.DirectoryServices.DirectorySearcher = _
        New System.DirectoryServices.DirectorySearcher(a)
        mySearcher.Filter = ("(objectClass=computer)")
        Dim resEnt As System.DirectoryServices.SearchResult
       
        For Each resEnt In mySearcher.FindAll()
            Try
                TextBox20.Text = TextBox20.text + (":Processing:" & Mid(resEnt.GetDirectoryEntry).Name.ToString(), 4))

            Catch ex As Exception
                Console.WriteLine("Trying to Connect to: " & _
                  resEnt.GetDirectoryEntry().Name.ToString() & vbCrLf & ex.Message.ToString())
            End Try

        Next



and



Public Function GetComputersInfoCollection(ByVal domain As String) As DirectoryEntry
        Dim domainEntry As DirectoryEntry = New DirectoryEntry("WinNT://" + domain, "ioptc\rpi", "ali ranji 321", AuthenticationTypes.Secure)
        domainEntry.Children.SchemaFilter.Add("computer")
        Return domainEntry
    End Function


but when i run i get this error message:The provider does not support searching and cannot search WinNT://ioptc.org
Avatar of farhadtolooie
farhadtolooie

ASKER

IS THERE ANY EXPERT TO SOLVE MY QUESTION?
I write
 dirEntry.Path = "LDAP://10.48.10.50/CN=Users;DC=ioptc"
and I get error :
A referral was returned from the server
please help me
ASKER CERTIFIED SOLUTION
Avatar of graye
graye
Flag of United States of America 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
I write
dirEntry.Path = "LDAP://ioptc/OU=Users"
ioptc is our company domain and I want to get  computername of all clients,
and error occure:
operation error occured
please help me !
what I replace in OU=Users?
that'scorrect?
I'd use the full path to the domain

OU=Users,DC=ioptc,DC=com