* http://tracker.openchange.org/projects/openchange/wiki/HowTo_Install_OpenChange_From_Source

From a base install of ubuntu 10.04 server.

OpenChange

Dependencies

First, install the dependencies needed to build both OpenChange and Samba4 :

Source Code

Checkout the source from the sogo branch:

mkdir openchange
cd openchange
svn co -r 2970 http://svnmirror.openchange.org/openchange/branches/sogo

Samba4 compilation

The following steps have to be done since OpenChange makefiles are configured to install samba4 under /usr/local/samba:

# Teach ld.so about the non standard location of samba4 libraries
sudo su -c 'echo "/usr/local/samba/lib" > /etc/ld.so.conf.d/samba4.conf'

# update PKG_CONFIG_PATH and PYTHONPATH
sudo su -c 'echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/samba/lib/pkgconfig; export PKG_CONFIG_PATH" >> /etc/profile.d/samba4-env-build.sh'
sudo su -c 'echo "PYTHONPATH=$PYTHONPATH:/usr/local/samba/lib/python2.6/site-packages; export PYTHONPATH" >> /etc/profile.d/samba4-env-build.sh'
. /etc/profile.d/samba4-env-build.sh

Once the environment is set, use the samba target to build and install samba4. This requires internet access from the host since it fetches the source code tarball from the samba web site. These commands can be run as a normal user with sudo access. The current code only works with samba-4.0.0alpha14. This is defined in script/samba4_ver.sh

cd sogo
make samba
sudo ldconfig

Fix tdb_wrap.h

There is an error in a samba4 header file, until this is fixed upstream the following patch has to be applied to /usr/local/samba/include/tdb_wrap.h:

--- tdb_wrap.h.ori      2011-06-14 12:21:02.389043803 -0400
+++ tdb_wrap.h  2011-06-14 12:18:21.741047467 -0400
@@ -29,7 +29,7 @@
 #ifndef _TDB_WRAP_H_
 #define _TDB_WRAP_H_
 
