Login_AlterLogin()

Examples


The Login_AlterLogin() function is used to change the characteristics of a SQL login.

Syntax

Login_AlterLogin(data_source, user_ID, login_options, return_code {,new_password} {,previous_password})

Parameters

data_source – A string specifying the data source to use to connect to the SQL server.

user_ID – A string specifying the ID of the user login that is being altered.

login_options – A long integer that specifying the option settings to use for the SQL login. This is a bitmask value. The following table lists the options and their corresponding hexadecimal values:

[spacer]

Option

Value

Enforce password policy

0x01000000

Enforce password expiration

0x02000000

Change password on next login

0x00800000


These options apply only to logins for SQL Server 2005. They are ignored for SQL Server 2000.


return_code – A returned long integer indicating the results of the command. This is a bitmask value. The following table lists the values that can be returned.

[spacer]

Return code

Value

Successful login

0x00000001

Failed login

0x00000002

Create or alter failed

0x00000004

Create or alter succeeded

0x00000008

Password expired

0x00010000

Exception caught

0x00020000

Login locked

0x00040000

Password too short

0x00100000

Password too long

0x00200000

Password not complex

0x00400000


new_password – An optional string that specifies the new password to use for the SQL login.

previous_password – An optional string that specifies the previous password for the login. This parameter is used when a user is changing their own password. If this parameter is supplied, the login_options parameter is ignored.

Return value

An integer specifying the status of the operation. The following table lists the constants that correspond to the values that can be returned.

[spacer]

Constant

Description

STATUS_SUCCESS

Operation was successful.

STATUS_MEMORY_ERROR

A memory error occurred.

STATUS_TOO_MANY_CONNECTIONS

Too many SQL connection in use to perform the operation.

STATUS_DATASOURCE_REJ

The SQL server rejected the operation.

STATUS_UNABLE_TO_CONNECT

Unable to connect to the data source.

STATUS_LOGIN_LOCKED

Login is locked.

STATUS_LOGIN_PASSWORD_HISTORY

Password supplied violates password history.

STATUS_LOGIN_PASSWORD_SHORT

Password specified is too short.

STATUS_LOGIN_PASSWORD_LONG

Password specified is too long.

STATUS_LOGIN_PASSWORD_SIMPLE

Password specified is too simple.

STATUS_LOGIN_PASSWORD_UNKNOWN

Password is unknown.

STATUS_LOGIN_PASSWORD_POLICY

The password specified violates the password policy.

STATUS_LOGIN_INVALID

The login is not valid to perform the operation.

STATUS_INVALID_PERMISSIONS

The login had invalid permissions to perform the operation.

STATUS_NOT_LOGGED_IN

No user is logged in to perform the operation.


Comments

A SQL administrator can use this command to change any specific user’s password or login options. A user can use this command to change only their own password.


Documentation Feedback