The Login_LogIntoDataSourceEx() function logs the user into the named data source using the specified user ID and password. It also supports the additional password features available for SQL Server 2005.
Login_LogIntoDataSourceEx(data_source, user_ID, password, return_code {,previous_password})
• data_source – A string specifying the data source to log into.
• user_ID – A string specifying the user ID to use when logging into the data source.
• password – A string specifying the password to use when logging into the named data source.
• 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.
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 |
• previous_password – An optional string parameter that is used when the current user is required to change their password when initially logging into the data source. This option is supported only on SQL Server 2005.
An integer corresponding to one of the following constants:
Constant |
Description |
---|---|
STATUS_SUCCESS |
The login was successful. |
STATUS_ERROR |
An unknown error occurred. |
STATUS_ALREADY_LOGGED_IN |
That user is already logged in. |
STATUS_LOGIN_FAILED |
The login information was invalid. |
STATUS_LOGIN_LOCKED |
Login is locked. |
STATUS_TOO_MANY_CONNECTIONS |
The maximum number of connections to the database was reached. |
STATUS_DATASOURCE_REJ |
The server acknowledged the connection attempt, but rejected it. The problem was server-based. |
STATUS_UNABLE_TO_CONNECT |
The client computer’s ODBC drivers were unable to establish a connection to the server. The problem was client-based. |
STATUS_LOGIN_PASSWORD_EXPIRED |
Password has expired. |
STATUS_LOGIN_PASSWORD_MUST_CHANGE |
The password must be changed before the user can log in. |
To support all of the login features in SQL Server 2005, you must be using the SQL Native Client driver for your ODBC connection.