Difference between revisions of "SQL User Import"

From Hornbill
Jump to navigation Jump to search
 
(13 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== About the Hornbill SQL User Import Utility ==
+
This document can now be found at its new location in the [https://docs.hornbill.com/data-imports-guide/users/database/overview Hornbill Document Library].
The utility provides a simple, safe and secure way to create user accounts on the Hornbill platform by synchronizing with accounts held in your Database.  The tool is designed to run behind your corporate firewall, connect to your database, query the required account information, transform and load into the Hornbill instance.  The tool connects to the Hornbill instance in the cloud over HTTPS/SSL so as long as you have standard internet access then you should be able to use tool without the need to make any firewall configuration changes.   The tool supports both the initial bulk import as well as incremental adds and updates. You can schedule the tool to run periodically to perform the import/update tasks as required.
 
  
==== Previous Versions ====
+
[[file:hornbill-document-library.png|Data Imports Guide|link=https://docs.hornbill.com/data-imports-guide/users/database/overview]]
Documentation to [[Special:Permalink/16449|Version 1.2.3]]
 
  
== Open Source ==
+
<!--
  
The SQL User Import Utility is provided open source under the [https://wiki.hornbill.com/index.php/The_Hornbill_Community_License_(HCL) Hornbill Community Licence] and can be found [https://github.com/hornbill/goDb2HUserImport here] on GitHub
+
== About the Hornbill SQL User Import Utility ==
 +
The utility provides a simple, safe and secure way to create user accounts on the Hornbill platform by synchronizing with accounts held in your Database.  The tool is designed to run behind your corporate firewall, connect to your database, query the required account information, transform and load into the Hornbill instance. The tool connects to the Hornbill instance in the cloud over HTTPS/SSL so as long as you have standard internet access then you should be able to use tool without the need to make any firewall configuration changes.   The tool supports both the initial bulk import as well as incremental adds and updates.  You can schedule the tool to run periodically to perform the import/update tasks as required.
  
 
== Installation Overview ==
 
== Installation Overview ==
  
 
=== Windows Installation ===
 
=== Windows Installation ===
* Download the [https://github.com/hornbill/goDb2HUserImport/releases/latest latest package] for your specific architecture and OS from GitHub  
+
* Download the [https://github.com/hornbill/user-import-database/releases/latest latest package] for your specific architecture from GitHub  
 
* Extract zip into a folder you would like the application to run from e.g. '''C:\Hornbill_Import\'''
 
* Extract zip into a folder you would like the application to run from e.g. '''C:\Hornbill_Import\'''
 
* Open '''conf.json''' and add in the necessary configration
 
* Open '''conf.json''' and add in the necessary configration
* Open Command Line Prompt as Administrator
+
* Open Command Line Prompt
* Change Directory to the folder with goDb2HUserImport.exe '''C:\Hornbill_Import\'''
+
* Change Directory to the folder with user_import_db.exe '''C:\Hornbill_Import\'''
* Run the command goDb2HUserImport.exe -dryrun=true
+
* Run the command user_import_db.exe -dryrun=true
  
 
== Configuration Overview ==
 
== Configuration Overview ==
Line 26: Line 25:
  
 
   {
 
   {
     "APIKey": "", /* this is the API-key which is associated to a user in the Hornbill instance [1] */
+
     "KeysafeKeyID": 0, /* this is the Keysafe key ID, which contains your database credentials */
    "InstanceId": "", /* your Hornbill instance name : not likely to change. Please note this value is case sensitive */
+
     "Database": {  
     "SQLConf": { /* db configuration : unlikely to change */
+
     "Source": "mssql", /* options: mssql/mysql/swsql/mysql320/csv/excel ; what DB to connect to */
     "Driver": "mssql", /* options: mssql/mysql/swsql/mysql320/csv/excel ; what DB to connect to */
 
    "Server": "10.123.123.123", /* DB Server address */
 
    "Database": "HB", /* DB Name */
 
    "UserName": "Hornbill", /* DB Username */
 
    "Password": "password", /* DB Password */
 
    "Port": 1433, /* DB Server Port */
 
 
     "UserID": "winaccount", /* the FIELD name  */
 
     "UserID": "winaccount", /* the FIELD name  */
 
     "Encrypt": false, /* options : true/false ; [2] */
 
     "Encrypt": false, /* options : true/false ; [2] */
Line 64: Line 57:
 
       "CurrencySymbol":"", /* any character */
 
       "CurrencySymbol":"", /* any character */
 
       "CountryCode":"" /* expects ISO 3166 Alpha 2 two Character Country Code [https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes (see here)] */
 
       "CountryCode":"" /* expects ISO 3166 Alpha 2 two Character Country Code [https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes (see here)] */
 +
      "Enable2FA": "disabled",
 +
      "DisableDirectLogin": "false",
 +
      "DisableDirectLoginPasswordReset": "false",
 +
      "DisableDevicePairing": "false"
 
     },
 
     },
 
     "Type":{
 
     "Type":{
Line 128: Line 125:
 
     , "Image":{
 
     , "Image":{
 
       "Action":"Both" /* options : Create/Update/Both ; on what action to change the Image */
 
       "Action":"Both" /* options : Create/Update/Both ; on what action to change the Image */
       , "UploadType": "URL" /* options : URI/URL ; local (network) drive or HTTP(S) served image */
+
       , "UploadType": "URL" /* options : URI/URL/LOCAL ; local (network) drive or HTTP(S) served image */
 
       , "InsecureSkipVerify": false
 
       , "InsecureSkipVerify": false
 
       , "ImageType": "jpg" /* options : jpg/png */
 
       , "ImageType": "jpg" /* options : jpg/png */
Line 179: Line 176:
  
  
# An API key is set up against a user within Hornbill (accessed through: Administration > System > Organisationl Data > Users).
 
 
# specify whether the connection between the script and the database should be encrypted. NOTE: There is a bug in SQL Server 2008 and below that causes the connection to fail if the connection is encrypted. Only set this to true if your SQL Server has been patched accordingly
 
# specify whether the connection between the script and the database should be encrypted. NOTE: There is a bug in SQL Server 2008 and below that causes the connection to fail if the connection is encrypted. Only set this to true if your SQL Server has been patched accordingly
 
# please note that all field names are specificied as lowercase - this is to ensure smooth running for the mapped fields (as they are case-sensitive). Also, by specifying each field in use, one is following SQL best practice as it prevents unnecessary/unused data to be stored and processed (longvarchar and blob fields, for instance, take up a lot of memory). '''For CSV''' please use UPPERCASE for all field names and, also, do NOT use spaces in the headers (fieldnames).
 
# please note that all field names are specificied as lowercase - this is to ensure smooth running for the mapped fields (as they are case-sensitive). Also, by specifying each field in use, one is following SQL best practice as it prevents unnecessary/unused data to be stored and processed (longvarchar and blob fields, for instance, take up a lot of memory). '''For CSV''' please use UPPERCASE for all field names and, also, do NOT use spaces in the headers (fieldnames).
Line 211: Line 207:
 
Hornbill can store a manager relationship between two users in Hornbill. The manager look up mechanism works as follows:
 
Hornbill can store a manager relationship between two users in Hornbill. The manager look up mechanism works as follows:
 
# The import reads the contents of the value attribute which will contain the some text identifying the manager eg "''mgrfirstname mgrlastname''"
 
# The import reads the contents of the value attribute which will contain the some text identifying the manager eg "''mgrfirstname mgrlastname''"
# IF a regex it given, then this first will be applied to the data obtained above.
+
# IF a regex is given, then this first will be applied to the data obtained above.
 
# The import is hard-coded to remove any slash and comma in the result.
 
# The import is hard-coded to remove any slash and comma in the result.
 
# With the "Reverse" option enabled, the above string would be reversed to give: "''mgrlastname mgrfirstname''"
 
# With the "Reverse" option enabled, the above string would be reversed to give: "''mgrlastname mgrfirstname''"
Line 220: Line 216:
 
* file - Defaults to '''''conf.json''''' - Name of the Configuration file to load
 
* file - Defaults to '''''conf.json''''' - Name of the Configuration file to load
 
* dryrun - Defaults to '''''false''''' - Set to True and the XMLMC for Create and Update users will not be called and instead the XML will be dumped to the log file, this is to aid in debugging the initial connection information.
 
* dryrun - Defaults to '''''false''''' - Set to True and the XMLMC for Create and Update users will not be called and instead the XML will be dumped to the log file, this is to aid in debugging the initial connection information.
* zone - Defaults to '''''eur''''' - Allows you to change the ZONE used for creating the XMLMC EndPoint URL https://{ZONE}api.hornbill.com/{INSTANCE}/
 
 
* workers - Defaults to `3` - Allows you to change the number of worker threads used to process the import, this can improve performance on slow import but using too many workers have a detriment to performance of your Hornbill instance.
 
* workers - Defaults to `3` - Allows you to change the number of worker threads used to process the import, this can improve performance on slow import but using too many workers have a detriment to performance of your Hornbill instance.
 +
* forcerun - This should '''only''' be used in the event of the error''' ''Unable to run import, a previous import is still running'' ''' to force the import to ignore the "running" status.
 +
* creds - Defaults to `false` - Set to `true` to decrypt and output the API key that is stored locally. NOTE - the tool will prompt you for your instance ID, and this can only be decrypted by the user who originally performed the encryption, and only on the same machine that it was encrypted on.
 +
 +
=== First Run ===
 +
 +
From version '''4.0.0''' of the User Import - Database utility, when you first run the utility it will prompt you for the ID of your Hornbill instance (case-sensitive), and the API key (also case-sensitive) that will be used to authenticate the API calls back into Hornbill. This information will be encrypted, and stored locally on the client PC that will be running the tool. For each subsequent import run, the utility will decrypt your instance ID and API key, and will use those to make the API calls back into Hornbill.
 +
 +
NOTE - the encrypted instance ID and API key can only be decrypted on the computer, and by the user, that performed the encryption, so please keep this in mind when scheduling your imports.
 +
 +
Should you wish to use a different API key to what has been previously encrypted, just delete the '''import.cfg''' file from the folder where the import binary resides, and re-run your import from the command line inputting the Instance ID and new API Key as you would have on its first run.
  
 
== Testing Overview ==
 
== Testing Overview ==
Line 227: Line 232:
  
 
<code>
 
<code>
goDb2HUserImport.exe -dryrun=true
+
user_import_db.exe -dryrun=true
 
</code>
 
</code>
 +
 +
== API Key Rules ==
 +
This utility uses ([[API keys]]):
 +
 +
* activity:profileImageSet
 +
* admin:sysOptionGet
 +
* admin:userAddGroup
 +
* admin:userAddRole
 +
* admin:userCreate
 +
* admin:userDeleteGroup
 +
* admin:userProfileSet
 +
* admin:userSetAccountStatus
 +
* admin:userUpdate
 +
* data:entityAddRecord
 +
* data:entityUpdateRecord
 +
* data:queryExec
 +
* session:getSystemLicenseInfo
 +
 +
=Troubleshooting=
  
 
== Logging Overview ==
 
== Logging Overview ==
Line 234: Line 258:
 
All Logging output is saved in the "log" directory which can be found in the same location as the executable. The file name contains the date and time the import was run '''''SQL_User_Import_2015-11-06T14-26-13Z.log'''''
 
All Logging output is saved in the "log" directory which can be found in the same location as the executable. The file name contains the date and time the import was run '''''SQL_User_Import_2015-11-06T14-26-13Z.log'''''
  
==Trouble Shooting==
+
==Common Error Messages==
 
 
===Common Error Messages===
 
  
 
Below are some common errors that you may encounter in the log file and what they mean:
 
Below are some common errors that you may encounter in the log file and what they mean:
 
* ''' ''[ERROR] Error Decoding Configuration File:.....'' ''' - this will be typically due to a missing quote (") or comma (,) somewhere in the configuration file. This is where an online JSON viewer/validator can come in handy rather than trawling the conf file looking for that proverbial needle in a haystack.
 
* ''' ''[ERROR] Error Decoding Configuration File:.....'' ''' - this will be typically due to a missing quote (") or comma (,) somewhere in the configuration file. This is where an online JSON viewer/validator can come in handy rather than trawling the conf file looking for that proverbial needle in a haystack.
* ''' ''[ERROR] Get https://api.github.com/repos/hornbill/goSQL2HUserImport/tags: dial tcp xx.xx.xx.xx:xxx: ........'' ''' - this most likely indicates that you have a HTTP proxy server on your network between the host running the executable and your Hornbill API endpoint. Ensure the http_proxy environment variable is set (See the section on "HTTP Proxies" for more information) and that the proxy is configured to allow this communication.
+
* ''' ''[ERROR] Get https://api.github.com/repos/hornbill/user-import-database/tags: dial tcp xx.xx.xx.xx:xxx: ........'' ''' - this most likely indicates that you have a HTTP proxy server on your network between the host running the executable and your Hornbill API endpoint. Ensure the http_proxy environment variable is set (See the section on "HTTP Proxies" for more information) and that the proxy is configured to allow this communication.
 
* ''' ''[ERROR] Unable to Create User: Invalid value for parameter '[parameter name]': The text size provided (31 characters) is greater than the maximum allowable size of 20 characters for column [column name]'' ''' - the contents of your directory attribute exceed the maximum number of characters that can be placed in the Hornbill database column.
 
* ''' ''[ERROR] Unable to Create User: Invalid value for parameter '[parameter name]': The text size provided (31 characters) is greater than the maximum allowable size of 20 characters for column [column name]'' ''' - the contents of your directory attribute exceed the maximum number of characters that can be placed in the Hornbill database column.
 
* ''' ''[ERROR] Unable to Create User: The value in element <userId> did not meet the required input pattern constraints. at location '/methodCall/params/userId' '' ''' - the user id contains characters that are not allowed. The User Id should be made up of alphanumeric characters. Full stops (.) and underscores (_) are also supported.
 
* ''' ''[ERROR] Unable to Create User: The value in element <userId> did not meet the required input pattern constraints. at location '/methodCall/params/userId' '' ''' - the user id contains characters that are not allowed. The User Id should be made up of alphanumeric characters. Full stops (.) and underscores (_) are also supported.
 
* ''' ''[ERROR] Unable to Update User: Invalid value for parameter '[parameter name]': Error setting value for column '[column name]'. bad lexical cast: source type value could not be interpreted as target'' ''' - this error is indicating that the contents of your directory attribute are in a format that is not compatible with the type of the Hornbill database column. For example, you will get this when trying to place text into a database field that is of type "INT" (accepts integer values only).
 
* ''' ''[ERROR] Unable to Update User: Invalid value for parameter '[parameter name]': Error setting value for column '[column name]'. bad lexical cast: source type value could not be interpreted as target'' ''' - this error is indicating that the contents of your directory attribute are in a format that is not compatible with the type of the Hornbill database column. For example, you will get this when trying to place text into a database field that is of type "INT" (accepts integer values only).
 
* ''' ''[ERROR] Unable to Load LDAP Attribute: '[LDAP attribute name]' For Input Param: '[Hornbill Parameter name]' '' ''' - When the import utility is unable to load a particular LDAP attribute, this means that the attribute field in your directory does not contain a value. This error will not prevent the user account being created or updated in Hornbill and can be considered more as a warning rather than an outright failure or problem.
 
* ''' ''[ERROR] Unable to Load LDAP Attribute: '[LDAP attribute name]' For Input Param: '[Hornbill Parameter name]' '' ''' - When the import utility is unable to load a particular LDAP attribute, this means that the attribute field in your directory does not contain a value. This error will not prevent the user account being created or updated in Hornbill and can be considered more as a warning rather than an outright failure or problem.
 +
* ''' ''[ERROR] Unable to run import, a previous import is still running'' ''' - This can occur when a previous import did not exit cleanly. Use the command-line parameter '''-forcerun''' on the next import to force the import to ignore the running status.
  
 
=== Error Codes ===
 
=== Error Codes ===
Line 251: Line 274:
 
* '''102''' - Unable to Load Configuration File
 
* '''102''' - Unable to Load Configuration File
  
== HTTP Proxies ==
+
= HTTP Proxies =
  
If you use a proxy for all of your internet traffic, the HTTP_PROXY and HTTPS_PROXY Environment variables needs to be set. These environment variables hold the hostname or IP address of your proxy server. It is a standard environment variable and like any such variable, the specific steps you use to set it depends on your operating system.
+
{{UtilityProxies}}
  
For windows machines, it can be set from the command line using the following:
+
= Scheduling Overview =
<br>
 
<code>
 
set HTTP_PROXY=HOST:PORT
 
  
set HTTPS_PROXY=HOST:PORT
+
== Windows ==
</code>
 
<br>
 
Where "HOST" is the IP address or host name of your Proxy Server and "PORT" is the specific port number.
 
IF you require a username and password to go through the proxy, the format for the setting is as follows:
 
<br>
 
<code>
 
set HTTP_PROXY=username:password@HOST:PORT
 
 
 
set HTTPS_PROXY=username:password@HOST:PORT
 
</code>
 
<br>
 
=== URLs to White List ===
 
 
 
Occasionally on top of setting the HTTP_PROXY variable the following URLs need to be white listed to allow access out to our network
 
 
 
* https://files.hornbill.com/instances/INSTANCENAME/zoneinfo - Allows access to lookup your Instance API Endpoint
 
* https://files.hornbill.co/instances/INSTANCENAME/zoneinfo - Backup URL for when files.hornbill.com is unavailable
 
* https://eurapi.hornbill.com/INSTANCENAME/xmlmc/ - This is your Instance API Endpoint, eurapi can change so you should use the endpoint defined in the previous URL
 
* https://api.github.com/repos/hornbill/goLDAPUserImport/tags - '''Optional''' Allows access to check for the latest version of the Import Tool
 
<br>
 
 
 
== Scheduling Overview ==
 
 
 
=== Windows ===
 
 
You can schedule .exe to run with any optional command line argument from Windows Task Scheduler.
 
You can schedule .exe to run with any optional command line argument from Windows Task Scheduler.
 
* Ensure the user account running the task has rights to ldap_import.exe and the containing folder.
 
* Ensure the user account running the task has rights to ldap_import.exe and the containing folder.
Line 292: Line 288:
  
  
== Required Permissions ==
+
= Required Permissions =
  
=== Default Role ===
+
== Default Role ==
 
As of Server Release 2494 a default role '''User Import''' is delivered which has all the necessary rights to import / update users. The exception to this is any roles you try and assign to users being imported must be assigned to the user account logging in and running the import, this is due to a security measure that prevents you inflating your own rights or giving a user more rights than you have yourself.  
 
As of Server Release 2494 a default role '''User Import''' is delivered which has all the necessary rights to import / update users. The exception to this is any roles you try and assign to users being imported must be assigned to the user account logging in and running the import, this is due to a security measure that prevents you inflating your own rights or giving a user more rights than you have yourself.  
  
Line 301: Line 297:
 
The following rights are required by any user account being used to run the User Import tool.
 
The following rights are required by any user account being used to run the User Import tool.
  
=== System Rights ===
+
== System Rights ==
 
'''Group A (Accounts)'''
 
'''Group A (Accounts)'''
 
* Manage Users
 
* Manage Users
Line 307: Line 303:
 
* Update Users
 
* Update Users
 
[[File:Screen_Shot_2016-02-26_at_07.59.50.png]]
 
[[File:Screen_Shot_2016-02-26_at_07.59.50.png]]
=== Table Rights ===
+
== Table Rights ==
 
'''h_sys_accounts'''
 
'''h_sys_accounts'''
 
* Browse
 
* Browse
Line 326: Line 322:
 
* Add
 
* Add
 
[[File:Screen_Shot_2016-03-02_at_10.00.30.png]]
 
[[File:Screen_Shot_2016-03-02_at_10.00.30.png]]
 +
 +
-->
 +
[[Category:HDOC]]

Latest revision as of 20:38, 11 April 2024

This document can now be found at its new location in the Hornbill Document Library.

Data Imports Guide