Csv import: Difference between revisions

From Open-Xchange
Line 23: Line 23:
This data is needed to create 5 new OX contexts including the mandatory contextadmin user. Modify the context id, password etc. for your needs.
This data is needed to create 5 new OX contexts including the mandatory contextadmin user. Modify the context id, password etc. for your needs.


To create the contexts from a CSV file, copy above data into new file called "contexts_list.csv"
To create the contexts from a CSV file, copy above data into new file called "contexts_list.csv" and execute following command:


<pre>
  $ /opt/open-xchange/sbin/createcontext -A oxadminmaster -P secret --csv-import contexts_list.csv
  $ /opt/open-xchange/sbin/createcontext -A oxadminmaster -P secret --csv-import contexts_list.csv
</pre>


In general, if you want to let the context admin use the OX GUI too, you also have to set


In general, if you want to let the context admin use the OX GUI too, you also have to set
<pre>
mail.properties:com.openexchange.mail.adminMailLoginEnabled=true
mail.properties:com.openexchange.mail.adminMailLoginEnabled=true
</pre>


in the file <code>/opt/open-xchange/etc/groupware/mail.properties</code>
in the file  
<code>/opt/open-xchange/etc/groupware/mail.properties</code>


=== Importing users to an existing context ===
=== Importing users to an existing context ===

Revision as of 14:30, 24 August 2011

Create OX Contexts and OX Users from CSV Data

It is possible to create a batch of contexts and users with the "createcontext" and "createuser" commandline tool to make the migration of existing data easier.

For this you need to export your existing userdata to a CSV (Comma-Separated Values) file with the following structure:

Note: The first line defines the fields and have to be in every file you want to import. Due to linebreaks you will probably see more than 3 lines, just copy and paste the example to an editor of your choice or reduce the font size.

Generate new contexts

If you need to initially create new contexts into OX via CSV import functionality, you have to create CSV data which cover the context informations and also the informations which are needed for the context admin user.

contextid,addmapping,username,password,displayname,givenname,surname,email,imaplogin,imapserver,smtpserver,quota,access-combination-name,language,timezone
"100","loginmapping_100","contextadmin","contextadminpassword","Context Admin 100","Context 100","Admin","admin_100@mymailserver.org","context_","imap://imapserver100:143","smtp://mailserver100:25","1024","all","en_GB","Europe/London"
"101","loginmapping_101","contextadmin","contextadminpassword","Context Admin 101","Context 101","Admin","admin_101@mymailserver.org","context_","imap://imapserver101:143","smtp://mailserver101:25","1024","all","en_GB","Europe/London"
"102","loginmapping_102","contextadmin","contextadminpassword","Context Admin 102","Context 102","Admin","admin_102@mymailserver.org","context_","imap://imapserver102:143","smtp://mailserver102:25","1024","all","en_GB","Europe/London"
"103","loginmapping_103","contextadmin","contextadminpassword","Context Admin 103","Context 103","Admin","admin_103@mymailserver.org","context_","imap://imapserver103:143","smtp://mailserver103:25","1024","all","en_GB","Europe/London"
"104","loginmapping_104","contextadmin","contextadminpassword","Context Admin 104","Context 104","Admin","admin_104@mymailserver.org","context_","imap://imapserver104:143","smtp://mailserver104:25","1024","all","en_GB","Europe/London"
"105","loginmapping_105","contextadmin","contextadminpassword","Context Admin 105","Context 105","Admin","admin_105@mymailserver.org","context_","imap://imapserver105:143","smtp://mailserver105:25","1024","all","en_GB","Europe/London"

This data is needed to create 5 new OX contexts including the mandatory contextadmin user. Modify the context id, password etc. for your needs.

To create the contexts from a CSV file, copy above data into new file called "contexts_list.csv" and execute following command:

 $ /opt/open-xchange/sbin/createcontext -A oxadminmaster -P secret --csv-import contexts_list.csv

In general, if you want to let the context admin use the OX GUI too, you also have to set

mail.properties:com.openexchange.mail.adminMailLoginEnabled=true

in the file /opt/open-xchange/etc/groupware/mail.properties

Importing users to an existing context

adminuser,adminpass,contextid,username,displayname,givenname,surname,password,email,imaplogin,imapserver,smtpserver,quota,access-combination-name,language,timezone
oxadmin110,secret,110,pete_test,Pete Test,Pete,Test,secret,pete_test@mymailserver.org,pete_test,imap://imapserver:143,smtp://mailserver:25,1024,all,de_DE,Europe/Berlin
oxadmin110,secret,110,sandra_linux,Sandra  Linux,Sandra,Linux,secret,sandra_linux@mymailserver.org,sandra_linux,imap://imapserver:143,smtp://mailserver:25,1024,all,en_GB,Europe/London

oxadmin110 is the adminuser of the context 110 with the password secret. There will be 2 users imported to the context (110), pete_test and sandra_linux. To import the users:

$ /opt/open-xchange/sbin/createuser --csv-import myuserlist.csv

Definitions

Language codes: you can use the same you have in the language menue for the user, like de_DE, en_GB, en_US, jp_JP ...

A list of timezones: Wikipedia:Zone.tab