SQL Server
  • 14 Dec 2023
  • 5 Minutes to read
  • Dark
    Light
  • PDF

SQL Server

  • Dark
    Light
  • PDF

Article Summary

The SQL Server adapter imports device information from arbitrary SQL servers: Microsoft SQL Server, MySQL, Oracle and PostgreSQL.

Note:

Axonius considers the results imported from the SQL server as if these were received from a CSV file. This means the imported data must include at least one column of required data as specified in the CSV adapter - Which fields will be imported with a devices file?

Types of Assets Fetched

This adapter fetches the following types of assets:

  • Devices
  • Users

Parameters

  1. SQL Server Host (required) - The hostname / domain of the SQL server.
    For MSSQL:
    • To use a specific named instance, the value supplied should be in the following format: {server_host}\{instance_name}.
    • If no instance is supplied, the default instance will be used.
  2. SQL Server Port (required) - The port of the SQL server.
    For MSSQL the required ports are:
    • Microsoft SQL Server discovery port - 1433.
    • The specific port for the supplied named instance, if relevant.
  3. User Name (required) - The credentials for a user account that has the required permissions to fetch assets.
Note:

* The best practice is to create a dedicated SQL local user for Axonius usage. For details on creating an Axonius user for Microsoft SQL Server, see Creating a Local Read-Only User for Microsoft SQL Server.
* If you are using a domain user, specify the domain and the user name in the following format: domain\username.

  1. Password (required) - The user's password. The password must not include ";".
  2. SQL Server Database Name (required) - The database to connect to.
  3. SQL Server Table Name (required) - The name of the table to fetch information from. Axonius runs a 'SELECT * FROM [[specified value]]' statement.
  4. Database Type (required) - MSSQL, MySQL, Oracle, PostgreSQL or HyperSQL. MySQL also supports the MariaDB.
  5. Is Users Table (required, default: False) - Select whether the SQL Server table is a devices or a users table.
    • If enabled, Axonius will consider the data fetched from the specified table as user data.
    • If disabled, Axonius will consider the data fetched from the specified table as device data. You can also fetch Software Vulnerabilities data. A table with Software Vulnerabilities data must contain a CVE ID field. See CSV for more information.
  6. Fetch system users in addition to table - Select this option to not only fetch the SQL Server Table Name provided in the configuration but also query the system's Service Principle table for extra user assets.
  7. Server Tag (optional, default: empty) - Specify a custom tag for the SQL Server adapter connection that you have configured.
    • If supplied, Axonius will set the Server Tag field with the defined value.
    • If not supplied, Axonius will not populate the Server Tag field.
  8. MySQL Character Set (optional, default: empty) - Specify a custom character set (encoding) for connections to MySQL databases. Example values: 'utf8', 'latin1'. When no character set is specified, 'utf8' is used by default.
    Note: This option is only valid when MySQL is selected from the Database Type dropdown.
  9. Ignore entities in current connection that have not been seen in the last X hours - Specify the number of hours, so that the system will not fetch entities that were not seen in the last x hours. When Is Users Table is configured, this refers to users; otherwise, this refers to devices.
  10. Delete entities in current connection that have not been returned in the last X hours - Specify the number of hours, so that the system will delete entities that were not fetched in the last x hours. When Is Users Table is configured, this refers to users; otherwise this refers to devices.
  11. MSSQL Connection Timeout (optional, default: 30)- Specify a custom timeout in seconds for MSSQL connections.
  12. Multi-value fields delimiter (optional, default: empty) - Specify a delimiter to separate between values within the same column in the imported SQL table. When you specify a delimiter Axonius considers fields that contain the specified delimiter as multi-value fields. For example, ';'. Otherwise Axonius considers all imported fields as single-value fields.

To learn more about common adapter connection parameters and buttons, see Adding a New Adapter Connection.

SQL%20Server


Advanced Settings

Note:

Advanced settings can either apply for all connections for this adapter, or you can set different advanced settings and/or different scheduling for a specific connection, refer to ​Advanced Configuration for Adapters

  1. SQL pagination (required, default: 1000) - Set the number of results per page received for a given SQL query, to gain better control of the performance of all connections for this adapter.
  2. Add dynamic date raw field (required, default: false) - Select whether to duplicate each date field appearing in the MSSQL database as a text value. The name of the new field is appended with the ‘_raw’ suffix.
Note:

For details on general advanced settings under the Adapter Configuration tab, see Adapter Advanced Settings.

Enabling TCP/IP for the SQL Server

In order to connect to the SQL instance, TCP must be enabled. By default, Microsoft SQL or Microsoft SQL Express has TCP/IP access disabled. Perform the following on the SQL Server Configuration Manager to make sure that TCP/IP access is enabled on your server.

  1. Open the SQL Server Configuration Manager.

    SQLServer1

  2. Under SQLServer Network Configuration, click Protocols for SQLEXPRESS (or the equivalent for your SQL server).

    SQLTCP

  3. If TCP/IP is set to 'Disabled', right click and select 'Enable'.

  4. The system informs you that your changes will be saved, but that you need to stop and restart the SQL Service. Go to Services on your system and restart the SQL Service.

    SQLRestart

Creating a Local Read-Only User for Microsoft SQL Server

To connect to the Microsoft SQL Server to create a Local Read-Only User, you can use Microsoft SQL Server Management Studio. If you don't have it on your local machine, you can probably find it on the machine the Microsoft SQL Server is installed on.

After connecting to the server, you should do the following:

  1. If you don't have the name of your database, expand the Databases folder which shows all the databases in this server. Your database should appear here, starting with "CM_".

  2. Navigate to the Security folder and expand it. Right-click the Logins folder and click New Login.

    image.png

  3. Create a user using the "SQL Server Authentication" option. Fill in the details and select your database from the Default Database List.

    image.png

  4. Navigate to the User Mapping page, and check the check box for the database that your login can access. In the Database role membership list, leave the default option public selected, and select the db_datareader check box.

    image.png

  5. Click OK and create the user.

  6. Reconnect with the new user to validate that it was indeed created (File -> Connect Object Explorer).

    image.png

Troubleshooting

  • "Login failed" - If you are using a domain user, in the User Name field, specify the domain and the user name in the following format: domain\username.


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.