加密web.config中的成员资格元素时出现问题

时间:2008-09-25 17:19:02

标签: .net configuration encryption web-config

我正在尝试加密.Net应用程序的Web.Config中的“system.web.membership”元素,以保护Active Directory的用户名和密码。我正在使用aspnet_regiis命令进行加密,并为“pe”选项的值尝试了几个不同的字符串但没有成功。我已成功加密web.config上的“connectionstrings”元素。

Cmd的

C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -pe "connectionStrings" -site MySite -app /MyApp
Encrypting configuration section...
Succeeded!

C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -pe "membership" -site MySite -app /MyApp
Encrypting configuration section...
The configuration section 'membership' was not found.
Failed!

C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -pe "system.web.membership" -site MySite -app /MyApp
Encrypting configuration section...
The configuration section 'system.web.membership' was not found.
Failed!

的Web.Config

<configuration>
    ...
    <system.web>
        ...
        <authentication mode="Forms">
            <forms name=".ADAuthCookie" 
                   timeout="30"/>
        </authentication>
        <authorization>
            <deny users="?"/>
            <allow users="*"/>
        </authorization>
        <membership defaultProvider="MyADMembershipProvider">
            <providers>
                <add name="MyADMembershipProvider"
                     type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
                     connectionStringName="ADConnectionString" 
                     connectionUsername="MyUserName" 
                     connectionPassword="MyPassowrd"/>
            </providers>
        </membership>
        ...
    </system.web>
    ...
</configuration>

那是什么给出的?我错过了什么?

2 个答案:

答案 0 :(得分:8)

配置部分由“system.web/membership”标识,而不是“membership”或“system.web.membership”。

答案 1 :(得分:4)

我知道您的问题已经解决了,但是对于其他人收到此错误消息,似乎只能加密web.config的某些部分。我试图加密我的网络配置中的SMTP设置:

<?xml version="1.0"?>
<configuration>
  <system.net>
    <mailSettings>
      <smtp>
        <network host="myhost" port="25" userName="myusername" password="mypassword" />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

这有效:

aspnet_regiis.exe -pef "system.net/mailSettings/smtp" "path_to_site" -prov "DataProtectionConfigurationProvider"

但这些没有:

aspnet_regiis.exe -pef "system.net/mailSettings" "path_to_site" -prov "DataProtectionConfigurationProvider"

aspnet_regiis.exe -pef "system.net" "path_to_site" -prov "DataProtectionConfigurationProvider"