锁定在SQL Server中Windows身份验证下创建的用户帐户 [英] Locking User account created under Windows Authentication in SQL Server
问题描述
根据我的项目要求,我需要在SQL Server中锁定用户(这是使用Windows身份验证创建的).有什么办法吗?
As per my project requirement i need to lock a user in SQL Server(Which is created using Windows Authentication). Is there any way to do this?
例如:对于SQL登录,如果尝试使用错误的密码登录超过3或4次,则该帐户将被锁定.用户无法使用该用户名登录SQL Server.我想使用在Windows身份验证下创建的用户检查此问题
For example: For a SQL login if you try to login using wrong Password more than 3 or 4 attempts, then that account gets locked out. User cannot login to SQL Server using this username. I want to check this using Users created under windows authenntication
感谢您的帮助
桑托什
推荐答案
您需要将两件事分开:
-
在服务器级别上,您拥有具有登录名的用户-这使他们完全可以连接到该SQL Server.您可以使用以下方式禁用登录:
on a server-level, you have users that have a login - this gives them the ability to connect to that SQL Server at all. You can disable a login using:
ALTER LOGIN (name) DISABLE
这样做会阻止用户一起登录数据库服务器-他(或她)无法再访问该数据库服务器上的任何内容
Doing so prevents that user from logging into the database server alltogether - he (or she) cannot access anything on that database server anymore
在每个数据库级别的 上,可以授予这些登录名对数据库的访问权限-通过创建用户(基于该登录名)来完成该数据库,并为该用户分配某些权限.您不能真正禁用数据库中的用户-您只需要删除该用户
on a per-database level, those logins might be granted access to the database - this is done by creating a user (based on that login) for that database, and assigning that user certain permissions. You can't really disable a user in a database - you just have to drop that user
USE (database)
DROP USER (name)
您始终可以使用该数据库中的登录名重新创建该用户
You can always re-create that user from his login in that database using
USE (database)
CREATE USER (name) WITH LOGIN = (login name)
这篇关于锁定在SQL Server中Windows身份验证下创建的用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!