Previous Topic: Scenario Management APIsNext Topic: Creating Scenarios: create_scenario_ex()


Starting Work: create_session()

The create_session API function lets you authenticate against Control Service and returns the session ID. You pass the session ID as an argument when calling any other API function. The open session can be invalidated by using the close_session API.

Arguments

The create_session API function includes the arguments described in the following table:

Name

Type

Description

user_name

string

The user name.

Example: MyDomain\Administrator

password

string

The password for the user name.

Example: Arcserve

error_code

out uint

A zero value indicates that API function was executed successfully. A nonzero value indicates failure API.

Return Values

When authentication using create_session is successful, this function returns uint value with the session ID and an error_code argument set to 0. Otherwise, the MAX uint value (0xFFFFFFFF) is returned and the error_code argument contains the detailed error code.

Note: You should specify the user_name argument in the form <DOMAIN_NAME>\<USER_NAME>. For example, test_domain\Administrator.

Examples

Example 1: Creating a web services object.

xosoapapi_c get_mng()
        {
            xosoapapi_c mng = new xosoapapi_c();
            return mng;
        }

Example 2: Creating a session.

public bool create_session_example()
        {
            try
            {
                uint err = 0;
                string user_name = global::api_examples.Properties.Settings.Default.user_name;
                string password = global::api_examples.Properties.Settings.Default.password;
                _session_id = get_mng().create_session(user_name, password, out err);
                if (_session_id == 0xffffffff)
                {
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            return false;
        }