我必须用密码保护Windows服务器上的目录。该页面应该显示位于该目录中的文件列表。我没有任何以前的知识(以前只使用过Apache),所以我试着通过谷歌来破解一些东西。(对于那些知道自己在做什么的人来说,我敢肯定这看起来很可笑)
我现在有什么是我得到一个登录弹出,但没有密码是工作。我们在SQL数据库中有一个adminusers表,因此从那里获取user-login或在配置文件中嵌入登录都是可以的。我只需要把文件夹设为密码保护。
这是我现在在我的网页上的内容。
配置文件,该配置文件位于应该受密码保护的文件夹中。<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<authentication mode="Forms">
<credentials passwordFormat="Clear">
<user name="test" password="test" />
</credentials>
</authentication>
<authorization>
<allow users="test" />
<deny users="*" />
</authorization>
</system.web>
<system.webServer>
<directoryBrowse enabled="true" />
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<basicAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</configuration>
希望这是一个简单的问题,提前感谢任何帮助!:)
试试这个:
<configuration>
<system.web>
<authentication mode="Forms">
<credentials passwordFormat="Clear">
<user name="test" password="test" />
</credentials>
</authentication>
<authorization>
<allow users="test" />
<deny users="*" />
</authorization>
</system.web>
<location path="admin">
<system.web>
<authorization>
<allow roles="admin" />
<deny users="*"/>
</authorization>
</system.web>
</location>
<system.webServer>
<directoryBrowse enabled="true" />
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<basicAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</configuration>
你可以像这样加密用户信息:
aspnet_regiis.exe -pef "sectionName" C:PathToYourApplication