Solved

ASP.NET C# How to get the windows login name or domain username?

Posted on 2011-02-14
10
1,349 Views
Last Modified: 2012-05-11
How to get the windows login name or domain username?
0
Comment
Question by:mawingho
10 Comments
 
LVL 6

Accepted Solution

by:
PJBX earned 72 total points
ID: 34893940
Have you tried: Context.User.Identity.Name


0
 
LVL 8

Assisted Solution

by:PagodNaUtak
PagodNaUtak earned 72 total points
ID: 34893955
Try the below code
string networklogon = null;
Array arrnetworklogon = null;
string loginname = null;

//get network user data
networklogon = Request.ServerVariables("LOGON_USER");
arrnetworklogon = Strings.Split(networklogon, "\\");
loginname = arrnetworklogon(Information.UBound(arrnetworklogon));

Open in new window

0
 
LVL 5

Assisted Solution

by:aternex
aternex earned 72 total points
ID: 34894011
As long as the asp.net site is running windows authentication user.identity.name has always worked for me. This would return the username in the form of Domain\User
0
 
LVL 9

Assisted Solution

by:s_chilkury
s_chilkury earned 71 total points
ID: 34894021
this.Context.User.Identity.Name;

will server the purpose.

Check the following:
http://weblogs.asp.net/jpinquie/archive/2008/02/06/how-to-get-domain-user-information-from-active-directory-in-c.aspx
0
 

Author Comment

by:mawingho
ID: 34894044
It doesn't work
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:mawingho
ID: 34894053
How to do windows authentication ???
am I need to add any code or change any setting?
I am using Microsoft Visual Web Developer 2010 Express.
and creating website
0
 
LVL 10

Assisted Solution

by:Asim Nazir
Asim Nazir earned 71 total points
ID: 34894342
0
 
LVL 11

Assisted Solution

by:MajorBigDeal
MajorBigDeal earned 71 total points
ID: 34894355
Try this:

Inside the webpage:

Validate(HttpContext.Current);


In your other class (if you have one):

public void Validate(HttpContext currentContext)
{
   string name = currentContext.Request.LogonUserIdentity.Name;
   string isAuth = currentContext.Request.IsAuthenticated;
}
0
 
LVL 2

Assisted Solution

by:HSIHSA
HSIHSA earned 71 total points
ID: 34894430
0
 

Author Closing Comment

by:mawingho
ID: 34894843
thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now