- 02 Oct 2024
- 6 Minutes to read
- Print
- DarkLight
- PDF
SQL Server
- Updated on 02 Oct 2024
- 6 Minutes to read
- Print
- DarkLight
- PDF
The SQL Server adapter imports device information from arbitrary SQL servers: Microsoft SQL Server, MySQL, Oracle and PostgreSQL.
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
- 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.
- 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.
- User Name (required) - The credentials for a user account that has the required permissions to fetch assets.
* 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.
- Password (required) - The user's password. The password must not include ";".
- SQL Server Database Name (required) - The database to connect to.
- SQL Server Table Name (required) - The name of the table to fetch information from. Axonius runs a 'SELECT * FROM [[specified value]]' statement.
- Database Type (required) - MSSQL, MySQL, Oracle, PostgreSQL or HyperSQL. MySQL also supports the MariaDB.
- 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.
- 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.
- 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.
- 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. - 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.
- 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.
- MSSQL Connection Timeout (optional, default: 30)- Specify a custom timeout in seconds for MSSQL connections.
- 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.
- Allow empty values - Select this option to allow the system to support assets with empty fields. If an asset was created with a field that contained a value, when the SQL file subsequently contains an empty field with the same name, the device or user asset will display that field without a value in it.
To learn more about common adapter connection parameters and buttons, see Adding a New Adapter Connection.
Advanced Settings
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
- 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.
- 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.
- Parse Asset Name as Hostname when Hostname is missing (required, default: false) - Select this option to use the Asset Name as the Hostname value when no Hostname value is provided.
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.
Open the SQL Server Configuration Manager.
Under SQLServer Network Configuration, click Protocols for SQLEXPRESS (or the equivalent for your SQL server).
If TCP/IP is set to 'Disabled', right click and select 'Enable'.
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.
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:
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_".
Navigate to the Security folder and expand it. Right-click the Logins folder and click New Login.
Create a user using the "SQL Server Authentication" option. Fill in the details and select your database from the Default Database List.
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.
Click OK and create the user.
Reconnect with the new user to validate that it was indeed created (File -> Connect Object Explorer).
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.