chandu1551
3/2/2018 - 7:02 PM

Authentication in Asp.net Web Forms

Authentication in Asp.net Web Forms

Windows Authentication

 <system.web>
 
    <compilation targetFramework="4.5" debug="true"/>
    <httpRuntime targetFramework="4.5" maxRequestLength="1048576" executionTimeout="3600"/>

    <authentication mode="Windows"/>
	
	 <!--Disable Anonymous Users-->
    <authorization>
      <deny users ="?" />
    </authorization>
	
	 <!--If you want to have the application code executed using the logged in user Identity, Enable Impersonate else app pool identity is used-->
    <identity impersonate="false"/>
	
	<!--Other Setings-->
	<trust level="Full"/>
    <customErrors mode="Off"/>
    <sessionState timeout="120" mode="InProc"/>
    <machineKey decryption="AES" validation="SHA1"/>
	
 </system.web>	
 
 
IIS_IUSRS
IUSR
Everyone
LOCAL SERVICE

 string userNTID = HttpContext.Current.User.Identity.Name;
 
Response.Write("1Application code executed using:");
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name +"<br>");

Response.Write("1Is User Authenticated: ");
Response.Write(User.Identity.IsAuthenticated.ToString() + "<br>");

Response.Write("1Authentication Type: ");
Response.Write(User.Identity.AuthenticationType.ToString() + "<br>");

Response.Write("User Name: ");
Response.Write(User.Identity.Name.ToString() + "<br>");