Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 31 Dec 2006 06:40 GMT
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.

Signature

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

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

David Thielen - 31 Dec 2006 06:52 GMT
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.

Signature

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

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

> 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.
Mark Rae - 31 Dec 2006 10:55 GMT
> 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...
David Thielen - 31 Dec 2006 16:27 GMT
Any idea how? I've tried and this seems to be a very difficult problem.

Signature

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

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

> > In the case of NETWORD SERVICE the env var USERDOMAIN is an empty string.
> > And
[quoted text clipped - 4 lines]
> to return the name of the domain that it's part of I think you'd have to use
> ActiveDirectory...
Mark Rae - 31 Dec 2006 17:19 GMT
> 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);
}
David Thielen - 31 Dec 2006 20:51 GMT
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.

Signature

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

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

> > Any idea how? I've tried and this seems to be a very difficult problem.
>
[quoted text clipped - 4 lines]
>     strDomain = objSearcher.SearchRoot.Name.Substring(3);
> }
Mark Rae - 31 Dec 2006 21:43 GMT
> 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... :-)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.