473,792 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listing Machines on a Domain

I'm sure this is easy and i'll kick myself for it.

How would i go about listing all the machines on a domain?
I want to display them in a list box.

Thanks

/Jonny
Nov 15 '05 #1
4 1941
Jonny,

You will have to make a call to the NetServerEnum API function through
the P/Invoke layer. This will allow you to get the names of different types
of machines (including all machines, if you wish) in your domain.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jonny" <jo************ *****@hotmail.c om> wrote in message
news:06******** *************** *****@phx.gbl.. .
I'm sure this is easy and i'll kick myself for it.

How would i go about listing all the machines on a domain?
I want to display them in a list box.

Thanks

/Jonny

Nov 15 '05 #2
use DirectoryServic e:
DirectoryEntry de = new DirectoryEntry
("WinNT://YourDomain");
DirectoryEntrie s des = deDomain.Childr en;
foreach (DirectoryEntry d in desDomain) {
if ("Computer" == d.SchemaClassNa me) { //do something }
}
Linh Nguyen
}
-----Original Message-----
I'm sure this is easy and i'll kick myself for it.

How would i go about listing all the machines on a domain?
I want to display them in a list box.

Thanks

/Jonny
.

Nov 15 '05 #3
Thanks, A few changes and the code was great.

It does throw up absolutely every machine ever on the
domain... is there a way to filter the list so that only
active or current machines are shown?

Thanks again guys,

/Jonny

-----Original Message-----
Jonny,

You will have to make a call to the NetServerEnum API function throughthe P/Invoke layer. This will allow you to get the names of different typesof machines (including all machines, if you wish) in your domain.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jonny" <jo************ *****@hotmail.c om> wrote in messagenews:06******* *************** ******@phx.gbl. ..
I'm sure this is easy and i'll kick myself for it.

How would i go about listing all the machines on a domain? I want to display them in a list box.

Thanks

/Jonny

.

Nov 15 '05 #4
Don't PInvoke NetXXXX API's, use DirectoryServic es namespace instead.

Try this:

using System;
using System.Director yServices;
//*************** *************** *************** *************** *************** */

class Tester {
public static void Main() {
String unl = new string(('_'),60 );

DirectoryEntry container;
using( container = new DirectoryEntry( "WinNT://celeb", "celeb\\adminis trator", "kevin", AuthenticationT ypes.ServerBind ))
{
DirectoryEntrie s computers = container.Child ren;
computers.Schem aFilter.Add("Co mputer");
foreach (DirectoryEntry computer in computers) {
try
{
Console.WriteLi ne("domain member path: " + computer.Path);
// connect with the member to retrieve its name
// this can be very time consuming in a large domain, especially when some PC's are off-line
Console.WriteLi ne("Name" + ":\t" + (computer.Prope rties["Name"])[0].ToString());
}
catch(Exception e)
{
// "The network path was not found." will be thrown when a member is down or unreacheable.
Console.WriteLi ne(e.Message );
}
}
}
}
}

Willy.
"Jonny" <jo************ *****@hotmail.c om> wrote in message news:06******** *************** *****@phx.gbl.. .
I'm sure this is easy and i'll kick myself for it.

How would i go about listing all the machines on a domain?
I want to display them in a list box.

Thanks

/Jonny

Nov 15 '05 #5

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

Similar topics

2
4556
by: Dirk Hagemann | last post by:
Hi! I'm using this code to list all computers of our WinNT-Domains: import win32com.client from pprint import pprint as p domain='domainX' auswahl='computer' def enumerate(domain,auswahl): adsi = win32com.client.Dispatch("ADsNameSpaces")
3
1845
by: Jason | last post by:
I need to get a listing of users from Active Directory. Getting the list is no problem using the DirectorySearcher class. My problem is getting the full legacy-style domain name of the user (in the form of domain\username). The "sAMAccountName" property only gives me the username portion. What property gives with the domain? Or do I need to be looking at a different AD object altogether? Thanks, Jason
5
3926
by: Eranga | last post by:
I want to get the list of computers with users logged on in my domain using C# as the language . Can some one of you plese tell me how exactly I can perform this Thanks in advance *** Sent via Developersdex http://www.developersdex.com ***
2
1272
by: Grace | last post by:
Are there any ways it can let users only login once and users can browse different ASP.Net/ASP web applications on different machines? ex: A machine: login web application, a web application B machine: b web application C machine: c web application Users only login on A machine, they don't login again and they can use a, b and c web applications. How to do it?
4
1687
by: Dan Walls | last post by:
Hi, I am deploying an ASP.Net web app into the following scenario: Internet --> Firewall --> WebServer (IIS) --> --> However I am not sure what sort of authentication options are available to me in gettingthe application to talk to the SQL server. How do I talk between the web app and the database server - if TCP/IP then
3
2774
by: Joe User | last post by:
Hi - I found the class below on another website (www.devx.com) and can't seem to figure out how to make a call to this class to retrieve the machines and put them in a listbox. I am definitely a beginner in vb programming, and would really appreciate the help. TIA!
3
3037
by: tshad | last post by:
I have my windows authentication on our intranet set up as: <authentication mode="Windows"/> This works for 15 machines at work fine. Doesn't ask you to logon. It uses the logon credentials the user used to logon originally There are 4 machines that it asks for logon credentials (even though they have already logged on). Obviously, the credentials are valid or they wouldn't be able to log on to their local machines.
3
4932
by: =?Utf-8?B?ZG1idXNv?= | last post by:
I would like a listing of all users in the current domain (or on my computer). I'm running Windows XP Home Edition and I've set up four user, one for each member of my family. 'My.User.Name' just lists me. How do I get the others? I looked at some code posted here on 4/27/07 and it doesn't work, I've already tried it. Thanks in advance. --
5
3004
by: Maniyarasan | last post by:
Hi All, I am unable to access another machine's IIS URL from my machines in a same domain. Say like..Two machines are in a domain called machine1, machine2. http://machine1/ http://machine2/ these two URL's should access from one another. It is not happening for me..
0
9670
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
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 we have to send another system

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.