对对象“sysobjects”、数据库“mssqlsystemresource”、架构“sys”的 SELECT 权限被拒绝
设置:SQL Server 2005 和 SQL Server 2005 DotNetNuke 05.01.02。
首先,我尝试安装一个 DNN 模块,该模块的 SQL 脚本中包含“select * from dbo.sysobjects”。失败并出现以下错误:
SELECT 权限被拒绝 对象“sysobjects”,数据库 “mssqlsystemresource”,架构“sys”。
我通过 SQL Server Management Studio 作为 DNN 用户帐户登录数据库,当我尝试在 sysobjects 视图上执行 SELECT 时,出现相同的错误。
我尝试向 DNN 用户帐户授予对该视图的显式 SELECT 权限。当我通过“安全”-> 进行检查时用户-> DNN用户登录->右键单击->属性-> Securables 并向下滚动以找到 sys.sysobjects 视图,它表示此用户帐户对 dbo 具有显式权限:并且选中了 SELECT 复选框。但我仍然无法作为该 DNN 用户帐户在 sysobjects 视图上执行选择。
我做错了什么?我怎样才能做到这一点?
SETUP: SQL Server 2005 & DotNetNuke 05.01.02.
This started with me trying to install a DNN Module that had "select * from dbo.sysobjects" in it's SQL scripts. That failed with the following error:
The SELECT permission was denied on
the object 'sysobjects', database
'mssqlsystemresource', schema 'sys'.
I logged into the database via SQL Server Management Studio as the DNN user account, and I get the same error when I try and perform a SELECT on the sysobjects view.
I tried to grant the DNN user account explicit SELECT permission to that view. When I check it by going to Security -> Users -> DNNUserLogin-> right-click -> Properties -> Securables and scroll down to find the sys.sysobjects view, it says this user account has explicit permissions for dbo: And the SELECT checkbox is checked. But I still cannot perform a select on the sysobjects view as that DNN user account.
What am I doing wrong? How can I make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
这也是具有拒绝权限的用户的问题;在我匆忙授予权限时,我基本上给了用户一切。否认正在扼杀它。因此,一旦我删除了这些权限,它就起作用了。
This was a problem with the user having deny privileges as well; in my haste to grant permissions I basically gave the user everything. And deny was killing it. So as soon as I removed those permissions it worked.
我遇到了同样的错误,并通过删除数据库用户的数据库角色 db_denydatawriter 和 db_denydatreader 来解决。为此,请在登录时选择适当的数据库用户>>属性>>用户映射>>找到DB并选择它>>取消选中提到的数据库用户角色。就是这样 !!
I had the same error and SOLVED by removing the DB roles
db_denydatawriter
anddb_denydatreader
of the DB user. For that, select the appropriate DB user on logins >> properties >> user mappings >> find out DB and select it >> uncheck the mentioned Db user roles. Thats it !!在良好的服务器上执行此代码,这将为您提供 PUBLIC 角色的完整权限。复制输出并粘贴到存在问题的服务器。执行。尝试再次登录。它解决了我们的问题。
Execute this code on a good server which will provide you the complete rights for PUBLIC role. Copy the output and paste to the server with the issue. Execute. Try logging in again. It fixed our problem.
因为出错的可能性有很多。这是另一种值得关注的可能性。我遇到了一些问题,我在数据库上设置了自己的角色。 (例如,“管理员”、“经理”、“数据输入”、“客户”,每个都有自己的限制)唯一可以使用它的是“经理”角色或以上角色 - 因为他们也是设置的作为系统管理员,因为他们将用户添加到数据库(并且他们高度信任)。此外,添加的用户是 Windows 域用户 - 使用其域凭据。 (有权访问数据库的每个人都必须在我们的域中,但并非域中的每个人都有权访问数据库 - 并且只有少数人有权更改它。)
无论如何,这个工作系统突然停止工作,我收到与上述类似的错误消息。我最终解决的方法是检查该数据库中“公共”角色的所有权限,并将这些权限添加到我创建的所有角色中。我知道每个人都应该处于“公共”角色,即使您无法添加他们(或者更确切地说,您可以“添加”他们,但他们不会“保持添加”)。
因此,在“SQL Server Management Studio”中,我进入了应用程序的数据库,换句话说(我的本地化名称在 <> 括号内模糊):“ (SQL Server - sa)”\Databases\\Security\Roles\ Database Roles\public”。右键单击“public”并选择“属性”。在“Database Role Properties - public”对话框中,选择“Securables”页面。浏览列表,对于列表中的每个元素,例如,有一个标量函数“[dbo].[fn_diagramobjects]”,“public”角色具有“执行”权限。 ,我添加了以下行:
对“Securables”列表中的所有元素执行此操作后,我将其封装在游标上的 while 循环中,选择角色表中的所有角色,这显式授予了所有权限。那时,我的所有用户都再次工作了(即使在我删除了他们的“sysadmin”访问权限之后——作为临时措施,我弄清楚发生了什么。)
我确信。有一种更好(更优雅)的方法来做到这一点,通过对数据库对象进行某种查询并选择公共角色,但是经过大约半个小时的调查,我没有弄清楚,所以我只是做了这是蛮力方法。如果它对其他人有帮助,这是我的代码。
一旦进入系统,我只需要“Exec GrantAccess”即可使其工作。 (当然,我有一个表 [RoleList],其中包含一个“AppRoleName”字段,其中包含数据库角色的名称。
因此,谜团仍然存在:为什么我的所有用户都失去了他们的“公共”角色以及为什么我不能给出这是 SQL Server 2008 R2 更新的一部分吗?是因为我运行了另一个脚本来删除每个用户并将其添加回来,以便刷新他们与域的连接吗?
您可能应该检查系统上的“公共”角色,以确保没有任何遗漏或错误,这里您的系统总是可能有一些不同。
最后一个警告:在运行此命令之前,
Since there are so many possibilities for what might be wrong. Here's another possibility to look at. I ran into something where I had set up my own roles on a database. (For instance, "Administrator", "Manager", "DataEntry", "Customer", each with their own kinds of limitations) The only ones who could use it were "Manager" role or above--because they were also set up as sysadmin because they were adding users to the database (and they were highly trusted). Also, the users that were being added were Windows Domain users--using their domain credentials. (Everyone with access to the database had to be on our domain, but not everyone on the domain had access to the database--and only a few of them had access to change it.)
Anyway, this working system suddenly stopped working and I was getting error messages similar to the above. What I ended up doing that solved it was to go through all the permissions for the "public" role in that database and add those permissions to all of the roles that I had created. I know that everyone is supposed to be in the "public" role even though you can't add them (or rather, you can "add" them, but they won't "stay added").
So, in "SQL Server Management Studio", I went into my application's database, in other words (my localized names are obscured within <> brackets): " (SQL Server - sa)"\Databases\\Security\Roles\Database Roles\public". Right-click on "public" and select "Properties". In the "Database Role Properties - public" dialog, select the "Securables" page. Go through the list and for each element in the list, come up with an SQL "Grant" statement to grant exactly that permission to another role. So, for instance, there is a scalar function "[dbo].[fn_diagramobjects]" on which the "public" role has "Execute" privilege. So, I added the following line:
Once I had done this for all the elements in the "Securables" list, I wrapped that up in a while loop on a cursor selecting through all the roles in my roles table. This explicitly granted all the permissions of the "public" role to my database roles. At that point, all my users were working again (even after I removed their "sysadmin" access--done as a temporary measure while I figured out what happened.)
I'm sure there's a better (more elegant) way to do this by doing some kind of a query on the database objects and selecting on the public role, but after about half and hour of investigating, I wasn't figuring it out, so I just did it the brute-force method. In case it helps someone else, here's my code.
Once that is in the system, I just needed to "Exec GrantAccess" to make it work. (Of course, I have a table [RoleList] which contains a "AppRoleName" field that contains the names of the database roles.
So, the mystery remains: why did all my users lose their "public" role and why could I not give it back to them? Was this part of an update to SQL Server 2008 R2? Was it because I ran another script to delete each user and add them back so to refresh their connection with the domain? Well, this solves the issue for now.
One last warning: you probably should check the "public" role on your system before running this to make sure there isn't something missing or wrong, here. It's always possible something is different about your system.
Hope this helps someone else.
看起来有人可能已经撤销了 sys.configurations 上的权限
为了公共角色。或者拒绝该特定用户访问该视图。或者,在从
sys.configurations
表中删除公共角色后创建了用户。向公共用户 sys.configurations 对象提供 SELECT 权限。
It looks like someone might have revoked the permissions on
sys.configurations
for the public role. Or denied access to this view to this particular user. Or the user has been created after the public role was removed from the
sys.configurations
tables.Provide
SELECT
permission to public usersys.configurations
object.我通过引用安全登录下登录用户的属性解决了这个问题。然后转到用户映射并选择数据库,然后检查 db_datareader 和 db_dataweriter 选项。
I solved this by referring properties of login user under the security, logins. then go to User Mapping and select the database then check db_datareader and db_dataweriter options.
就我而言,我的网站托管在共享主机上,并且存在资源过度使用甚至与我的数据库无关的情况,因此我的数据库被锁定,托管面板是 Plesk
In my case, my site was hosted on shared hosting and there was a resource over usage not even relating to my database, thus my database was locked down, the hosting panel was Plesk
就我而言,只需授予用户对数据库的权限即可解决此问题。
所以右键单击数据库->单击属性-> [左侧菜单]点击权限->并向下滚动到备份数据库 ->勾选“授予”
In my case, simply giving the user permissions on the database fixed it.
So Right click on the database -> Click Properties -> [left hand menu] Click Permissions -> and scroll down to Backup database -> Tick "Grant"