User import tool

Last modified by Aurelie Bertrand on 2024/09/24 10:22


Description

importtools is a tool for managing users in DigDash LDAP. It is particularly useful for managing a large user base.

importtools can be run directly using the "importtools.bat" command file provided, with the default arguments (which can be modified by editing the .bat file)

or

It can be run via the "importtools.jar" Java tool provided in the <digdash_install>\add-ons\tools\lib folder with default or customisable arguments (see next section).

java -jar importtools.jar [-conf configfile] [-users userfile] [-out outputfile]

Since version 2022R1, the value of the langChoice user parameter is now a language code rather than an index. For example, 0 has become "en", 1 has become "fr". You need to take this change into account and adapt your existing user import scripts if necessary.

Importing users

This mainly involves having two input files:

  • the configuration file in XML format: the example file conf.xml is delivered in <digdash_install>\add-ons\tools\importtools; It is used to map a column in the users file (see next) to an attribute of an LDAP user in the output file (see next).
  • the user file in Excel or CSV format: the example file users.xls is delivered in <digdash_install>\add-ons\tools\importtools; This is the user database (one line per user) to be imported into LDAP. Its columns correspond to the attributes in the XML configuration file.

And an output file:

  • the output file in XML format: named "out.xml" by default, it is generated when the "importtools" tool is launched with the two files mentioned above as input; it is generated in such a way as to map onto the LDAP structure.
TagDescription
-conf <config file>Path to the XML configuration file. By default, conf.xml.
-users <excel file / csvfile>Path to the input file of users to be imported. This can be an Excel file or a CSV file. By default, users.xls.
-out <outputfile>Path to the XML output file mapping to LDAP. By default, out.xml.
-helpUsage help command.
-debugDisplays traces of errors.
-importSends the output file (by default out.xml) to the server for import into LDAP.
-importonlyUses an existing output file (by default, out.xml) and sends it to the server to be imported into LDAP.
-serverAddress of the DigDash server.
-domainDigDash Enterprise domain name (for example, ddenterpriseapi)
-userThe supervisor user.
-passThe password of the supervisor user.

Commands for adding users

There are three ways of adding a user to LDAP:

create

In this mode the user will be added if, and only if, it does not exist.
In other words, with the create command, adding an existing user is an error.

overwrite

This command will overwrite an existing user.
To be more precise, the user will be deleted before being completely created with the new attributes.
If the user does not already exist, it will simply be added.

update

This command will update the user with the attributes contained in your import file.
The user must already exist. It will not be deleted.

Deleting users

You can delete all or some of the users in the DigDash LDAP database.

TagDescription
-removeallDeletes ALL users present in LDAP AND the license.
-removeall -attr="ldap attribute name" -regexp="attribute value or regular expressionRemoves all users whose specified ldap attribute value checks the regular expression.
-removeall -license_type="all.missing.forbidden.[usertype]"

Removes all users according to their type or status in the licence:

  • all: all
  • missing : users not in the licence
  • forbidden: users in the licence but not authorised
  • [user type]: possible values are named, extranet, concurrent, public, broadcast.
    None, one or more values can be used, separated by a ".".
    Example: named.extranet or missing.extranet.named

At least one of these parameters must be used.

Exporting users

It is possible to export users from the LDAP database.

Options :

TagDescription
-exportExports all users to a CSV file. By default, the export file is called users_export.csv.
-exportfile "file.csvExports all users to the CSV file indicated by its absolute path (preceded by -export).

General parameters

Logs
-log "C:\temp"The log file will be created in the specified directory, named as follows: importtool-yyyy-mm-dd_hh-mm-ss.log.
-log "C:\log.txt"The log file will be created in the directory and under the name specified.
Other
-loginFormForces LDAP authentication in the SSO case.

Examples

  • java -jar importtools.jar
  • java -jar importtools.jar -conf ../importtools/conf.xml -users ../importtools/users.xls -out ../importtools/out.xml
  • java -jar importtools.jar -conf ../importtools/conf.xml -users ../importtools/users.xls -out ../importtools/out.xml -import -server http://localhost:8080 -domain ddenterpriseapi -user admin -pass admin
  • java -jar importtools.jar -export -server http://localhost:8080 -domain ddenterpriseapi -user admin -pass admin
  • java -jar importtools.jar -export -exportfile "D:\my_users_export.csv" -server http://localhost:8080 -domain ddenterpriseapi -loginForm -user admin -pass admin
  • java -jar importtools.jar -removeall -server http://localhost:8080 -domain ddenterpriseapi -user admin -pass admin
  • java -jar importtools.jar -removeall -attr "license_type" -regexp "extranet" -server http://localhost:8080 -domain ddenterpriseapi -user admin -pass admin
  • java -jar importtools.jar -removeall -attr "uid" -regexp "toto1[0-9]*" -server http://localhost:8080 -domain ddenterpriseapi -user admin -pass admin

Troubleshooting encoding errors on Windows

Windows can contain encoding errors. To overcome these errors, you need to add the following command when exporting:

-Dfile.encoding=utf-8

This command is a parameter for JAVA, so you need to place it upstream of the options for importtool.jar. For example:

"C:\java.exe" -Dfile.encoding=utf-8 -jar "importtools.jar" %* -export -exportFile "export_.csv" -server https://serveur.digdash.com -domain ddenterpriseapi -user admin -pass "AdminPassWrd"

SSL certificate problem

Running the importtools module to import users in batch to a DigDash server protected by an SSL certificate, from your local workstation or a workstation that is not the DigDash server, may fail because the SSL certificate has been incorrectly configured.
You are likely to get the following message when you run the script:

2020-11-09 20:39:34,407 INFO [main] (DDEnterpriseAPIRest.java:1593) - Exception raised (params: clientId=ImportTool, method=login, pass=******, user=#####@###.fr): URL download error: https://###.fr/####DOMAINE###/DDEnterpriseAuthServlet

To work around this problem :

  1. Modify the importools.bat file .
  2. Add the -DSSLNoPathCheck=true parameter before -jar as in the example below:

java -Dlog4j.configuration="file:///%importtoolshome%/import_log4j.properties" -DSSLNoPathCheck=true -jar "%importtoolshome%/importtools.jar" %* -conf conf.xml -users users.xls -out out.xml -import -server https://###.fr -domain ###DOMAIN### -user admin -pass ##PASS##