0

I tried to access the username DomainControlle I succeeded with the following code

Request.ServerVariables.Get("logon_user");
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent()).Identity.Name;

with web.config

     <authorization>
    <deny users="?"/>
    <allow users ="*" />
  </authorization>
</system.web>

If the configuration code is not in the server, the code will not work

My problem is this. Internal users of the domain are working. Users outside the domain give an error. Unauthorized I want to direct the domain's internal users to the next login page. And users outside the domain can see the login page

Thanks for your help

  • System.Security.Principal.IPrincipal user = System.Web.HttpContext.Current.User; Response.Write(user.Identity.Name); & Response.Write(Request.ServerVariables["AUTH_USER"].ToString()); Both the above method works when i run the page from visual studio. However when i run the page from IIS or any other server, it gives me a blank value Please help me as i cannot begin this project without solving this issue – Samira Yazdani Sep 19 '22 at 08:14
  • https://stackoverflow.com/questions/19676312/how-to-get-user-name-using-windows-authentication-in-asp-net – Samira Yazdani Sep 20 '22 at 06:16

0 Answers0