php - MySqlConnection 打开失败,即使模拟也拒绝访问

标签 php .net mysql com impersonation

我的类库无法使用 MySql .net 连接器建立 mysql 连接。如果我通过使用类库的命令行控制台应用程序运行它,它可以连接。但当我使用 PHP COM 加载/运行 .net 程序集时,它失败了。类库具有模拟用户的模拟代码。为了进行测试,我模拟了我自己的用户帐户。

查看堆栈跟踪。访问 C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config 需要什么凭据? 在 .NET 程序集中模拟的正确代码是什么(它也是 COM 感知的)?

2011/08/17 10:11:52.653 AM - The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception.
2011/08/17 10:11:52.653 AM -    at System.Transactions.Transaction.get_Current()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at MineForums.Miner.Process(Int32 forumId, String mineDirectory)
2011/08/17 10:11:52.653 AM - Configuration system failed to initialize
2011/08/17 10:11:52.653 AM -    at System.Transactions.Transaction.get_Current()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at MineForums.Miner.Process(Int32 forumId, String mineDirectory)
2011/08/17 10:11:52.965 AM - System.TypeInitializationException: The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Access is denied.
 (C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config) ---> System.Security.SecurityException: Access is denied.

   at System.Security.Principal.WindowsImpersonationContext.Undo()
   at System.Security.Principal.WindowsImpersonationContext.Dispose(Boolean disposing)
   at System.Security.Principal.WindowsImpersonationContext.Dispose()
   at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()
The Zone of the assembly that failed was:
MyComputer
   --- End of inner exception stack trace ---
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
   at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   --- End of inner exception stack trace ---
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
   at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
   at System.Diagnostics.DiagnosticsConfiguration.Initialize()
   at System.Diagnostics.DiagnosticsConfiguration.get_Sources()
   at System.Diagnostics.TraceSource.Initialize()
   at System.Diagnostics.TraceSource.get_Switch()
   at System.Transactions.Diagnostics.DiagnosticTrace..cctor()
   --- End of inner exception stack trace ---
   at System.Transactions.Transaction.get_Current()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at MineForums.Miner.Process(Int32 forumId, String mineDirectory)

最佳答案

在命令提示符下

cacls "C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config" 将显示谁/什么对该文件具有权限。您还想验证文件上方所有目录的访问权限。

关于php - MySqlConnection 打开失败,即使模拟也拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7097088/

相关文章:

php - 使用Doctrine作为水合器的Zend Framework 2形式问题

php - 如何处理 PHP 中的 fatal error ?

c# - 如何停止 WPF 控件(使用扩展器)在 ItemsControl 中扩展到父级的高度

c# - 应用程序中包含的数据库

php - 使用 php 将动态 LI 发送到 mySQL 表中

php - 在文件中搜索内容并使用 PHP 更改内容的最佳(最有效)方法是什么?

php - 引用 - 这个错误在 PHP 中是什么意思?

没有 new 的 C# 内部结构

mysql - Python 脚本数据库连接作为池不起作用,但简单连接正常

mysql - 按年份连接 SQL 结果(年份、品牌、型号)