473,795 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ 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.Use rDomainName, 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 19797
You have some options, in order of preference:

- Use the System.Manageme nt namespace classes.
- Use the System.Director yServices and the NT4 ADSI provider interface
- Use PInvoke

Here's a sample using the first:

....
ManagementObjec t cs;
using(cs = new ManagementObjec t
("Win32_Compute rSystem.Name='y ourSystemName'" ))
{
cs.Get();
Console.WriteLi ne("{0}",cs["domain"].ToString());
}
}
...

Willy.

"SiPearson" <si***********@ herbertsmith.co m> wrote in message
news:7b******** *************** ***@posting.goo gle.com...
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.Use rDomainName, 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.Manageme nt classes to work for
you.

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

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

For more information about Win32_ComputerS ystem structure, please refer to:
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
win32_computers ystem.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.mi crosoft.com ("Jeffrey Tan[MSFT]") wrote in message news:<Xb******* *******@cpmsftn gxa07.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.Manageme nt classes to work for
you.

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

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

For more information about Win32_ComputerS ystem structure, please refer to:
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
win32_computers ystem.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
8821
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 IIS) and put this automatically in a textbox in an webpage. Can this be done with asp & VB? I basically want to automatically populate a username field with the users logon so the do not need to type it themselves, leading to type errors. ...
4
18172
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 point of view. Thank's in advance
0
520
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 - Domain A is the corporate domain and Domain B is the application domain. Domain B trusts Domain A. What we want to do for general public users is to create users in Domain B (the application) and add them to a group in Domain B. For the...
2
5856
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 reading from a template file and inserting text at bookmark locations (with details pulled from a table in the database). I'm running the app under a regular domain account that isn't an administrator on the server. The read/execute permissions are...
4
1073
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 process under a domain user, rather than give the ASP.NET user access to the share. regards, Bruce
1
6775
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
2271
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
2060
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 sucessfully copy a file out to a network share using a ASP.NET application, but when I updated the password in the machine.config file it now gives me this System.IO.IOException: The account used is a computer account. Use your global user account or...
0
1436
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 successfully add domain users if I run the application under the identity of a domain account with administrative privileges on the local machine (or use windows auth with impersonation), but if I try to run it under a local account rather than a domain...
0
1236
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 user has logged in to the Server, application was able to access the certificates. but unable to access the certificates when the domain user was not logged into the server. Can anyone let me know whether the domain user has to login, is there any...
0
9673
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
10217
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...
1
10167
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9046
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
7544
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
6784
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
5440
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...
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.