Find Who Loggedin on Particular System

Posted by Sivaprasadadiraju under ASP.NET on 11/24/2010 | Points: 10 | Views : 1331 | Status : [Member] | Replies : 7
Hi
how can i find who is logged in means windows user name?
based on username my web application has to work
now i am using
lblname.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

its is working in my system. but when i am hosting this it is not giving windows username it is giving
ASPNET as username

SIVA PRASAD ADIRAJU


Responses

Posted by: Vuyiswamb on: 11/25/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Why dont you use the environmental variables like

Environment.UserName


Thank you for posting at Dotnetfunda
[Administrator]

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

Posted by: Sivaprasadadiraju on: 11/25/2010 [Member] Starter | Points: 25

Up
0
Down
Hi i implemented this one also i am getting same thing by using this one...pls help me out

SIVA PRASAD ADIRAJU

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

Posted by: Chvrsri on: 11/25/2010 [Member] [Moderator] [MVP] Silver | Points: 25

Up
0
Down
Using 3 ways you can get the username of the person logged in :


They are

1) System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;

string strName = p.Identity.Name;

[ OR ]

2) string strName = HttpContext.Current.User.Identity.Name.ToString();

[ OR ]

3) string strName = Request.ServerVariables["AUTH_USER"]; //Finding with name

string strName = Request.ServerVariables[5]; //Finding with index

In Above 3 Cases returnin string contains DomainName\WinNTLoggedUserName

(for Ex: Microsoft\Bill.Gates. Here Microsoft is domain Bill.Gates is Logger User Name )

Using string operations seperate the DomainName and UserName.


Refer this articel for more information....

http://www.codeproject.com/KB/aspnet/How_to_NT_User_Name.aspx
Hope this helps ...

Cheers!!!



Thanks,
Radha Srikanth

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

Posted by: Chvrsri on: 11/25/2010 [Member] [Moderator] [MVP] Silver | Points: 25

Up
0
Down
Reply me if you gained answer from the above mentioned links

Thanks,
Radha Srikanth

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

Posted by: Sivaprasadadiraju on: 11/25/2010 [Member] Starter | Points: 25

Up
0
Down
sri,

it is working on local host but when i hosted that one in iis and testing on another system on lan at that time it is giving ASPNET as user name and my system name as domain name.

but i need username of windowsNTlogin of testing machine

SIVA PRASAD ADIRAJU

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

Posted by: Chvrsri on: 11/25/2010 [Member] [Moderator] [MVP] Silver | Points: 25

Up
0
Down
Hi Siva,

Try this.....


Use IIS Manager to turn off Anonymous Access and turn on
Integrated Security (this is done on the Directory Security tab of the
website Property pages, using the Edit button in the Anonymous Access and
authentication control section).

Once you have done this, the user name will be in the LOGON_USER
servervariable:

Response.Write Request.ServerVariables("LOGON_USER")


Follow this link for more details .(I found this info there)

http://www.eggheadcafe.com/software/aspnet/32876232/how-to-get-username-on-iis-run-intranet-asp.aspx



Thanks,
Radha Srikanth

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

Posted by: Sivaprasadadiraju on: 11/25/2010 [Member] Starter | Points: 25

Up
0
Down
Sri,

it is not working , it is asking username and password to connect with my system.
it is giving domainname and my username when i run on my system. when i am testing on other system it is not working

SIVA PRASAD ADIRAJU

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

Login to post response