ASP.Net Membership.DeleteUser [英] ASP.Net Membership.DeleteUser

查看:169
本文介绍了ASP.Net Membership.DeleteUser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在测试中,我用一个数据库用户是一个很大的人Jefe。在生产中,他只有执行。

In testing, the user on a db i've used was a big jefe. In production, he only has Execute.

当我打电话,

Membership.DeleteUser(user)

在测试中,它的工作。
我尝试在生产同样的,我也得到这样的:

In testing, it worked. I try the same in production, and I get this:

DELETE语句冲突与参考约束
  FK__aspnet_Us__UserI__37703C52。冲突发生于数据库
  测试,表dbo.aspnet_UsersInRoles,列用户ID。

The DELETE statement conflicted with the REFERENCE constraint "FK__aspnet_Us__UserI__37703C52". The conflict occurred in database "Testing", table "dbo.aspnet_UsersInRoles", column 'UserId'.

在我seargles(在谷歌搜索),我碰到这个链接来了
那里的家伙说的话,

In my seargles (searches on Google), I came across this link where the dude was saying,

错误:DELETE语句冲突
  与参考约束
  FK__aspnet_Me__UserI__15502E78。该
  冲突发生于数据库
  YourDBName,表
  dbo.aspnet_Membership,列
  用户ID。

Error: The DELETE statement conflicted with the REFERENCE constraint "FK__aspnet_Me__UserI__15502E78". The conflict occurred in database "YourDBName", table "dbo.aspnet_Membership", column 'UserId'.

我花了一段时间才能找到解决
  这种跨多个站点和选项
  作为错误和可能的解决办法
  都相当具有误导性。事实证明,在
  至少在我的情况下,这是一个问题
  与会员权限
  数据库。我使用的用户
  连接得以进入查看
  数据库中的成员资格的详细信息
  本身,而是作为部分
  aspnet_Users_DeleteUser存储
  过程它从选择
  sysobjects表。会员资格
  连接用户显然没有
  有足够的权限这样做
  选择让整体删除失败。

Took me a while to find a solution to this across multiple sites and options as the error and possible solutions were rather misleading. Turns out, at least in my case, it was a problem with permissions on the membership database. The user I'm using to connect had access to view the membership details within the database itself, but as part of the aspnet_Users_DeleteUser stored procedure it selects from the sysobjects table. The membership connection user apparently did not have sufficient rights to do that select so the overall delete failed.

我的修复是将用户添加到
  该aspnet_Membership_FullAccess作用
  为会员数据库。

The fix for me was to add the user to the aspnet_Membership_FullAccess role for the membership database.

但是,当我这样做,它没有工作。人对如何处理这个任何想法?

But when I did that it didn't work. Anyone have any ideas on how to deal with this?

推荐答案

一点点检查,我发现这个问题后,该线路aspnet_Users_DeleteUser存储过程:

After a little inspection I found the issue is this line in the aspnet_Users_DeleteUser stored procedure:

IF ((@TablesToDeleteFrom & 1) <> 0 AND
    (EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_aspnet_MembershipUsers') AND (type = 'V'))))

有3其他类似线等3个表。问题是,如果执行存储过程,用户不必访问vw_aspnet_MembershipUsers从sysobjects中选择时,它会转不起来。我很好奇,想知道为什么整个EXISTS语句是必需的。

There are 3 other similar lines for 3 other tables. The issue is that if the user executing the stored proc doesn't have access to vw_aspnet_MembershipUsers it won't turn up when selecting from sysobjects. I'm curious to know why that whole EXISTS statement is necessary.

无论如何,下面的讨论中,<一href=\"http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.sqlserver.security&tid=f6f57505-7e3f-4a95-97bf-38cb6d86780e&cat=en_US_a36f2156-9287-4116-9521-b0c8ee543ba8&lang=en&cr=US&sloc=&p=1\">Access以系统对象查看用户表,而无需直接在SQL Server安全性访问用户表,有答案。通过对问题的看法授予VIEW DEFINITION,该声明EXISTS现在会成功,你没有给予不必要的,多余的或过度的权限应用程序的连接字符串中的用户。

Regardless, the following discussion, "Access to sysobjects to view user tables without having access to the user tables directly in SQL Server Security", has the answer. By granting "VIEW DEFINITION" on the views in question, the EXISTS statements will now succeed and you don't have to grant unneeded, unwanted, or excessive permissions to the user in your application's connection string.

这篇关于ASP.Net Membership.DeleteUser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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