用户权限错误,当访问"用户实例"从ASP.NET数据库 [英] User permission error when accessing "user instance" database from ASP.NET

查看:287
本文介绍了用户权限错误,当访问"用户实例"从ASP.NET数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器托管csharpindepth.com最近被迁移。

The server hosting csharpindepth.com has recently been migrated.

它的大部分工作正常,但我不能让在用来装勘误数据库,票据等。

Most of it is working fine, but I can't get at the database used to hold errata, notes etc.

相关细节:

  • 在32位Windows Server 2003
  • 在SQL Server的防爆preSS 2005安装
  • 在运行ASP.NET池网络服务帐户
  • 在.NET 3.5
  • 每个人都有完全权限的数据库文件(此刻,只是为了排除这种可能性!)
  • 连接字符串:

  • 32 bit Windows Server 2003
  • SQL Server Express 2005 installed
  • ASP.NET pool running under "NETWORK SERVICE" account
  • .NET 3.5
  • Everyone has full permission to database files (at the moment, just to rule that out!)
  • Connection string:

Data Source=.;AttachDbFilename=|DataDirectory|\WebSiteData.mdf;
Integrated Security=True;User Instance=True

  • 我通过创建连接只是一个新的 WebSiteDataContext (具有上述连接字符串作为其默认的)

  • I'm connecting just by creating a new WebSiteDataContext (which has the above connection string as its default)

    使用从包含文件的目录中运行一个小的测试控制台应用程序,为管理员帐户,使用相同的查询,我可以看到数据库的内容。

    Using a small test console app running from the directory containing the files, as the administrator account, using the same query, I can see the contents of the database.

    在ASP.NET我得到这个异​​常:

    In ASP.NET I'm getting this exception:

    SqlException (0x80131904): User does not have permission to perform this action.
    

    编辑:更多的信息,这里的堆栈跟踪:

    More information, here's the stack trace:

    [SqlException (0x80131904): User does not have permission to perform this action.]
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4844759
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
       System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
       System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +144
       System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
       System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
       System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
       System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +4859187
       System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
       System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +433
       System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
       System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +499
       System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
       System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
       System.Data.SqlClient.SqlConnection.Open() +122
       System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user) +44
       System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() +45
       System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() +20
       System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +57
       System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +35
    

    编辑:我错了大鱼大肉的文件名是正确的 - 更改连接字符串,使其跟一个不同的文件中的的更改错误

    procmon中从来没有显示它触及文件...

    ProcMon never shows it touching the file...

    编辑:另外的怪事 - 重新启动它在本地系统帐户下运行的应用程序池的还是的有问题,这是因为它得到奇!就好像,尽管错误信息,它实际上是试图做一些事情是不可能的(例如使用了错误的路径),而不是仅仅是一个权限问题。

    Further oddities - restarting the application pool with it running under the Local System account still has problems, which is about as odd as it gets! It's as if, despite the error message, it's actually trying to do something impossible (e.g. with the wrong path) rather than just being a permissions issue.

    编辑:更多的信息 - 我刚刚从一个服务作为网络服务,并运行我的小测试控制台应用程序,它是成功的(其中超时初步尝试后)。因此,这不是在用户帐户方面有权限的事情......这是一些关于它所运行的环境...

    More information - I've just run my little test console app from a service as "NETWORK SERVICE" and (after an initial attempt which timed out) it was successful. So it's not a permissions thing in terms of the user account... it's something about the environment in which it runs...

    推荐答案

    请问子实例甚至开始?当一个RANU数据库请求主实例(\在这个例子SQLEX preSS)具有创建一个子的实例,换句话说启动SQLSERVR.EXE过程作为一个用户进程根据用户的凭证运行这要求从.SQLEX $ P $干燥综合征实例RANU连接。在这种情况下,该实例将必须开始为网络服务

    Does the child instance even start? When a RANU database is requested the master instance (.\SQLEXPRESS in this case) has to create a 'child' instance, in other words start the sqlservr.exe process as an user process running under the credentials of the user that requested the RANU connection from the .SQLEXPRESS instance. In this case the instance would have to be started as 'NETWORK SERVICE'.

    要验证,如果孩子实例启动,连接到主实例(\ SQLEX preSS),并检查的 sys.dm_os_child_instances

    To validate if the child instance is started, connect to the master instance (.\SQLEXPRESS) and check sys.dm_os_child_instances:

    SELECT * 
    FROM sys.dm_os_child_instances
    

    如果一个网络服务资子实例启动时,把它的 instance_pipe_name 直连接子实例:

    If an NETWORK SERVICE owned child instance is started, take it's instance_pipe_name and connect straight to the child instance:

    sqlcmd -S np:\\.\pipe\<child pipe name>\tsql\query
    

    在理想情况下,连接了网络服务(例如,从交互式CMD控制台开始作为NEWTORK服务,可能使用at.exe将其计划在未来1分钟)。如果这样的作品,最后一步是尝试使用ordinarry sp_attach_db的附加密度板。

    Ideally, connect as NETWORK SERVICE (eg. from an interactive cmd console started as NEWTORK SERVICE, perhaps using at.exe to schedule it 1 minute in future). If that works, the last step is to try to attach the MDF using ordinarry sp_attach_db.

    这些步骤的想法是不解决问题,但查明故障原因,因为你的错误是有点通用的,......不完全是有益的。

    The idea of these steps is not to solve the issue, but pinpoint the failure cause, since the error you get is kinda generic and ... not exactly helpfull.

    这篇关于用户权限错误,当访问&QUOT;用户实例&QUOT;从ASP.NET数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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