473,466 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I get list of computers in a domain?

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
Nov 17 '05 #1
4 1813
"Peter Steele" <ps*****@z-force.com> wrote in message news:<eq*************@TK2MSFTNGP12.phx.gbl>...
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/de..._resources.asp

-Vinayak
Nov 17 '05 #2
"Peter Steele" <ps*****@z-force.com> wrote in message
news:eq*************@TK2MSFTNGP12.phx.gbl...
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/de...faces_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
Nov 17 '05 #3
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!

"Vinayak Raghuvamshi" <vs************@hotmail.com> wrote in message
news:9a**************************@posting.google.c om...
"Peter Steele" <ps*****@z-force.com> wrote in message news:<eq*************@TK2MSFTNGP12.phx.gbl>...
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/de..._resources.asp
-Vinayak

Nov 17 '05 #4
Two options! I'll have to check out both of these API calls and see which
suits my needs.

"William DePalo [MVP VC++]" <wi***********@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
"Peter Steele" <ps*****@z-force.com> wrote in message
news:eq*************@TK2MSFTNGP12.phx.gbl...
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/de...faces_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

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Piotrek Stachowicz | last post by:
Hi, I'd like to display list of all MS SQL servers which are available on the network (I write application which uses database located on one of the machines in my LAN). Has anyone got any idea...
5
by: Mel Weaver | last post by:
Hi, I'm trying to get a list of Users or Computers currently logged into a domain? Thanks Mel
1
by: Lloyd Taylor | last post by:
Hello, I have a simple bit of code which I have found in the forums which lists all the computer(s) in a domain. The code is: DirectoryEntry domainEntry = new...
4
by: JB | last post by:
I am trying to get a list of all the active computers running on my domain. I'm writing some remote management style software with WMI, which works fine when i know the computer name, but i just...
8
Plater
by: Plater | last post by:
I hope I can explain this correctly. BACKGROUND: My office has a local network. We use a windows server 2003(small business server i think) computer to handle our domain. So all of our employees...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.