Get Username for logged in user using ASP.net(c#.net)

Posted by Kavi.Sirius under ASP.NET on 5/11/2012 | Points: 10 | Views : 18229 | Status : [Member] | Replies : 15
hi,

I am having trouble getting a logged in username to use on an iis server. If I use User.Identity.Name.ToString I get a blank.
If I use Environment.UserName.ToString I get "Network Service".

If I run the application in debug locally I get the Domain\username but not when I run it on our iis server.

Regards
Kavi.n



Responses

Posted by: Sakthi.Singaravel on: 5/11/2012 [Member] Silver | Points: 25

Up
0
Down
sorry i don't know abt asp .net and web pages...

anyway refer this....

http://forums.asp.net/t/1179997.aspx/1

Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 5/11/2012 [Member] Silver | Points: 25

Up
0
Down
this link must used for u....

http://www.codeproject.com/Articles/12614/How-to-Get-Window-NT-Logged-User-Name-Using-ASP-NE#_rating

Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kavi.Sirius on: 5/11/2012 [Member] Starter | Points: 25

Up
0
Down
hi,

Thank u for ur reply,
i already saw this site,
but is not working

Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 5/11/2012 [Member] Silver | Points: 25

Up
0
Down
sorry...

Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 5/11/2012 [Member] Silver | Points: 25

Up
0
Down
try this..

http://msdn.microsoft.com/en-us/library/fcxcb339.aspx

Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 5/11/2012 [Member] Silver | Points: 25

Up
0
Down
refer this..
Ur same query posted here...
So its used for u...

Page 1:

http://forums.asp.net/t/1121780.aspx/1?Getting+a+users+DOMAIN+username+from+a+web+application

Page 2:

http://forums.asp.net/t/1121780.aspx/2/10?Getting+a+users+DOMAIN+username+from+a+web+application



Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kavi.Sirius on: 5/11/2012 [Member] Starter | Points: 25

Up
0
Down
Thank u for ur replies

Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 5/12/2012 [Member] Starter | Points: 25

Up
0
Down
If User.Identity.IsAuthenticated Then

Label17.Text = User.Identity.Name

Else

Label17.Text = "No user identity available."

End If

This is work perfectly

Rathnayake

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kavi.Sirius on: 5/12/2012 [Member] Starter | Points: 25

Up
0
Down
hi nuwan

this code work perfectly in localhost
but not work in iis server


Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 5/12/2012 [Member] Silver | Points: 25

Up
0
Down
try this..

HttpContext.Current.Request.LogonUserIdentity.Name 


Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 5/12/2012 [Member] Silver | Points: 25

Up
0
Down
Read this article...

http://richhewlett.com/2011/02/15/getting-a-users-username-in-asp-net/

Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 5/12/2012 [Member] Starter | Points: 25

Up
0
Down
Ok I will check it in iis.

Rathnayake

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 5/16/2012 [Member] Starter | Points: 25

Up
0
Down
You Can do that using Session, try it.

Rathnayake

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kavi.Sirius on: 5/16/2012 [Member] Starter | Points: 25

Up
0
Down
hi nuwan,

i cant get ur answer,
pls explain clearly

Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 5/16/2012 [Member] Starter | Points: 25

Up
0
Down
in Login Page.aspx

Session["user"] = this.TexUsername.Text;
Response.Redirect("ViewPage.aspx");

View Page.aspx

this.LblUsername.Text = Session["user"].ToString();

Try This code

Rathnayake

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response