473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1917
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.com

"Jonny" <jo*****************@hotmail.com> 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 DirectoryService:
DirectoryEntry de = new DirectoryEntry
("WinNT://YourDomain");
DirectoryEntries des = deDomain.Children;
foreach (DirectoryEntry d in desDomain) {
if ("Computer" == d.SchemaClassName) { //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.com

"Jonny" <jo*****************@hotmail.com> 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 DirectoryServices namespace instead.

Try this:

using System;
using System.DirectoryServices;
//************************************************** **************************/

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

DirectoryEntry container;
using( container = new DirectoryEntry("WinNT://celeb", "celeb\\administrator", "kevin", AuthenticationTypes.ServerBind))
{
DirectoryEntries computers = container.Children;
computers.SchemaFilter.Add("Computer");
foreach (DirectoryEntry computer in computers) {
try
{
Console.WriteLine("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.WriteLine("Name" + ":\t" + (computer.Properties["Name"])[0].ToString());
}
catch(Exception e)
{
// "The network path was not found." will be thrown when a member is down or unreacheable.
Console.WriteLine(e.Message );
}
}
}
}
}

Willy.
"Jonny" <jo*****************@hotmail.com> 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
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):...
3
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...
5
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...
2
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...
4
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...
3
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...
3
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...
3
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'...
5
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/...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.