Chapter 4. Getting Started
The first thing you do in a MAPI application is to log on to MAPI, thereby creating a session that you can use to communicate with the server. The session itself represents one user logged on to the server.
In windows, you can create profile via the MAPI profile editor. In linux this component is not available, and therefore you must create a profile before logging on.
The profile contains information like the type of service (Zarafa in this case), and variables like username, password, path, proxy options, etc. If you have an existing profile, it’s easy to log on to such a profile:
import MAPI
session = MAPILogonEx(0, 'profilename', None, 0)
We simply pass the profile name and password (None in this case) and MAPI gives us a session object.
If you try this in linux, it will always fail; this is because linux does not keep a central log of profiles - each application starts fresh with no profiles. This means that you have to create a profile first. Since this is not a very simple operation, MAPI.Util provides us with a function to create a temporary profile, logon, and then delete the temporary profile:
import MAPI
from MAPI.Util import *
session = OpenECSession('username', 'password', 'http://localhost:236/zarafa')
This will work in both win32 and linux environments and will allow you to log on via HTTP, HTTPS or FILE (unix socket) connections.
If your application is running as a trusted user (see local_admin_users setting in zarafa’s server.cfg), then you can use the unix socket
file:///var/run/zarafa to connect with zarafa without specifying a password. This allows you to run a task as the target user without knowing the user’s password.