MAPI Utility to add Ldap Address Books to existing Outlook profiles 5/5 (1)

1+

Important

The sample in this blog post is superseeded by https://github.com/andreighita/MAPIToolkit. Please use MAPIToolkit instead.

I’ve had quite a few requests recently for a tool that can configure Ldap (Internet) Address Books in existing Outlook profiles. Since I don’t know of any tool to do this except for the good ole PRF import, I’ve decided to write some code for posterity. Unlike the PRF import, this tool will allow you to configure a username and a password for your Ldap Address Book(s).

How it works

The tool will connect to either the default profile or a profile of your choosing and it will either list, create, update or remove Ldap Address Books. Ldap Address Books are stored as EMABLT services in the MAPI profile, for which reason listing the Address Books comes down to searching for all EMABLT services and listing the properties and creating, updating and removing Address Books will obviously create, update and remove the associated services.

Usage information

LdapABManager - Ldap Address Book Manager
 Sample utility for listing, creating, updating or removing Ldap address books.
 Usage: LdapABManager [-?] [-pm ] [-pn profilename] [-dn displayname] [-sn servername] [-f configurationfilepath] [-m ]
 Options:
   -pm : Sets the profile mode.
         "default" to process the default profile.
         "one" to process a specific profile. Profile Name needs to be specified using -pn. 
         The default profile will be used if -pm is not used.
   -pn : Name of the profile to process. The Default profile will be used if -pn is not used.
   -dn : Display name of the Ldap Addressbook to list.
    -f : Full path to the XML configuration file. For example: "C:\LdapABManager\ABConfiguration.xml".
    -m : Sets the running mode.
         "list" to list all Ldap Addressbooks.
         "create" to create a new Ldap Addressbook. Must be used in conjunction with -f .
         "update" to update a specifc Ldap Addressbook. Must be used in conjunction with -dn, 
         optionally -sn and -f.
         "remove" to remove a specifc Ldap Addressbook. Must be used in conjunction with -dn and optionally -sn.
    -? : Displays this usage information.

Examples

>LdapABManager.exe -m list
Retrieved IProfAdmin interface pointer.
 Retrieved IMsgServiceAdmin interface pointer.
 Running in List mode.
 Retrieved message service table from profile.
 Set up restriction for searching Ldap AB services.
 Queried service table for Ldap AB services.
 Listing entry #0:
 Display Name : Contoso AB
 Ldap Server Name : ldap.contoso.com
 Ldap Server Port : 3268
 Username :
 Search Base :
 Search Timeout : 60
 Maximum entries : 100
 Use SSL : true
 Use SSL : false
 Use SSL : false
 Use SSL : true
>LdapABManager.exe -m update -dn “Contoso AB” -f “ABConfiguration.xml”
Retrieved IProfAdmin interface pointer.
 Retrieved IMsgServiceAdmin interface pointer.
 Running in Update mode.
 Retrieved message service table from profile.
 Set up restriction for searching Ldap AB service.
 Queried service table for Ldap AB service.
 Found one entry.
 Attempting encrypt password…DONE
 Attempting to update AB service…DONE
>LdapABManager.exe -m create -f “ABConfiguration.xml”
Retrieved IProfAdmin interface pointer.
 Retrieved IMsgServiceAdmin interface pointer.
 Running in Create mode.
 Retrieved message service table from profile.
 Set up restriction for searching Ldap AB service.
 Queried service table for Ldap AB service.
 Attempting ot obtain an IMsgServiceAdmin2 interface pointer…DONE
 Attempting to Create AB service…DONE
 Attempting to Configure AB service…DONE
>LdapABManager.exe -m remove -dn “Contoso AB”
Retrieved IProfAdmin interface pointer.
 Retrieved IMsgServiceAdmin interface pointer.
 Running in Remove mode.
 Retrieved message service table from profile.
 Set up restriction for searching Ldap AB service.
 Queried service table for Ldap AB service.
 Found one entry.
 Attempting to delete AB service…DONE

Resources

The sample in this blog post is superseeded by https://github.com/andreighita/MAPIToolkit. Please use MAPIToolkit instead.

Lastly

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This sample assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures.

Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

NB: If you run into any problems, please let me know and I will try and address them as soon as I can.

1+

Please rate this

Leave a Reply

Your email address will not be published. Required fields are marked *