Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

How can I get list of computers in a domain?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Steele - 29 Jun 2004 23:27 GMT
I've found some VB code to query a domain controller to return the list of
all computers in that domain. The VB code is reasonably straightforward (see
below). How do I do the equivalent in C++? I've done a lot of searches and
haven't come up with much useful information. Any pointers would be
appreciated:

Public Function GetDomainComputers(ByVal strDomain)
  Dim objIADsContainer          ' ActiveDs.IADsDomain -
  Dim objIADsComputer           ' ActiveDs.IADsComputer
  Dim vReturn                   ' Variant

  Set objIADsContainer = GetObject("WinNT://" & strDomain)

  ' set the filter to retrieve only objects of class Computer
  objIADsContainer.Filter = Array("Computer")

  ReDim vReturn(0)
  For Each objIADsComputer In objIADsContainer
     If Trim(vReturn(0)) <> "" Then
        ReDim Preserve vReturn(UBound(vReturn) + 1)
     End If
     vReturn(UBound(vReturn)) = objIADsComputer.Name
  Next

  GetDomainComputers = vReturn
  Set objIADsComputer = Nothing
  Set objIADsContainer = Nothing
End Function
Vinayak Raghuvamshi - 30 Jun 2004 04:22 GMT
> I've found some VB code to query a domain controller to return the list of
> all computers in that domain. The VB code is reasonably straightforward (see
> below). How do I do the equivalent in C++? I've done a lot of searches and
> haven't come up with much useful information. Any pointers would be
> appreciated:

check out WNetEnumResource

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/enume
rating_network_resources.asp


-Vinayak
Peter Steele - 30 Jun 2004 13:20 GMT
I'd much rather use an API call than deal with Active Directory. I had
looked for something but none of my searches came up with anything. This
appears to be what I need. Thanks!

> > I've found some VB code to query a domain controller to return the list of
> > all computers in that domain. The VB code is reasonably straightforward (see
[quoted text clipped - 3 lines]
>
> check out WNetEnumResource

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/enume
rating_network_resources.asp


> -Vinayak
William DePalo [MVP VC++] - 30 Jun 2004 04:51 GMT
> I've found some VB code to query a domain controller to return the list of
> all computers in that domain. The VB code is reasonably straightforward (see
> below). How do I do the equivalent in C++? I've done a lot of searches and
> haven't come up with much useful information. Any pointers would be
> appreciated:

I'm not expert at either VB or Active Directory Services but that's what I
think your snippet is using. You may want to start reading here

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/activ
e_directory_service_interfaces_adsi.asp


and then perhaps find an Active Directory newsgroup for information on its
object model.

On the other hand if you are looking for an answer to the question in the
subject line then I'd suggest that you search the docs for NetServerEnum()
for the pre-AD way of enumerating the workstations in a domain.

Regards,
Will
Peter Steele - 30 Jun 2004 13:21 GMT
Two options! I'll have to check out both of these API calls and see which
suits my needs.

> > I've found some VB code to query a domain controller to return the list of
> > all computers in that domain. The VB code is reasonably straightforward
[quoted text clipped - 5 lines]
> I'm not expert at either VB or Active Directory Services but that's what I
> think your snippet is using. You may want to start reading here

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/activ
e_directory_service_interfaces_adsi.asp


> and then perhaps find an Active Directory newsgroup for information on its
> object model.
[quoted text clipped - 5 lines]
> Regards,
> Will

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.