Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Loop through all Logins to find Locked logins?

$
0
0

What T-SQL code could I use that would iterate through all Logins on an instance and identify SQL Server Authenticated logins that are locked? I know how to determine if a given Login is locked, e.g.

declare @login sysname

set @login = 'LoginOfInterest'

select LOGINPROPERTY(@login, 'IsLocked') as islocked;

But would like to execute this in a loop, daily, to pre-identify any Locked logins before any app owners report a Login is locked and should be unlocked. Sure this could be done with PowerShell--feel free to include that code if you'd like. But I'd specifically like to do this using T-SQL.

Thanks in advance.






Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>