Solved

How to get current user's name?

Posted on 2014-12-20
7
295 Views
Last Modified: 2014-12-21
Hi, I'm using vs2012, C# and asp.net.
why I'm getting"" with this User.Identity.Name; in my code in my C# program. I was hoping to be able to get user id/name of their window's login.  How can I get a user's name/credential whey they are visiting my web page?

Thank you.
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40511363
You can only do that if you have a 'login' for your pages.  Normal visitors that do not have to login do not leave any personal info that you can get.
0
 
LVL 12

Expert Comment

by:Ammar Gaffar
ID: 40511366
If your asp.net is internet based (Hosted in Internet and visitors don't have to login to access it) then you can't, but if your asp.net application is intranet based (Hosted inside your company and using your company AD - Windows Authentication) then you can.
0
 

Author Comment

by:lapucca
ID: 40511369
This will be an Intranet.  I'm still developing it and is running from my VS2012 on my PC.  Why am I just getting ""?  How can I get my id /name to display?  I am logon to our company network VPN using Cisco Anyconnect right now.  
Thank you.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 81

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 200 total points
ID: 40511375
in your authorization and authentication in IIS are you using windows authenticaton
0
 

Author Comment

by:lapucca
ID: 40511377
I will set it up in IIS to use Windows authentication.  However, I'm still developing the program and right now it's just running on my local PC from VS2012.  But still, shouldn't it display the name?
0
 
LVL 12

Accepted Solution

by:
Ammar Gaffar earned 300 total points
ID: 40511404
How you are expecting to have user identity information without authentication?

Unless you setup your IIS to use Windows Authentication and configure your asp.net application to use Windows Authentication mode and login using your windows credentials you will not be able to read user identity information.
0
 

Author Closing Comment

by:lapucca
ID: 40511861
Okay, that makes sense.  I'll see if that works when I set it up in our IIS server.    Thank you.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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