Locking User account created under Windows Authentication in SQL Server

。_饼干妹妹 提交于 2019-12-25 02:59:25

问题


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?

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

Thanks for the help

Santhosh


回答1:


You need to keep two things apart:

  • 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)
    


来源:https://stackoverflow.com/questions/2605814/locking-user-account-created-under-windows-authentication-in-sql-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!