Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » MobiLink - Server Administration » MobiLink events » Synchronization events

authenticate_parameters connection event

Receives values from the remote database that can be used to authenticate beyond a user ID and password. The values can also be used to arbitrarily customize each synchronization.


In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, use the appropriate corresponding data type.

In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated. Use named parameters instead. You cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you are going to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.

Parameter name for SQL scripts Description Order (deprecated for SQL)
s.authentication_status INTEGER. This is an INOUT parameter. 1
s.authentication_message VARCHAR(1024). This is an INOUT parameter. Provides an authentication message. Not applicable
s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable
s.script_version VARCHAR(128). Optional IN parameter to specify that the MobiLink server passes the script version string used for the current synchronization to this parameter. Question marks cannot be used to specify this parameter. Not applicable
s.username VARCHAR(128). The MobiLink user name. 2
a.N (one or more) VARCHAR(4000). For example, named parameters could be a.1 a.2. 3 or higher
Parameter description
  • authentication_status

    The authentication_status parameter is required. It indicates the overall success of the authentication, and can be set to one of the following values:

    Returned Value authentication_status Description
    V <= 1999 1000 Authentication succeeded.
    1000 <= V <= 2999 2000 Authentication succeeded: password expiring soon.
    3000 <= V <= 3999 3000 Authentication failed: password expired.
    4000 <= V <= 4999 4000 Authentication failed.
    5000 <= V <= 5999 5000 Unable to authenticate because the remote ID is already in use. Try the synchronization again later.
    6000 <= V 4000 If the returned value is greater than 5999, MobiLink interprets it as a returned value of 4000 (authentication failed).
  • authentication_message

    This optional parameter provides an authentication message.

    This named parameter is initialized to NULL before its first use by a user authentication script. Its returning message is then passed into the next user authentication script, if the script takes this named parameter. The final message is translated into the character set of the remote database.

    If no error occurred during execution of the user authentication scripts, this message is then sent to the client by the MobiLink server before precessing the upload stream, regardless of the user authentication status.

    This message is sent to the client, even if the user authentication failed.

  • remote_ID

    The MobiLink remote ID. You can only reference the remote ID if you are using named parameters.

  • script_version

    This optional parameter specifies that the MobiLink server passes the script version string used for the current synchronization to this parameter. Question marks cannot be used to specify this parameter.

  • username

    This parameter is the MobiLink user name. VARCHAR(128).

  • remote a.N

    The Nth authentication parameter sent up from the remote client.


The number of remote parameters must match the number expected by the authenticate_parameters script or an error results. An error also occurs if parameters are sent from the client and there is no script for this event.

You can send strings (or parameters in the form of strings) from both SQL Anywhere and UltraLite clients. This allows you to have authentication beyond a user ID and password. It also means that you can customize your synchronization based on the value of parameters, and do this in a pre-synchronization phase, during authentication. These parameters may also be referenced from any synchronization script.

The MobiLink server executes this event upon starting each synchronization. It is executed in the same transaction as the authenticate_user event.

You can use this event to replace the built-in MobiLink authentication mechanism with a custom mechanism. You may want to call into the authentication mechanism of your DBMS, or you may want to implement features not present in the MobiLink built-in mechanism.

If the authenticate_user or authenticate_user_hashed scripts are invoked and return an error, this event is not called.

SQL scripts for the authenticate_parameters event must be implemented as stored procedures.


For UltraLite remote databases, pass the parameters using the num_auth_parms and auth_parms fields in the ul_sync_info struct. num_auth_parms is a count of the number of parameters, from 0 to 255. auth_parms is a pointer to an array of strings. To prevent the strings from being viewed as plain text, the strings are sent using the same obfuscation as passwords. If num_auth_parms is 0, set auth_parms to null. The following is an example of passing parameters in UltraLite:

ul_char * Params[ 3 ] = { UL_TEXT( "param1" ), 
   UL_TEXT( "param2" ), UL_TEXT( "param3" ) };

info.num_auth_parms = 3;
info.auth_parms = Params;

For SQL Anywhere remote databases, you pass parameters using the dbmlsync -ap option, in a comma-separated list. For example, the following command line passes three parameters:

dbmlsync -ap "param1,param2,param3"

In this example, the authenticate_parameters script could be:

CALL my_auth_parm ( 
  {ml s.authentication_status},
  {ml s.remote_id},
  {ml s.username},
  {ml a.1},
  {ml a.2},
  {ml a.3}