February 7, 2013 at 4:36 am
I'm writing a proc to detect any locked or disabled logins across my server estate.
For windows users I get that info from syslogins
For sql users I get the info from loginproperty
This is fine, but slightly annoying that I can't get this simple info from EITHER sys tables OR a function. I have to write a 2 part procedure for the 2 user types.
Not a problem, just inelegant. Am I missing something or is this just the way it is?
Thank you.
February 7, 2013 at 7:53 am
syslogins is deprecated as of SQL 2005.
Mapping SQL Server 2000 System Tables to SQL Server 2005 System Views
How about this:
SELECT *
FROM sys.server_principals
WHERE is_disabled = 1;
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
February 7, 2013 at 7:56 am
Sorry, forgot the second part of your question:
SELECT name,
is_disabled,
LOGINPROPERTY(name, 'IsLocked') AS is_locked
FROM sys.server_principals
WHERE is_disabled = 1
OR LOGINPROPERTY(name, 'IsLocked') = 1;
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
February 7, 2013 at 10:24 am
Perfect! Thank you! I had a feeling I was missing something.
🙂
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply