Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get user name, telephone, email
Message
 
General information
Forum:
ASP.NET
Category:
Active Directory
Miscellaneous
Thread ID:
01672094
Message ID:
01672101
Views:
48
>Hi,
>
>This question is specific to ASP.NET or C#. If a user logs into a PC using his/her Active Directory user ID and password, can my ASP.NET page/app get/find the user name and his/her email? If yes, how?
>
>TIA

I have a small success where if I know the current user account (somedomain\username) I can find email and other values. And I can get the domain name (using C# code). But so far, the username returns the computer/server name and not the currently logged user name. I tried many ways to get the user name. Some of them are:
Environment.UserName;
System.Environment.UserName;
Environment.GetEnvironmentVariable("USERNAME");
But all above return the server name.

To get the domain name is simple:
Environment.UserDomainName;
The web.config has the following settings:
<authentication mode="Windows" /> 
<identity impersonate="false" />     // also tried "true", no difference
Where in the IIS or in the web site it could be set to use the server name as the current user name?

UPDATE. Finally, after a million of tries and various changes in the web.config, and reading tons of threads, I came across a solution. So, now I can get both the user name, domain name, and get the email address from the AD.
I just need to test it on a real user. If I could find one :)
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform