Wiki source code of Outil d’importation d'utilisateurs (importtools)
Last modified by Aurelie Bertrand on 2025/12/19 08:51
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{ddtoc/}} |
| 2 | |||
| 3 | ---- | ||
| 4 | |||
| 5 | = **{{id name="__RefHeading___Toc1848_2652393712"/}}**Description = | ||
| 6 | |||
| |
28.1 | 7 | **importtools **is a tool for managing users in DigDash LDAP. It is particularly useful for managing a large user base. |
| |
1.1 | 8 | |
| |
28.1 | 9 | Importtools can be run directly via the "importtools.bat" command file provided, with default arguments (which can be modified by editing the .bat file) |
| 10 | - or - | ||
| 11 | 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). | ||
| |
1.1 | 12 | |
| |
2.1 | 13 | (% class="box infomessage" %) |
| 14 | ((( | ||
| |
1.1 | 15 | java -jar importtools.jar [-conf configfile] [-users userfile] [-out outputfile] |
| |
2.1 | 16 | ))) |
| |
1.1 | 17 | |
| |
28.1 | 18 | = Importing users = |
| |
9.1 | 19 | |
| |
28.1 | 20 | This mainly involves having two input files: |
| |
1.1 | 21 | |
| |
28.1 | 22 | * 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). |
| 23 | * The user file in Excel or CSV format: 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. You can consult the example file [[users_example.xls>>attach:users_example.xls]] and the description of the [[user attributes>>doc:.User_attributes.WebHome]]. | ||
| |
1.1 | 24 | |
| |
28.1 | 25 | And an output file : |
| |
1.1 | 26 | |
| |
28.1 | 27 | * 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. |
| |
1.1 | 28 | |
| 29 | |=Tag|=Description | ||
| |
28.1 | 30 | |**-conf** <config file>|Path to the XML configuration file. By default, conf.xml. |
| 31 | |**-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. | ||
| 32 | |**-out** <outputfile>|Path to the XML output file mapping to LDAP. By default, out.xml. | ||
| 33 | |**-help**|Usage help command. | ||
| 34 | |**-debug**|Displays traces of errors. | ||
| 35 | |**-import**|Sends the output file (by default out.xml) to the server for import into LDAP. | ||
| 36 | |**-importonly**|Uses an existing output file (by default, out.xml) and sends it to the server to be imported into LDAP. | ||
| 37 | |**-server**|Address of the DigDash server. | ||
| 38 | |**-domain**|DigDash Enterprise domain name (for example, ddenterpriseapi) | ||
| 39 | |**-user**|The supervisor user. | ||
| 40 | |**-pass**|The password of the supervisor user. | ||
| |
1.1 | 41 | |
| |
28.1 | 42 | = {{id name="__RefHeading___Toc476_3721803795"/}}Commands for adding users = |
| |
7.2 | 43 | |
| |
25.1 | 44 | (% class="box infomessage" %) |
| 45 | ((( | ||
| |
28.1 | 46 | ℹ If a user has an element (role, ACL group and profile) that does not exist at the time of import, the user is still added without this element. |
| |
25.1 | 47 | ))) |
| 48 | |||
| |
28.1 | 49 | There are three ways of adding a user in LDAP: |
| |
7.2 | 50 | |
| 51 | == create == | ||
| 52 | |||
| |
28.1 | 53 | In this mode the user will be added if, and only if, it does not exist. |
| 54 | In other words, with the create command, adding an existing user is an error. | ||
| |
7.2 | 55 | |
| |
22.1 | 56 | (% class="box" %) |
| 57 | ((( | ||
| |
28.1 | 58 | 💡 **Importing user profiles** |
| |
22.1 | 59 | |
| |
28.1 | 60 | You can import user profiles in create mode in the same way as users. |
| 61 | To do this, you can use the same file in Excel or CSV format as for importing users: | ||
| |
22.1 | 62 | |
| |
28.1 | 63 | 1. In the **uid**, **dn** and **cn** columns, instead of the user name, enter the name of the profiles with the prefix **"dd_profil_**" |
| 64 | For example: //"dd_profil_profilA" //with //profileA //the name of the profile. | ||
| 65 | You can view the file [[import_profile.csv>>attach:import_profil.csv]] file as an example. | ||
| 66 | 1. Run importtools as normal. | ||
| 67 | ➡ The profiles entered in the file will be created with their associated roles, ACLs, etc. | ||
| |
22.1 | 68 | ))) |
| 69 | |||
| |
7.2 | 70 | == overwrite == |
| 71 | |||
| |
28.1 | 72 | This command will overwrite an existing user. |
| 73 | The user is first deleted, then recreated with the new attributes. If it does not already exist, it is simply added. | ||
| |
7.2 | 74 | |
| 75 | == update == | ||
| 76 | |||
| |
28.1 | 77 | This command updates the user with the attributes present in your import file. |
| 78 | The user must already exist. It will not be deleted: its attributes will simply be added to those in the import file. | ||
| |
7.2 | 79 | |
| |
28.1 | 80 | = {{id name="__RefHeading___Toc476_3721803795"/}}Deleting users = |
| |
2.1 | 81 | |
| |
28.1 | 82 | It is possible to delete all or some of the users in the DigDash LDAP database, depending on their criteria. |
| |
2.1 | 83 | |
| 84 | |=Tag|=Description | ||
| |
28.1 | 85 | |**-removeall**|Removes ALL users present in LDAP AND the license. |
| 86 | |**-removeall -attr **"name of LDAP attribute" **-regexp **"value of attribute or regular expression|Removes all users whose specified ldap attribute value checks the regular expression. | ||
| 87 | |**-removeall -license_type **"all.missing.forbidden.[user type]"|((( | ||
| 88 | Removes all users according to their type or status in the licence: | ||
| |
5.1 | 89 | |
| |
28.1 | 90 | * **all**: all |
| 91 | * **missing **: users not in the licence | ||
| 92 | * **forbidden**: users in the licence but not authorised | ||
| 93 | * [**user type]**: possible values are **named**, **extranet**, **concurrent**, **public**, **broadcast**. | ||
| 94 | None, one or more values can be used, separated by a ".". | ||
| 95 | Example: named.extranet or missing.extranet.named | ||
| |
5.1 | 96 | |
| |
28.1 | 97 | At least one of these parameters must be used. |
| |
4.1 | 98 | ))) |
| |
2.1 | 99 | |
| |
28.1 | 100 | = {{id name="__RefHeading___Toc478_3721803795"/}}Exporting users = |
| |
2.1 | 101 | |
| |
28.1 | 102 | It is possible to export users from the LDAP database. |
| |
2.1 | 103 | |
| 104 | **Options :** | ||
| 105 | |||
| 106 | |=Tag|=Description | ||
| |
28.1 | 107 | |**-export**|Exports all users to a CSV file. By default, the export file is called users_export.csv. |
| 108 | |**-exportfile** "file.csv|Exports all users to the CSV file indicated by its absolute path (preceded by **-export**). | ||
| |
2.1 | 109 | |
| |
1.1 | 110 | (% id="HIV.Exemples" %) |
| |
28.1 | 111 | = {{id name="__RefHeading___Toc1856_2652393712"/}}General parameters = |
| |
1.1 | 112 | |
| |
3.1 | 113 | |(% colspan="2" %)**Logs** |
| |
28.1 | 114 | |**-log** "C:\temp"|The log file will be created in the specified directory, named as follows: importtool-yyyy-mm-dd_hh-mm-ss.log. |
| 115 | |**-log** "C:\log.txt"|The log file will be created in the directory and under the name specified. | ||
| 116 | |(% colspan="2" %)**Other** | ||
| 117 | |**-loginForm**|Forces LDAP authentication in the SSO case. | ||
| |
3.1 | 118 | |
| |
28.1 | 119 | = Examples = |
| |
3.1 | 120 | |
| |
1.1 | 121 | * **java -jar importtools.jar** |
| |
9.2 | 122 | * **java -jar importtools.jar -conf ../importtools/conf.xml -users ../importtools/users.xls -out ../importtools/out.xml** |
| |
28.1 | 123 | * **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** |
| |
1.1 | 124 | * **java -jar importtools.jar -export -server http:~/~/localhost:8080 -domain ddenterpriseapi -user admin -pass admin** |
| 125 | * **java -jar importtools.jar -export -exportfile "D:\my_users_export.csv" -server http:~/~/localhost:8080 -domain ddenterpriseapi -loginForm -user admin -pass admin** | ||
| 126 | * **java -jar importtools.jar -removeall -server http:~/~/localhost:8080 -domain ddenterpriseapi -user admin -pass admin** | ||
| 127 | * **java -jar importtools.jar -removeall -attr "license_type" -regexp "extranet" -server http:~/~/localhost:8080 -domain ddenterpriseapi -user admin -pass admin** | ||
| 128 | * **java -jar importtools.jar -removeall -attr "uid" -regexp "toto1[0-9]*" -server http:~/~/localhost:8080 -domain ddenterpriseapi -user admin -pass admin** | ||
| 129 | |||
| |
28.1 | 130 | = Troubleshooting encoding errors on Windows = |
| |
12.1 | 131 | |
| |
28.1 | 132 | Windows can contain encoding errors. To overcome these errors, you need to add the following command when exporting: |
| |
12.1 | 133 | |
| 134 | {{code language="shell"}} | ||
| 135 | -Dfile.encoding=utf-8 | ||
| 136 | {{/code}} | ||
| 137 | |||
| |
28.1 | 138 | This command is a parameter for JAVA, so you need to place it upstream of the options for importtool.jar. For example: |
| |
12.1 | 139 | |
| |
14.1 | 140 | {{code language="shell"}} |
| |
13.1 | 141 | "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" |
| 142 | {{/code}} | ||
| |
12.1 | 143 | |
| |
28.1 | 144 | = SSL certificate problem = |
| |
15.1 | 145 | |
| 146 | (% class="wikigeneratedid" id="HContexte" %) | ||
| |
28.1 | 147 | Running the **importtools **module to import users en masse to a DigDash server protected by an **SSL certificate, **from your local workstation or a workstation that is not the DigDash server, may fail due to incorrect configuration of the SSL certificate. |
| 148 | You are likely to get the following message when you run the script: | ||
| |
15.1 | 149 | |
| 150 | (% class="box errormessage" %) | ||
| 151 | ((( | ||
| |
28.1 | 152 | 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 |
| |
15.1 | 153 | ))) |
| 154 | |||
| 155 | (% class="wikigeneratedid" id="HContournement" %) | ||
| |
28.1 | 156 | To work around this problem : |
| |
15.1 | 157 | |
| |
28.1 | 158 | 1. Modify the **importools.bat** file **.** |
| 159 | 1. Add the **-DSSLNoPathCheck=true **parameter before **-jar **as in the example below: | ||
| |
15.1 | 160 | |
| 161 | (% class="box" %) | ||
| 162 | ((( | ||
| |
18.1 | 163 | 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 ~#~##DOMAINE~#~## -user admin -pass ~#~#PASS~#~# |
| |
15.1 | 164 | ))) |