Getting account 'locked' status in SQL Server

冷暖自知 提交于 2019-12-10 14:56:20

问题


I want to unlock one account in SQL Server. Before unlocking I have to check whether that account is locked or not.

I want to unlock only if the account is locked.

Is there any SQL query or stored procedure to get the "Locked" status of SQL user?


回答1:


Posting Answer on Behalf of Alex K.

SELECT LOGINPROPERTY('loginname', 'IsLocked')




回答2:


Do you mean a login name that has Login: Denied ? If so you can:

SELECT is_disabled from sys.server_principals WHERE name = @loginname


来源:https://stackoverflow.com/questions/2607290/getting-account-locked-status-in-sql-server

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