Iis – How to simulate htaccess for auth with IIS without having access to the server config

authenticationconfigurationiis

I need to put a website on windows server IIS, i'd like to use basic authentification like i'd do with Apache, with the .htaccess / .htpasswd

I read here & there, that i could do this through the admin tabs of IIS, but i'm not the administrator, and i only have ftp access.
It seems to be a 'web.config' file where i could do this.

Is there a way to set up such things within a config file ?

I'm not used to work with IIS…

Best Answer

This depends. Typically this isn't delegated the same way as Apache does. However if you are looking to password protect your site and you're using ASP.NET, you can do this with the authentication and authorization elements. This is set in web.config. To research and get up to speed, do a google/bing search for "authentication authorization asp.net".

Additionally, if you are using IIS7, then you can set this in <system.webServer> which will apply to all file types.

If you need to change the authentication type from windows to basic, that's something different again, and will require the server administrator or a control panel to help with that, but I suspect that it's just password protection that you need.

Here's an example that may be what you need:

Assuming that you're using asp.net and you want to password protect your site, create a file called web.config in the root of the site and place the following in it:

<configuration>
  <system.web>
    <authentication mode="Windows">
    <authorization>
      <allow users="?" />
    </authorization>
  </system.web>
</configuration>
Related Topic