473,396 Members | 1,836 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,396 software developers and data experts.

How do I get the domain name that a computer is on?

If my ASP.NET app is running as NETWORK SERVICE then
Environment.UserDomainName returns NT AUTHORITY, not the domain name. Same
for anything returning the full username.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
Dec 31 '06 #1
6 1474
In the case of NETWORD SERVICE the env var USERDOMAIN is an empty string. And
there are cases where I do not have a client user (scheduled reports) so I
can't use the domain part of an authenticated user.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"David Thielen" wrote:
If my ASP.NET app is running as NETWORK SERVICE then
Environment.UserDomainName returns NT AUTHORITY, not the domain name. Same
for anything returning the full username.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Dec 31 '06 #2
"David Thielen" <th*****@nospam.nospamwrote in message
news:9D**********************************@microsof t.com...
In the case of NETWORD SERVICE the env var USERDOMAIN is an empty string.
And
there are cases where I do not have a client user (scheduled reports) so I
can't use the domain part of an authenticated user.
Obviously, it's easy enough to get the machine name of the IIS server, but
to return the name of the domain that it's part of I think you'd have to use
ActiveDirectory...
Dec 31 '06 #3
Any idea how? I've tried and this seems to be a very difficult problem.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"Mark Rae" wrote:
"David Thielen" <th*****@nospam.nospamwrote in message
news:9D**********************************@microsof t.com...
In the case of NETWORD SERVICE the env var USERDOMAIN is an empty string.
And
there are cases where I do not have a client user (scheduled reports) so I
can't use the domain part of an authenticated user.

Obviously, it's easy enough to get the machine name of the IIS server, but
to return the name of the domain that it's part of I think you'd have to use
ActiveDirectory...
Dec 31 '06 #4
"David Thielen" <th*****@nospam.nospamwrote in message
news:85**********************************@microsof t.com...
Any idea how? I've tried and this seems to be a very difficult problem.
E, well this certainly works for me:

using (DirectorySearcher objSearcher = new DirectorySearcher())
{
strDomain = objSearcher.SearchRoot.Name.Substring(3);
}
Dec 31 '06 #5
Is (string) objSearcher.SearchRoot.Properties["name"].Value;

legit (ie will always work)? Or better to use yours below? I want to make
sure whatever I use works on 100% of the system configurations out there.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"Mark Rae" wrote:
"David Thielen" <th*****@nospam.nospamwrote in message
news:85**********************************@microsof t.com...
Any idea how? I've tried and this seems to be a very difficult problem.

E, well this certainly works for me:

using (DirectorySearcher objSearcher = new DirectorySearcher())
{
strDomain = objSearcher.SearchRoot.Name.Substring(3);
}
Dec 31 '06 #6
"David Thielen" <th*****@nospam.nospamwrote in message
news:62**********************************@microsof t.com...
Is (string) objSearcher.SearchRoot.Properties["name"].Value;

legit (ie will always work)? Or better to use yours below? I want to make
sure whatever I use works on 100% of the system configurations out there.
Sorry, but I don't know enough about it to be sure.

I suggest you post in microsoft.public.adsi.general - anything you are told
by Joe Kaplan you can take as gospel... :-)
Dec 31 '06 #7

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

Similar topics

0
by: Paul Steele | last post by:
This isn't really a question on .NET, although it is network related. There doesn't seem to be a way in .NET to work with domains in any case. I am writing a C# program to automate the...
1
by: Paul Steele | last post by:
I am writing a C# program to automate the deployment of new notebooks the first time they are booted after sysprep has done it's thing. I want to join the notebook to our domain and give it a...
7
by: Peter Steele | last post by:
I have code to add a domain user to a local group but I'm not sure if it will work with NT domains or whether it will only work with Active Directory based systems. Here's the code: public void...
5
by: Bruno Mendonça | last post by:
My boss asked me to build a program to create a report with logon/logoff events for all users within our windows domain. I'm using .Net to do so and decided to have a program running on the Domain...
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
6
by: Anders K. Olsen | last post by:
Hello group I'm trying to list the users and groups who has read access to a file. I use .NET 2.0 and FileInfo.GetAccessControl().GetAccessRules(...) and then loop through the...
6
by: Spyder | last post by:
When you go to "MyComputer" and get properties and select "Computer Name", you get the Domain or Workgroup a computer belongs to. I have looked thru MSDN library, the Internet, the Registry and in...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...
0
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...

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.