Detect the name of the ASP.NET user

Detect the name of the ASP.NET user

am 09.08.2007 20:54:02 von Vilhelm

I am making a ASP.NET application that connects to a database.

I want to distrtibute this to my customers that may have different Windows
OS, so my installer must handle different windows versions.

In my installer I am using the following SQL statement to enable ASP.NET to
connect to my database.
CREATE LOGIN [NT AUTHORITY\NETWORK SERVICE] FROM WINDOWS
followed by
sp_grantdbaccess 'NT AUTHORITY\NETWORK SERVICE'

This works like a charm when the ASP.NET user is NT AUTHORITY\NETWORK
SERVICE, but that is not the case for all Windows versions.
It even depends on the language of the windows operation system.

How do I detect (in C#) the name (including domain) of the user that runs
the ASP.NET process?

Thankful for any response.

-- Vihelm Heiberg

Re: Detect the name of the ASP.NET user

am 09.08.2007 21:10:28 von reb01501

Vilhelm wrote:
> I am making a ASP.NET application that connects to a database.

There was no way for you to know it (except maybe by browsing through
some of the previous questions before posting yours - always a
recommended practice), but this is a classic asp newsgroup. ASP.Net is
a different technology from classic ASP. While you may be lucky enough
to find a dotnet-savvy person here who can answer your question, you
can eliminate the luck factor by posting your question to a newsgroup
where the dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net where you can find a lot of people
to help you.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.