473,378 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Getting username

Vik
An ASP.NET page uses Windows authentication method for the user log in. How
can get the username by code in this page?

Thanks.
Nov 18 '05 #1
4 1413
There are three identities that may be of interest:
HttpContext.Current.User, WindowsIdentity.GetCurrent(), and
Thread.CurrentPrincipal. Depending on the exact details of your
authentication and impersonation scheme, one or more of these may contain
the identity you want. See
http://msdn.microsoft.com/library/en...SecNetAP05.asp for
details.

HTH,
Nicole
"Vik" <viktorum@==hotmail.com==> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
An ASP.NET page uses Windows authentication method for the user log in.
How
can get the username by code in this page?

Thanks.

Nov 18 '05 #2
"HttpContext.Current.User" WILL contain the identity you want if you are using windows authentication.

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
There are three identities that may be of interest:
HttpContext.Current.User, WindowsIdentity.GetCurrent(), and
Thread.CurrentPrincipal. Depending on the exact details of your
authentication and impersonation scheme, one or more of these may contain
the identity you want. See
http://msdn.microsoft.com/library/en...SecNetAP05.asp for
details.

HTH,
Nicole


"Vik" <viktorum@==hotmail.com==> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
An ASP.NET page uses Windows authentication method for the user log in.
How
can get the username by code in this page?

Thanks.



Nov 18 '05 #3
The easy version of the other two replies is just use something like this:

userName = User.Identity.Name;

--
Dale Preston
MCAD C#
MCSE, MCDBA
"Vik" wrote:
An ASP.NET page uses Windows authentication method for the user log in. How
can get the username by code in this page?

Thanks.

Nov 18 '05 #4
That depends on what you mean by "using Windows authentication". Having an
<authentication mode="Windows" /> element in your web.config file is not, in
and of itself, sufficient to make an authenticated user identity end up in
HttpContext.Current.User. See, for example, the IIS anonymous
authentication of the P&P document at
http://msdn.microsoft.com/library/en...SecNetAP05.asp.

Also, if someone needs to ask the question, they generally are unaware that
multiple user identities may be implicated. Are you sure OP merely wants
the user name provided? What if the real intent is to determine why trusted
connections to SQL Server are failing when it is supposed that the
credentials being passed are those of the authenticated user? The
HttpContext user wouldn't help one bit with this...
"Raterus" <ra*****@spam.org> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"HttpContext.Current.User" WILL contain the identity you want if you are
using windows authentication.

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
There are three identities that may be of interest:
HttpContext.Current.User, WindowsIdentity.GetCurrent(), and
Thread.CurrentPrincipal. Depending on the exact details of your
authentication and impersonation scheme, one or more of these may contain
the identity you want. See
http://msdn.microsoft.com/library/en...SecNetAP05.asp for
details.

HTH,
Nicole
"Vik" <viktorum@==hotmail.com==> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
An ASP.NET page uses Windows authentication method for the user log in.
How
can get the username by code in this page?

Thanks.


Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Derek Martin | last post by:
Using VB.Net, I would like to retrieve the currently logged in user's DN from Active Directory. Alternatively, if, using WindowsIdentity, or something similar, I would like to get the user's full...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
2
by: PHP_Paul | last post by:
Ok, I'm trying to poineer into the wonderful area of PHP/MySQL programming, but I'm having some difficulties. http://www.paulhq.com/php/freepage.html should register, but when anyone fills something...
5
by: olaamussah | last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this...
5
by: dgleeson3 | last post by:
Hello all I have used the LoginForm1 class in a Visual studio 2005 VB application. Its the standard Username, Pasword request for user input. I was hoping to use property procedures to get...
10
by: priyakollu | last post by:
hi guyz! please help me in sorting out error as im unable to find it... my requirement is there will be userid field and password field and "login" button after clicking button certain validations...
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
6
NawazAhmed
by: NawazAhmed | last post by:
Hi, I was trying to get local system's username in my code behind. I tried every almost possible way. Here is the scenario: My project is web based and I don't have a login screen....I need to get...
4
by: icarus | last post by:
global_vars.py has the global variables set_var.py changes one of the values on the global variables (don't close it or terminate) get_var.py retrieves the recently value changed (triggered right...
8
by: tiijnar | last post by:
Hi, To get windows username Im using the following code. public class GetWindowUsername { public String getUser() { String userName = System.getProperty("user.name");...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.