Retrieve User Name in C#.net

G

Guest

Hi All,

I am trying to find how to retrieve the user name
using .Net. I know how to retrieve the user login using
HttpContext.Current.User.Identity.Name but I ned to
retrieve the name and not the login.

Thanks In Advance.
 
B

Brock Allen

There's no API in ASP.NET to do this for you. You'll have to take the login
you have and query whatever the authentication source is to determine that
info.
 
P

Paul Clement

¤ Hi All,
¤
¤ I am trying to find how to retrieve the user name
¤ using .Net. I know how to retrieve the user login using
¤ HttpContext.Current.User.Identity.Name but I ned to
¤ retrieve the name and not the login.

I don't have a C# example but the below should be easy to convert. The System.DirectoryServices
namespace is required:

Dim DomainUser As String =
System.Security.Principal.WindowsIdentity.GetCurrent.Name.Replace("\", "/")
Dim ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://" & DomainUser)

Dim FullName As String = ADEntry.Properties("FullName").Value


Paul
~~~~
Microsoft MVP (Visual Basic)
 
J

Jean

I used the same thing but insted of user name I get "ASP.NET Machine Account
" Does any one knows Why??????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top