473,473 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get the MACHINE domain, not the user domain.

Hi,

I'm writing an app that needs to get the domain the machine running it
belongs to. I know that you can do a Environment.UserDomainName, but
this returns the domain the user has logged onto.

What I have is a machine that sits on a resource domain called ***Res,
and a trusted domain the user logs onto the machine called Global.
The user always logs onto Global, but the machine could be on BobRes,
BillRes or BrianRes.

I'd be grateful if someone could help me found out which domain the
machine is on.

Many thanks

Simon
Nov 15 '05 #1
4 19780
You have some options, in order of preference:

- Use the System.Management namespace classes.
- Use the System.DirectoryServices and the NT4 ADSI provider interface
- Use PInvoke

Here's a sample using the first:

....
ManagementObject cs;
using(cs = new ManagementObject
("Win32_ComputerSystem.Name='yourSystemName'" ))
{
cs.Get();
Console.WriteLine("{0}",cs["domain"].ToString());
}
}
...

Willy.

"SiPearson" <si***********@herbertsmith.com> wrote in message
news:7b**************************@posting.google.c om...
Hi,

I'm writing an app that needs to get the domain the machine running it
belongs to. I know that you can do a Environment.UserDomainName, but
this returns the domain the user has logged onto.

What I have is a machine that sits on a resource domain called ***Res,
and a trusted domain the user logs onto the machine called Global.
The user always logs onto Global, but the machine could be on BobRes,
BillRes or BrianRes.

I'd be grateful if someone could help me found out which domain the
machine is on.

Many thanks

Simon

Nov 15 '05 #2

Hi simon

Thank you for posting in the community!

Based on my understanding, you want to get the domain's name which your
machine belongs to, but not the domain your user logon.

=================================================
Just as Willy suggested, you can use System.Management classes to work for
you.

Actually, System.Management classes use WMI to get the system information.

I have tested Willy's sample, it works well.

For more information about Win32_ComputerSystem structure, please refer to:
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
win32_computersystem.asp

=================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3
Many thanks to both of you for your help, thats exactly what I was looking for.

Thanks again

Simon
v-*****@online.microsoft.com ("Jeffrey Tan[MSFT]") wrote in message news:<Xb**************@cpmsftngxa07.phx.gbl>...
Hi simon

Thank you for posting in the community!

Based on my understanding, you want to get the domain's name which your
machine belongs to, but not the domain your user logon.

=================================================
Just as Willy suggested, you can use System.Management classes to work for
you.

Actually, System.Management classes use WMI to get the system information.

I have tested Willy's sample, it works well.

For more information about Win32_ComputerSystem structure, please refer to:
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
win32_computersystem.asp

=================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4

Hi simon

Thanks for your feedback.

If you have any further concern, please feel free to tell me, I will work
with you. thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

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

Similar topics

1
by: jach | last post by:
How can I get the domain, username and PC network name (Win 2000 Pro & Win XP Pro PC's) of the current logged on user (logged onto a domain and access an intranet page, Window 2000 server running...
4
by: Kona | last post by:
Hello, My server is part of a W2K domain. What do you advice me as account to run my SQL*Server, service started with a domain user account or as local system ? I need advices from a security...
0
by: RobinB | last post by:
We gave created a web application that uses AD for authorization and authentication. The application can be used by domain users as well as the general public. What we currently have is 2 domains...
2
by: David Olive | last post by:
Hi guys, I'm having a bit of a problem getting a VB .NET console app to run happily as a scheduled task. The app itself generates a bunch of word documents on a file share on another server by...
4
by: Bruce Whitehouse | last post by:
How do I get the ASP.NET processes running under a domain user, rather than the standard ASP.NET user? I have a COM dll that requires access to a network share. I'd rather run the ASP.NET...
1
by: Paul | last post by:
Hi all, Thanks in advance for your help. I would like to know how to add a computer to a domain, and a domain user to a local group. Cheers Paul
4
by: Michael | last post by:
Hello, does anyone know how to find out the logged in user with domain in vc++ ? Thanks for help Michael
1
by: Jason Camp | last post by:
I used the following article to run ASP.NET 1.1 under a domain user identity: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT01.asp I was able to...
0
by: Chad Dressler | last post by:
I'm trying to use System.DirectoryServices to add a domain user to a local group via a web application which runs under the identity of a local admin account. Is this possible? I can...
0
by: Sethuraman D | last post by:
Using <identity impersonate="true" userName="DOMAIN\UserName" password="Password" /> From the client machine, the application access the server to check for the certificates. When the domain...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
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
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,...
1
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...
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?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.