在SQL Server上configuration用户login和存储过程权限

我是一名完成Web应用程序的软件开发人员。 该应用程序在我的SQL Server 2008“SQLServer_1”中使用数据库“DB1”。

我想创build一个有限的用户,该Web应用程序将在其连接string中使用。 这个用户将被允许执行一个存储过程列表,没有别的。 所以用户不应该被允许从列表中执行adhoc SQL或其他存储过程。

我有一个“用户”和“login”之间的一点点混乱,我不知道我应该在哪里创build新的“帐户”。

我应该遵循哪些步骤?

提前致谢。

这一切都归结为范围。 login是服务器级帐户,用户是数据库级帐户。 用户需要被映射到一个login名,所以你将首先创build你的login(同时创build一个方法来validation服务器)。 接下来,在您的应用程序的数据库中,您将创build该用户。 当你这样做的时候,你可以select这个用户代表的是哪个login名。 您将select您之前创build的login名。 然后,您可以将权限分配给您希望能够执行的存储过程。 当然,这样做的方式很简单:

create login [your login name here] from windows; --if the login is a Windows account create login [your login name here] with password 'some super secret password'; --if not a Windwos account use [DB1]; create user [your login name here] for login [your login name here]; grant execute on [your stored procedure here] to [your login name here]; grant execute on [another stored procedure here] to [your login name here]; ... 

我不确定你是什么意思? 如果您不知道“用户”,“login”和“angular色”之间的区别,请按照Microsoft的优秀文档 。 从那里你可以达到任何其他相关的主题,如授予存储过程的执行权限。