App.config连接字符串保护错误 [英] App.config connection string Protection error

查看:301
本文介绍了App.config连接字符串保护错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个我之前遇到的问题;无法找到我如何解决它的参考。

I am running into an issue I had before; can't find my reference on how to solve it.

这里是问题。我们使用下面的代码加密客户端应用程序app.config中的连接字符串部分:

Here is the issue. We encrypt the connection strings section in the app.config for our client application using code below:

        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

问题是我们有一个销售人员离开。旧的笔记本电脑是一个新的销售人员,并在新用户的登录,当它试图这样做,我们得到一个错误。错误是:

The issue is we had a salesperson leave. The old laptop is going to a new salesperson and under the new user's login, when it tries to to do this we get an error. The error is:

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


推荐答案

我发现了一个更优雅的解决方案,在我原来的回答自己。我发现如果我只是登录作为用户谁原本安装的应用程序,并导致配置文件的连接字符串加密,并在commadn提示符下运行.net框架目录并运行

I found a more elegant solution that in my original answer to myself. I found if I just logged in as th euser who orignally installed the application and caused the config file connectionstrings to be encrypted and go to the .net framework directory in a commadn prompt and run

aspnet_regiis -pa "NetFrameworkConfigurationKey" "{domain}\{user}"

它给予其他用户访问RSA加密密钥容器的权限,然后它为其他用户工作。

it gave the other user permission to access the RSA encryption key container and it then works for the other user(s).

只是想添加它在这里,因为我认为我已经在我们的博客上发现了这个问题,但发现它在这里,所以如果我需要再次查找它将在这里。将添加链接到我们的dev博客点在这个线程以及。

Just wanted to add it here as I thought I had blogged this issue on our dev blog but found it here, so in case I need to look it up again it will be here. Will add link to our dev blog point at this thread as well.

这篇关于App.config连接字符串保护错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