I have used the below code to retrieve the Windows user id of the system.
The code works well in my machine but when I deployed in Server it's not working as expected.
string[] authenticatedUserName;
System.Security.Principal.IPrincipal User;
User = System.Web.HttpContext.Current.User;
if (User.Identity.IsAuthenticated)
{
authenticatedUserName = User.Identity.Name.Split('\\');
string userName = authenticatedUserName[1].ToString();
}
Kindly help me to sort this issue
Windows auth only works when client and server are on the same domain, it's probably not working as you're doing it over the internet.
Hi AidyF
Thanks for your response.
I am working on the same domain and it's a intranet not internet.
But still there is a problem to read the windows user id.
Do the usual checks that anonymous access isn't enabled.
Hi AidyF,
I tried enabled the anonymous access in IIS but it throws me below error
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
dj_naveen
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
Hi,
According to your error message, I think you should reset you IIS. Please refer to the steps below:
1. Open iis and select the website that is causing the 401
2. Open the “Authentication” property under the “IIS” header
3. Click the “Windows Authentication” item and click “Providers”
4. Move NTLM at top and BAM that's fixed it.
There are some similar threads, please refer to the links below:
http://www.somacon.com/p581.php
Hope it's useful for you.
Best Regards,
Michelle Ge
沒有留言:
張貼留言