Query Reports are reports that can be generated using an SQL query.
Role Required: SDAdmin; Technicians who have Complete Access to reports and Create Query Report permission.
To create a new query report,
- Go to the Reports tab and click New Query Report in the left pane.
- In the Query Editor, select the required module from the Table Schema drop-down.
- Specify the Report Title.
- Specify the query to be executed in the Query field. Any errors in the query will be shown in the Logs field.
- Click Run Report to create the query report.
Read-Only User
A read-only user has exclusive permission to view data in the database and execute secure query reports.
Role Required: SDAdmin; Technicians with Create Query Report permissions
Create a Read-Only User
Create a read-only user only if you have configured an external Postgres or MSSQL database in your application. For bundled Postgres, a read-only user is built-in by default.
- To create a read-only user, execute the following queries:
For External Postgres Database
| For MSSQL Database
|
CREATE USER <username> WITH LOGIN PASSWORD <password>;
GRANT CONNECT ON DATABASE <databaseName> TO <username>;
GRANT USAGE ON SCHEMA public TO <username>;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO <username>;
| CREATE LOGIN <username> WITH PASSWORD <password>;
CREATE USER <username> FOR LOGIN <username>;
|
- Grant relevant permissions for all tables.
- Revoke access for tables that contain sensitive or unnecessary data with this query:
- REVOKE SELECT ON <tableName> FROM <username>
- Obtain the encrypted key of the password.
- Go to [AssetExplorer]\bin in the command prompt.
- Execute the script encrypt.bat <read-only user password>.
- Copy the password encryption key displayed in the command prompt and store it in a secure location.
- Go to {AssetExplorer_Home}/AssetExplorer/conf.
- Open the database_params.conf file.
- Configure the username in the relevant tag. For example,
- rodatasource.username=<username>
- Fetch the encrypted password key and configure it in the relevant tag. For example,
- rodatasource.password=<password>
Update Database Flag
- After the user is created, connect the application to the database and execute the following query. This will allow the read-only user to generate secure query reports without accessing data from restricted tables.
- UPDATE ReportModuleConfiguration SET PARAMVALUE = 'true' WHERE CATEGORY LIKE 'ROUser' AND PARAMETER LIKE 'Use_ROUser'
- Restart the application for the changes to take effect.
Restore AssetExplorer
After restoring AssetExplorer from the backup data,
- Update the database flag if the database setup is unchanged.
- If the database or application setup is modified, create a read-only user again.
Restrict Execution of Database Functions
Administrative functions that interfere with or slow down query report generation must be restricted.
Restrict PostgREST Database Functions
To restrict Postgres functions, remove Execute permission from the public role using Data Control Language (DCL) commands.
- Copy the fetch functions script from this page.
- Execute the query present in the file.
- The functions that interfere with query reports will be listed in the query result.
- Copy the query result and execute the following queries to revoke the Execute permission.
- To revoke the Execute permission for public users:
- REVOKE EXECUTE ON FUNCTION FROM public;
- To revoke the Execute permission for the read-only user:
- REVOKE EXECUTE ON FUNCTION <insert query result> FROM <Read-Only User name>;
- To grant the Execute permission to all users except for public users and read-only user:
- GRANT EXECUTE ON FUNCTION <insert query result> TO <users except read-only user and public>;
Restrict MSSQL Database Functions
To restrict the MSSQL function,
- Fetch the functions to be restricted manually.
- Revoke the Execute permission with the following queries.
- To revoke Execute permission for the read-only user:
- DENY EXECUTE ON [dbo].<FunctionName> TO <Read-only User Name>;
- To revoke Execute permission for public users:
- DENY EXECUTE ON [dbo].<FunctionName> TO public;
- To grant the Execute permission to all users except for public users and read-only user:
- GRANT EXECUTE ON [dbo].<FunctionName> TO <user name comma sperated>;
Administrative functions that interfere with query reports must be restricted for public users and read-only user every time the AssetExplorer build is updated.
Tables to be Restricted for the Read-Only User
- AaaAccHttpSession, AaaPassword, RememberMeDetails, ADSTFAUserEnrollment, IDSAuthnFwFactorTOTPEnrollment, IDSAuthnFwFactorBackupCodeEnrollment, IDSFwState, IDSAuthnFwAuthnToken, IDSAuthnFwAuthnTokenVsResources, IDSAuthnFwEnrollmentSettings, IDSAuthnFwEnrollmentSettingsVsFactorConfig, IDSAuthnFwFactor, IDSAuthnFwFactorBackupCodeConfig, IDSAuthnFwFactorConfig, IDSAuthnFwFactorEmailConfig, IDSAuthnFwFactorEmailEnrollment, IDSAuthnFwFactorTOTPConfig, IDSAuthnFwMFAAttemptAudit, IDSAuthnFwMFAAttemptAuditVsAuthnFactorAttempt, IDSAuthnFwUserEnrollment, IDSAuthnFwUserEnrollmentVsFactorConfig, IDSFwEndpoint, IDSFwEndpointAccessRule, IDSFwEndpointAccessRuleAuthnSettings, IDSFwEndpointAccessRuleVsAuthnFactorConfig, IDSFwEndpointAccessRuleVsResources, IDSFwEndpointModule, CustomFunctionDetails, AdminAuditHistoryJson, MobileAuthKey, COMMONPASSWORD, PasswordInfo, PasswordResetLink, BackupSchedule, DBCredentialsAudit, ChatJson, ThrottleExceedingHistory, UserAdditionalFields_multiselect, UserAdditionalFields_history, UserAdditionalFields_historydiff, CustomPickListValues, CustomModuleInstance, CustomModuleInstanceImages, CustomModuleDescription, CustomModuleHistory, CustomModuleHistoryDiff, CM_Tasks, CM_Comments, CM_Attachments, Custom_001, Custom_MultiSelect_001, OauthToken, OauthCredential, CustomTrustStore, TechnicianKeyDefinition
Revoke Read-Only User Access in MSSQL
Use the following query to block the read-only user from executing commands and to revoke the user's access to all tables in the database.
Ignore any error messages about tables or objects not being found while running this script.
- DENY INSERT, UPDATE, DELETE ON SCHEMA :: [dbo] TO <userName>;
- REVOKE SELECT ON SCHEMA :: [dbo] FROM <userName>;
- declare commands cursor for
- SELECT
- 'GRANT SELECT ON [dbo].' + QUOTENAME(t.TABLE_NAME) + ' TO <userName>;'
- FROM
- TableDetails t
- WHERE
- t.TABLE_NAME NOT LIKE 'AaaAccHttpSession'
- AND t.TABLE_NAME NOT LIKE 'AaaPassword'
- AND t.TABLE_NAME NOT LIKE 'RememberMeDetails'
- AND t.TABLE_NAME NOT LIKE 'ADSTFAUserEnrollment'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwFactorTOTPEnrollment'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwFactorBackupCodeEnrollment'
- AND t.TABLE_NAME NOT LIKE 'IDSFwState'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwAuthnToken'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwAuthnTokenVsResources'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwEnrollmentSettings'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwEnrollmentSettingsVsFactorConfig'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwFactor'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwFactorBackupCodeConfig'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwFactorConfig'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwFactorEmailConfig'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwFactorEmailEnrollment'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwFactorTOTPConfig'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwMFAAttemptAudit'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwMFAAttemptAuditVsAuthnFactorAttempt'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwUserEnrollment'
- AND t.TABLE_NAME NOT LIKE 'IDSAuthnFwUserEnrollmentVsFactorConfig'
- AND t.TABLE_NAME NOT LIKE 'IDSFwEndpoint'
- AND t.TABLE_NAME NOT LIKE 'IDSFwEndpointAccessRule'
- AND t.TABLE_NAME NOT LIKE 'IDSFwEndpointAccessRuleAuthnSettings'
- AND t.TABLE_NAME NOT LIKE 'IDSFwEndpointAccessRuleVsAuthnFactorConfig'
- AND t.TABLE_NAME NOT LIKE 'IDSFwEndpointAccessRuleVsResources'
- AND t.TABLE_NAME NOT LIKE 'IDSFwEndpointModule'
- AND t.TABLE_NAME NOT LIKE 'CustomFunctionDetails'
- AND t.TABLE_NAME NOT LIKE 'AdminAuditHistoryJson'
- AND t.TABLE_NAME NOT LIKE 'MobileAuthKey'
- AND t.TABLE_NAME NOT LIKE 'COMMONPASSWORD'
- AND t.TABLE_NAME NOT LIKE 'PasswordInfo'
- AND t.TABLE_NAME NOT LIKE 'PasswordResetLink'
- AND t.TABLE_NAME NOT LIKE 'BackupSchedule'
- AND t.TABLE_NAME NOT LIKE 'DBCredentialsAudit'
- AND t.TABLE_NAME NOT LIKE 'ChatJson'
- AND t.TABLE_NAME NOT LIKE 'ThrottleExceedingHistory'
- AND t.TABLE_NAME NOT LIKE 'UserAdditionalFields_multiselect'
- AND t.TABLE_NAME NOT LIKE 'UserAdditionalFields_history'
- AND t.TABLE_NAME NOT LIKE 'UserAdditionalFields_historydiff'
- AND t.TABLE_NAME NOT LIKE 'CustomPickListValues'
- AND t.TABLE_NAME NOT LIKE 'CustomModuleInstance'
- AND t.TABLE_NAME NOT LIKE 'CustomModuleInstanceImages'
- AND t.TABLE_NAME NOT LIKE 'CustomModuleDescription'
- AND t.TABLE_NAME NOT LIKE 'CustomModuleHistory'
- AND t.TABLE_NAME NOT LIKE 'CustomModuleHistoryDiff'
- AND t.TABLE_NAME NOT LIKE 'CM_Tasks'
- AND t.TABLE_NAME NOT LIKE 'CM_Comments'
- AND t.TABLE_NAME NOT LIKE 'CM_Attachments'
- AND t.TABLE_NAME NOT LIKE 'Custom_001'
- AND t.TABLE_NAME NOT LIKE 'Custom_MultiSelect_001'
- AND t.TABLE_NAME NOT LIKE 'OauthToken'
- AND t.TABLE_NAME NOT LIKE 'OauthCredential'
- AND t.TABLE_NAME NOT LIKE 'CustomTrustStore'
- AND t.TABLE_NAME NOT LIKE 'TechnicianKeyDefinition';
- declare @cmd varchar(max)
- open commands
- fetch next from commands into @cmd
- while @@FETCH_STATUS=0
- begin
- exec(@cmd)
- fetch next from commands into @cmd
- end
- close commands
- deallocate commands
Query to Fetch Internal Tables
By default, internal tables are restricted from being viewed by users to avoid exposing sensitive data.
To view internal tables, administrators can execute the following queries:
Postgres Database
| MSSQL Database
|
SELECT Distinct(table_name) as "Name" FROM information_schema.tables WHERE lower(table_name) NOT IN (SELECT lower(table_name) from TableDetails ) ORDER BY table_name;
| SELECT * FROM (SELECT DISTINCT(name) as "Name" FROM sys.objects WHERE type_desc = 'SYSTEM_TABLE' OR type_desc = 'INTERNAL_TABLE' OR type_desc = 'USER_TABLE' OR type_desc = 'VIEW' UNION SELECT DISTINCT(name) FROM sys.tables UNION SELECT DISTINCT(name) FROM sysobjects WHERE sysobjects.xtype = 'U' OR sysobjects.xtype = 'S' UNION SELECT DISTINCT(name) FROM sys.system_views UNION SELECT DISTINCT(TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES ) AS t WHERE t.Name NOT IN (SELECT TableDetails.TABLE_NAME FROM TableDetails ); |
Queries that include keywords present in internal table names will not be executed.
Related Articles
Custom Reports
AssetExplorer enables you to create customized reports to meet the unique needs of your organization. Role Required: SDAdmin; Technicians with Complete Access to reports. To create custom reports, Go to the Reports Tab. Click the New Custom Report ...
Scheduling Reports
Using Schedule Report Settings, you can automate generating multiple reports, in various formats, at scheduled times. These reports can be generated in PDF, XLS, XLSX, HTML, Inline HTML, CSV, DOC, DOCX, or XML formats and shared via email or saved to ...
Predefined Reports
AssetExplorer provides predefined reports that technicians can use to generate reports instantly. Predefined reports can also be edited to fine-tune the data as needed. To access the reports, go to the Reports tab and browse the listed folders. ...
Support Policy
Support will be provided only for the AssetExplorer builds 7000 and above. We recommend you upgrade to the latest version to continue receiving support. Support for scripts, query reports, and customizations is chargeable. Scripts, query reports, and ...
Enable SSL Connection in MSSQL
Secure the AssetExplorer MSSQL database by setting up an SSL connection. To create an SSL connection, you must obtain either a self-signed SSL certificate or purchase a verified SSL certificate from a vendor. To generate a self-signed certificate, go ...