以编程方式将 LDAP 帐户添加到 MS Outlook

Add LDAP account to MS Outlook programmaticaly

我为 Outlook 使用 RDO 库。

我添加 POP3 帐户没有问题。

        RDOSession Session = new RDOSession();
        Session.Logon();
        var AllAccounts = Session.Accounts;
        bool AccFound = false;
        foreach (RDOAccount acc in AllAccounts)
        {
            if (acc.Name.Equals("testacc@mail.loc", StringComparison.OrdinalIgnoreCase))
                AccFound = true;
        }
        if (!AccFound)
        {
            try
            {
                var POP3Account = AllAccounts.AddPOP3Account("Test Account", "testacc@mail.loc", "pop3.mail.loc", "smtp.mail.loc", "testacc@mail.loc", "Password");
                POP3Account.SMTP_UseAuth = true;
                POP3Account.Save();
            }
            catch
            { }
        }
        Session.Logoff();

没问题。

但我不明白如何将 LDAP 通讯簿帐户添加到我的 Outlook 配置中。

可能吗? 你能给我简单的示例(C#)吗?

感谢您的帮助。

已更新

可能对某人有帮助

     Dim Profiles = CreateObject("ProfMan.Profiles")
     Dim MyProfile = Profiles.Item("Outlook")
     Dim LDAPService = NewProfile.Services.Add("EMABLT", "Personal Folders", False)
     Dim Properties = CreateObject("ProfMan.PropertyBag")

     Properties.Add(PR_DISPLAY_NAME,"Name LDAP Address Book")
     Properties.Add(PR_LOCAL_HOST_NAME,"LDAP server")
     PropertiesLDAP.Add(&H66230003, "0") 'Enable custom search base
     Properties.Add(PR_PROFILE_USER,"dc=comp,dc=loc") 'Search base   
     Properties.Add(&H6615000B, "true") 'Enable SPA
     Properties.Add(&H6601001E, "3268") 'Port

     LDAPService.Configure(0, , Properties)

目前,只能添加 POP3/SMTP、PST 和委托 Exchange 帐户。 您应该能够使用 ProfMan library, but it is more low level - it will be your responsibility to set all the properties expected by the LDAP provider: you might want to take a look at an existing LDAP account with OutlookSpy(单击 IProfAdmin 或 IMAPISession | AdminServices)。

更新:从 5.23 版本开始,Redemption 将支持添加 LDAP 帐户。 5.23发布前,请联系redemption(at)dimastr(dot)com获取测试版。

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set LdapAccount = Session.Accounts.AddLDAPAccount("Test LDAP Account", _
                                     "www.zflexldap.com", 389, _
                                     "cn=ro_admin,ou=sysadmins,dc=zflexsoftware,dc=com", _
                                     "zflexpass")