MAPI Utility to add Ldap Address Books to existing Outlook profiles


Current version: 1.0.0.4

 

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 <one, default>] [-pn profilename] [-dn displayname] [-sn servername] 
 [-f configurationfilepath] [-m <listall, listone, create, update, remove>]
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

You can download the x86 and x64 executables , as well as the XML configuration file and if you’re interested in the behind the scenes, you can also download the source code. Ideally you would run this at logon as a one off. To do so you can use a script similar to this one that I’ve written a while back. For example:

RunExe.vbs "\\CONDC-01\Netlogon\LdapABManager" "LdapABManager.exe" "-m create -f '\\CONDC-01\Netlogon\LdapABManager\ABConfiguration.xml'" false

 

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.

Comments (10)

  1. truu says:

    Hi Andrei

    I’ve tryed your ldapabmanager with no luck.
    When I try to create a new ldap address book I get the following error:

    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.
    FAILED! hr = 80070057. LINE = 557
    >>> 00932FE8
    FAILED! hr = 80070057. LINE = 333
    >>> 00932498

    Best Regards
    Urs

    1. Andrei Ghita says:

      Hi,

      I’ve just posted version 1.0.0.4. That should fix the issue.

      I had a bit of a bug around creating the restriction for searching for the existing service but it should be all sorted now.

      Please test it and let me know if it works.

      Andrei

      1. truu says:

        Thanks for solving the error. Your tool works perfect now 🙂

        Thank you
        Urs

  2. Thanks for sharing. Found very useful, works like a charm. Because I would like to use ii in a logon script, it would be great if you could add a “quiet mode” switch to suppress any error message, especially the msgbox it shows when Outlook is not installed or the ldapabmanager version doesn’t match the Outlook version (x86/x64).
    Thank you.
    A.

  3. Christian says:

    Hello, we want to connect an LDAP AB via for Pool clients with a lot of userprofiles. Is it possible to use Wildcards and how? Thx a lot and BR Christian

  4. fa says:

    Hi! I have the same problem as truu with v.1.0.0.4.
    Tried to launch on w10 x64 with Outlook v15.

    C:\Users\fa\Downloads\LdapABManager_Exe\x64>LdapABManager.exe -m create -f “LdapABManager_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.
    FAILED! hr = 80070057. LINE = 557
    >>> 00007FF761D2B690
    FAILED! hr = 80070057. LINE = 333
    >>> 00007FF761D2AAE0

    XML:

    Company
    company.local
    389
    False

    True
    60
    100
    False
    OU=Contacts,DC=company,DC=local
    True

  5. Sergio says:

    Hi Andrei,

    Thank you very much for your application.

    May I ask you if there’s any way to update the filter in the ldap, the registry value it’s this one : 001e6624

    Thank you in advance.

    Wish you the best for 2017

  6. Hugo says:

    Dear Andrei,

    Thank you for your Ldap Manager, works great.

    Just one question, there’s any possiblity to have the switch to add the checknames ?

    Thank you again

    Hugo

  7. Jolanda Zuidhoek says:

    I was trying to use this program, because we want to add a LDAP addressbook to all our users. I add manually a LDAP addressbook and tried to use the list function. I get a error message. Something link Outlook is not your default e-mail client.

    I use it as followed:
    ldapABManager -m list

    Error message. :
    FAILED! hr=80004005. LINE = 390
    >>> 000000013F10AFD0

    What is going wrong?

    1. Andrei Ghita says:

      Hi there. Apologies for the delay, we need to do a better job at moderating our comments. I believe the bitness of the executable doesn’t match Outlook’s bitness. Try running the correct bitness, for example if Outlook is 32 bit then run the 32 bit ldap address book exe.

Skip to main content