-#include <../lib/tdb/include/tdb.h>
+#include <tdb.h>
 
 struct tdb_wrap {
        struct tdb_context *tdb;

At this point, samba4 should be installed under /usr/local/samba/

Build OpenChange

Launch the configure scripts:  make clean && ./autogen.sh && ./configure --prefix=/usr/local/samba 

This should yield an output similar to the following:

===============================================================
OpenChange Configuration (Please review)

           * OpenChange Libraries:
             - libmapi (C library):     yes
                      Thread support:   yes (pthread)
             - libmapi++ (C++ library): yes
             - libmapiadmin:            yes
             - libocpf:                 yes

           * OpenChange Server:
             - mapiproxy:               yes

           * OpenChange mapistore backends:
             - sqlite3:                 no

           * OpenChange Tools:
             - openchangeclient:        yes
             - mapiprofile:             yes
             - openchangepfadmin:       yes
             - exchange2mbox:           yes
             - exchange2ical:           yes
             - mapitest:                yes
             - openchangemapidump:      yes
             - schemaIDGUID:            yes

           * subunit format (mapitest): no

           * OpenChange Documentation:  yes

           * Coverage Tests:            no

           * OpenChange Bindings:
             - Python:                  no
             - Qt4:                     no

           * Installation prefix:       /usr/local/samba


===============================================================

Compile and install OpenChange:

make
sudo make install
sudo ldconfig

SOGo

Dependencies

 sudo apt-get install monotone gnustep-make gnustep-base-runtime devscripts debhelper libgnustep-base-dev gobjc libxml2-dev libldap2-dev libssl-dev zlib1g-dev libpq-dev libmysqlclient-dev libmemcached-dev 

This will pull in postfix, simply select "Local site" for local mail only or use "Internet site with smarthost" if you want to relay mail through another smtp server.

Getting the sources and compiling SOGo

Fetch the latest sources :

mtn db init --db=~/db.mtn
mtn --db=~/db.mtn pull inverse.ca ca.inverse.sogo
mtn --db=~/db.mtn pull inverse.ca ca.inverse.sope
cd $HOME
mtn --db=~/db.mtn checkout --branch ca.inverse.sogo SOGo
mtn --db=~/db.mtn checkout --branch ca.inverse.sope SOPE

SOPE has to be installed first since SOGo depend on it:

cd SOPE
./configure --with-gnustep --enable-debug --disable-strip
make
sudo make install

Compile and install SOGo:

cd ../SOGo
./configure --enable-debug --disable-strip
make
sudo make install

SOGo Configuration

Next thing to do is to configure SOGo to use your current services, which are: IMAP, SMTP, SQL databases. The configuration instructions for this are available in the SOGo Installation and Configuration guide

SOGo OpenChange plugin

Run the the following commands to compile and install the SOGo OpenChange plugin:

cd OpenChange
make
sudo PKG_CONFIG_PATH=$PKG_CONFIG_PATH make install

OpenChange/Samba4 configuration

From the openchange/sogo/samba4/source4/ directory, run the following commands as root:

cd ~/openchange/sogo/samba4/source4
sudo PYTHONPATH=$PYTHONPATH ./setup/provision --realm=OPENCHANGE.LOCAL --domain=OPENCHANGE --adminpass='%1OpenChange' --server-role='domain controller'

Add the openchange user to samba. This is the user to use for testing outlook:

cd ~/openchange/sogo/samba4/
sudo ./bin/samba-tool newuser openchange openchange

Note that you don't necessarily need to use the openchange user. If you have bob, which is also defined in your LDAP/Active Directory/SQL authentication source, you can simply use this and adjust the instructions below accordingly.

Provision the OpenChange server by running the following commands:

cd ~/openchange/sogo/setup
sudo PYTHONPATH=$PYTHONPATH ./openchange_provision

NOTE: This operation can take several minutes
[+] Step 1: Register Exchange OIDs
[+] Step 2: Add Exchange attributes to Samba schema
[+] Step 3: Add Exchange auxiliary classes to Samba schema
[+] Step 4: Add Exchange objectCategory to Samba schema
[+] Step 5: Add Exchange containers to Samba schema
[+] Step 6: Add Exchange *sub* containers to Samba schema
[+] Step 7: Add Exchange CfgProtocol subcontainers to Samba schema
[+] Step 8: Add Exchange mailGateway subcontainers to Samba schema
[+] Step 9: Add Exchange classes to Samba schema
[+] Step 10: Add possSuperior attributes to Exchange classes
[+] Step 11: Extend existing Samba classes and attributes
[+] Step 12: Exchange Samba with Exchange configuration objects
[SUCCESS] Done!

Provision the OpenChange Database:

sudo PYTHONPATH=$PYTHONPATH ./openchange_provision --openchangedb

Setting up openchange db
[+] Public Folders
===================
        * Public Folder Root                       0x0100000000000001
        * IPM_SUBTREE                              0x0200000000000001
        * NON_IPM_SUBTREE                          0x0300000000000001
        * EFORMS REGISTRY                          0x0400000000000001
        * OFFLINE ADDRESS BOOK                     0x0500000000000001
        * /o=First Organization/cn=addrlists/cn=oabs/cn=Default Offline Address Book 0x0600000000000001
        * SCHEDULE+ FREE BUSY                      0x0700000000000001
        * EX:/o=First Organization/ou=Exchange Administrative Group (UBUNTU-OC) 0x0800000000000001
        * Events Root                              0x0900000000000001

Create an OpenChange user:

sudo PYTHONPATH=$PYTHONPATH ./openchange_newuser --create openchange

[+] User openchange extended and enabled

Create the associated mailbox:

sudo PYTHONPATH=$PYTHONPATH ./openchange_newuser --mailbox openchange

[+] Mailbox for 'openchange'
============================
* GlobalCount (0xa) and ReplicaID (0x1)
* Mapistore content repository created: /usr/local/samba/private/mapistore/openchange
* User object created: CN=openchange,CN=First Organization Unit,CN=First Organization,CN=UBUNTU-OC,DC=openchange,DC=local
* Adding System Folders
        * Mailbox Root                            : 0x0a00000000000001
        * Deferred Actions                        : 0x0b00000000000001
        * Common Views                            : 0x0c00000000000001
        * Search                                  : 0x0d00000000000001
        * Schedule                                : 0x0e00000000000001
        * Shortcuts                               : 0x0f00000000000001
        * To-Do Search                            : 0x1000000000000001
        * Views                                   : 0x1100000000000001
        * Spooler Queue                           : 0x1200000000000001
        * IPM Subtree                             : 0x1300000000000001
        * Sent Items                              : 0x1400000000000001
        * Outbox                                  : 0x1500000000000001
        * Inbox                                   : 0x1600000000000001
        * Deleted Items                           : 0x1700000000000001
        * Reminders                               : 0x1800000000000001
* Adding Special Folders:
        * Calendar                                : 0x1900000000000001 (IPF.Appointment)
        * Contacts                                : 0x1a00000000000001 (IPF.Contact)
        * Journal                                 : 0x1b00000000000001 (IPF.Journal)
        * Notes                                   : 0x1c00000000000001 (IPF.StickyNote)
        * Tasks                                   : 0x1d00000000000001 (IPF.Task)
        * Drafts                                  : 0x1e00000000000001 (IPF.Note)
* Adding default Receive Folders:
        * All                                      Message Class added to 0x1600000000000001
        * IPM                                      Message Class added to 0x1600000000000001
        * Report.IPM                               Message Class added to 0x1600000000000001
        * IPM.Note                                 Message Class added to 0x1600000000000001
        * IPC                                      Message Class added to 0x1300000000000001
* Adding additional default properties to Inbox
* Adding additional default properties to Reminders
* GlobalCount (0x1f)

Adding users

To add another user to OpenChange, run the following commands:

# add user to samba
cd ~/openchange/sogo/samba4/source4
sudo ./bin/samba-tool newuser username password

# create user in openchange
cd ~/openchange/sogo/setup
sudo ./openchange_newuser --create username

# create his mailbox
sudo ./openchange_newuser --mailbox username

There is currently a limitation in the provisionning script: the password of the user is set to the same value as the username. To overcome this limitation, one must edit the openchange.ldb and fix the mapistore_uri:

echo "%s/:username@/:password@/g
w
q
" | /usr/local/samba/bin/ldbedit -H /usr/local/samba/private/openchange.ldb -e ex

A user that exists in your current LDAP/Active Directory server must also be created (for now) in OpenChange. Otherwise, it will not work.

Samba Configuration

Add the following parameters to the [global] section of /usr/local/samba/etc/smb.conf:

### Configuration required by OpenChange server ###
dcerpc endpoint servers = epmapper, mapiproxy
dcerpc_mapiproxy:server = true
dcerpc_mapiproxy:interfaces = exchange_emsmdb, exchange_nsp, exchange_ds_rfr
### Configuration required by OpenChange server ###

Since samba will be started as root, the sogo configuration files will be looked up under root's home directory. Create the following symlink to make sure that samba will find the configuration file:

ln -s ~sogo/GNUstep /root/ 

Start samba :

sudo /usr/local/samba/sbin/samba -d3 -i -M single

At this point samba should be running in the frontend in interactive mode. The logs can be found in /usr/local/samba/var/samba.log when samba runs daemonized.

Outlook Client

Outlook will use the hostname returned by samba. In this document, the hostname was "ubuntu-oc.openchange.local". If proper DNS resolution is not in place, the hosts file will have to be modified.

Add an entry like the following to c:\windows\system32\drivers\etc\hosts :

192.168.56.101  ubuntu-oc.openchange.local

To configure outlook :

Start outlook and enter your username and password (openchange/openchange), it should now start to synchronize. If you have a lot of information, especially mails, this process could take ages. It's recommended that you use test users.