get domain name - Global.asax

G

Guest

Hello,
I tried to get UserName and Domain by doing:
System.Collections.Specialized.NameValueCollection var =
Request.ServerVariables;
string[] sLogonUserArr = var["LOGON_USER"].ToString().Split('\\');

It's not working at the Global.asax file in the events:
Application_Start, Application_End, Application_Error, Session_Start,
Session_End

How can I get them ?

thanx,
Oren
 
R

Ray Booysen

Are you talking about the user who wants to log in or the user that is
logged into the domain of the computer that is accessing the site?
 
G

Guest

hi,
I mean the user/domain that accessed to IIS.

Ray Booysen said:
Are you talking about the user who wants to log in or the user that is
logged into the domain of the computer that is accessing the site?
Hello,
I tried to get UserName and Domain by doing:
System.Collections.Specialized.NameValueCollection var =
Request.ServerVariables;
string[] sLogonUserArr = var["LOGON_USER"].ToString().Split('\\');

It's not working at the Global.asax file in the events:
Application_Start, Application_End, Application_Error, Session_Start,
Session_End

How can I get them ?

thanx,
Oren
 
Joined
Jul 6, 2006
Messages
4
Reaction score
0
to get the current user name logged into the domain

hi,
Just try this HttpContext.Current.User.Identity.Name to get the user name logged in to that domain.

Regards
Balaji


=?Utf-8?B?T3Jlbg==?= said:
hi,
I mean the user/domain that accessed to IIS.

"Ray Booysen" wrote:

> Are you talking about the user who wants to log in or the user that is
> logged into the domain of the computer that is accessing the site?
>
> Oren wrote:
> > Hello,
> > I tried to get UserName and Domain by doing:
> > System.Collections.Specialized.NameValueCollection var =
> > Request.ServerVariables;
> > string[] sLogonUserArr = var["LOGON_USER"].ToString().Split('\\');
> >
> > It's not working at the Global.asax file in the events:
> > Application_Start, Application_End, Application_Error, Session_Start,
> > Session_End
> >
> > How can I get them ?
> >
> > thanx,
> > Oren

>
 
G

George Ter-Saakov

How do you think you can get a UserName/Domain in Application_Start.
There are no users. Application just starting.......
--------------------------------------------------------------
You can get it in Session_Start because that event is a direct response on
user hitting the site first time.

Most likely you need to set NT Authentication in IIS management and disable
anonymous access to your application. Then IIS will authenticate user and
LOGON_USER will be available.

------------------------------------------------------------------

You can not get that info in Session_End simply becuase this even is not a
response to any user action. The Request object is not available.
Session_End fire up after 20 minutes from lat time user hit your site.



George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top