Get sql user password expire details

SELECT

       name AS 'LoginName'

       ,LOGINPROPERTY(name, 'BadPasswordCount') AS 'BadPasswordCount'

       ,LOGINPROPERTY(name, 'BadPasswordTime') AS 'BadPasswordTime'

       ,LOGINPROPERTY(name, 'DaysUntilExpiration') AS 'DaysUntilExpiration'

       ,LOGINPROPERTY(name, 'DefaultDatabase') AS 'DefaultDatabase'

       ,LOGINPROPERTY(name, 'DefaultLanguage') AS 'DefaultLanguage'

       ,LOGINPROPERTY(name, 'HistoryLength') AS 'HistoryLength'

       ,LOGINPROPERTY(name, 'IsExpired') AS 'IsExpired'

       ,LOGINPROPERTY(name, 'IsLocked') AS 'IsLocked'

       ,LOGINPROPERTY(name, 'IsMustChange') AS 'IsMustChange'

       ,LOGINPROPERTY(name, 'LockoutTime') AS 'LockoutTime'

       ,LOGINPROPERTY(name, 'PasswordHash') AS 'PasswordHash'

       ,LOGINPROPERTY(name, 'PasswordLastSetTime') AS 'PasswordLastSetTime'

       ,LOGINPROPERTY(name, 'PasswordHashAlgorithm') AS 'PasswordHashAlgorithm'

       ,DATEADD(dd,CONVERT(int, LOGINPROPERTY (name, 'DaysUntilExpiration')),CONVERT(datetime,LOGINPROPERTY(name,'PasswordLastSetTime'))) AS 'PasswordExpiration'

       ,is_policy_checked AS 'IsPolicyChecked' 

FROM

       sys.sql_logins

WHERE

       is_expiration_checked = 1

ORDER BY

       name


Comments

Post a Comment

Hi User,
Thanks for visiting My Blog and please provide your valuable feedback and subscribe for more updates. Please don't post any spam content or comments.
Thank You

Popular Posts

Failed to execute the package or element. Build errors were encountered

Restore of database 'DataBase_Name' failed. (Microsoft.SqlServer.Management.RelationalEngineTasks)

Get List of logins on SQL Server instance