Quantcast
Channel: Sql And Me » system function
Viewing full articles (10 articles)
Browse article index
↧

SQL Functions – LOGINPROPERTY()

$
0
0

The LOGINPROPERTY() SQL function can be used to retrieve policy settings related to logins. It takes two arguments, Login Name and Property Name as below:

LOGINPROPERTY('Login Name','Property Name')

Where, Login Name = SQL Login Name, and

Property Name can be:

1. BadPasswordCount – Number of times and Incorrect password was provided,

2. BadPasswordTime – Last Timestamp when a wrong password was provided,

3. DaysUntilExpiration – Number of days until the password expires,

4. DefaultDatabase – NULL for Windows Users, and Default database name for SQL Logins,

5. DefaultLanguage – Default Language specified while creating the SQL Login, returns NULL for Windows Users,

6. HistoryLength – Number of passwords remembered,

7. IsExpired – 1 = Expired,

8. IsLocked – 1 = Locked,

9. IsMustChange – 1 = Specifies that user must change password at next login,

10. LockoutTime – Returns the time when Login was locked out, due to maximum number of unsuccessful login attempts,

11. PasswordHash – Returns the password hash,

12. PasswordLastSetTime – Timestamp when password was last changed.

– © 2011 – Vishal (http://SqlAndMe.com)

 

SELECT      LOGINPROPERTY('Vishal','badpasswordcount')

            AS 'BadPasswordCount',

            LOGINPROPERTY('Vishal','badpasswordtime')

            AS 'BadPasswordTime',

            LOGINPROPERTY('Vishal','daysuntilexpiration')

            AS 'DaysUntilExpiration',

            LOGINPROPERTY('Vishal','defaultdatabase')

            AS 'DefaultDatabase',

            LOGINPROPERTY('Vishal','iSexpired')

            AS 'IsExpired',

            LOGINPROPERTY('Vishal','iSlocked')

            AS 'IsLocked'

Result Set:

image

For LOGINPROPERTY() to return correct results, CHECK_POLICY and CHECK_EXPIRATION needs to be enabled for the login.

Hope This Helps!

Vishal

If you like this post, do like my Facebook Page -> SqlAndMe
EMail me your questions -> Vishal@SqlAndMe.com
Follow me on Twitter -> @SqlAndMe


Filed under: SQLServer, SQLServer 2005, SQLServer 2008, SQLServer 2008 R2
↧

Viewing full articles (10 articles)
Browse article index

Latest Images

Trending Articles



Latest Images