我遇到了以前的问题;找不到我如何解决它的参考。
这是问题所在。我们使用以下代码为客户端应用程序加密app.config中的连接字符串部分:
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
If config.ConnectionStrings.SectionInformation.IsProtected = False Then
config.ConnectionStrings.SectionInformation.ProtectSection(Nothing)
' We must save the changes to the configuration file.'
config.Save(ConfigurationSaveMode.Modified, True)
End If
问题是我们有一个营业员休假。旧的笔记本电脑将转向新的销售人员并在新用户的登录下,当它尝试执行此操作时,我们会收到错误消息。错误是:
Unhandled Exception: System.Configuration.ConfigurationErrorsException:
An error occurred executing the configuration section handler for connectionStrings. ---> System.Configuration.ConfigurationErrorsException: Failed to encrypt the section 'connectionStrings' using provider 'RsaProtectedConfigurationProvider'.
Error message from the provider: Object already exists.
---> System.Security.Cryptography.CryptographicException: Object already exists
http://blogs.msdn.com/mosharaf/archive/2005/11/17/protectedConfiguration.aspx#1657603
复制粘贴:D
2007年2月12日,星期一,上午12:15,Naica
re:使用受保护的配置加密配置文件
以下列出了我在PC上加密两个部分然后将其部署到WebServer的所有步骤。也许它会帮助某人......:
aspnet_regiis -pc "DataProtectionConfigurationProviderKeys" -exp
<add name="DataProtectionConfigurationProvider"
type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
keyContainerName="DataProtectionConfigurationProviderKeys"
useMachineContainer="true" />
千万不要错过上面的<clear />
!多次使用加密/解密时很重要<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
aspnet_regiis -pdf "connectionStrings" "c:\Bla\Bla\Bla"
aspnet_regiis -pdf "system.web/membership" "c:\Bla\Bla\Bla"
aspnet_regiis -pz "DataProtectionConfigurationProviderKeys"
aspnet_regiis -px "DataProtectionConfigurationProviderKeys" \temp\mykeyfile.xml -pri
aspnet_regiis -pi "DataProtectionConfigurationProviderKeys" \temp\mykeyfile.xml
在IIS中查看ASP.NET用户或使用:
aspnet_regiis -pa "DataProtectionConfigurationProviderKeys" "DOMAIN\User"
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name
我找到了一个更优雅的解决方案,在我对自己的原始回答中。我发现如果我只是以root用户身份登录,并且安装了应用程序并导致配置文件连接字符串被加密并在commadn提示符下转到.net framework目录并运行
aspnet_regiis -pr "DataProtectionConfigurationProviderKeys" "Domain\User"
它授予其他用户访问RSA加密密钥容器的权限,然后它适用于其他用户。
只是想在这里添加它,因为我认为我在我们的开发博客上发布了这个问题,但是在这里找到它,所以如果我需要再次查找它将会在这里。将在此主题中添加指向我们的开发博客点的链接。
所以我确实让它运转了。
但所有这一切都让它为这个用户工作。
现在我需要知道我要做些什么来更改代码以保护该部分,以便PC上的多个用户可以使用该应用程序。我来的是虚拟PC(明天下周三到WDW度假之后)!
任何有助于指导我正确方向的建议,因为我对这种RSA加密类型的东西不是很有经验。
听起来像权限问题。有问题的(新)用户对app.config文件有写权限吗?以前的用户是否可能掩盖了此问题的本地管理员或超级用户?