LOGINPROPERTY – A Good Function To Know

Like many other DBAs I have to deal work with users regularly in reference to their accounts. They usually lock themselves out because they have tried too many times to login. The function LOGINPROPERTY can provide you with some nice to know details about the accounts you have on your server.

You can look up all this information for yourself on BOL here.

The function will take two arguments. Login_name and property_name. The syntax is like so.

LOGINPROPERTY (‘login_name’, ‘property_name’)

Back to the situation where users have locked out their account. You can use this function to see if in fact the account is locked out or maybe something else might be going on with the account.


The return is numerical and follows the normal state. 0 and 1, where zero means no and one means yes. If we get a return of zero as shown in the picture then the account specified is not locked out.

Another handy property of the function is LockoutTime. This returns the date the login was locked out due to exceeding the number of failed login attempts, like so.


You can also check to see when the users password will expire buy using this property. As some of the other property returns this one returns numeric. If zero is returned, then the password is either expired or it will expire on the day of the query. If -1 is returned then the password never expires. And if you get a return of NULL then CHECK_POLICY or CHECK_Expiration is turned OFF for the login or the OS does not support a password policty.

As you can see the LOGINPROPERTY function has a few cool features that may come in handy when you need to work with the accounts on your servers.

You can read more about this function from MSDN here.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s