0

我有一个问题,尝试使用 Profman 为新配置文件配置 Exchange Online 邮件服务会导致身份验证提示,并且想知道是否有人以前以编程方式做过类似的事情,以及他们是否能够提供凭据/阻止提示从显示?

RDOSession profileSession = RedemptionLoader.new_RDOSession();

string proxy = String.Format("hknprd0204.outlook.com",machineName);
string server = String.Format("hknprd0204.mailbox.outlook.com", machineName);
string userName = "demo@pkstest.onmicrosoft.com";
string password = "P@ssw0rds";

profileSession.Credentials.Add(proxy, userName, password, CredentialPersist: rdoCredentialPersist.cpWindowsLogonSession);
profileSession.Credentials.Add(server, userName, password, CredentialPersist: rdoCredentialPersist.cpWindowsLogonSession);

newProfile = profiles.Add("ExchangeOnline");
newProfile.GlobalProfSect.set_Item((int)Redemption.MAPITags.PR_INTERNET_CONTENT_ID, server);
newProfile.GlobalProfSect.set_Item((int)Redemption.MAPITags.PR_DISPLAY_NAME, userName);

var newService = newProfile.Services.Add("MSEMS", "Microsoft Exchange", false);

ProfMan.PropertyBag properties = (ProfMan.PropertyBag)Activator.CreateInstance(Type.GetTypeFromProgID("ProfMan.PropertyBag"));

properties.Add((int)Redemption.MAPITags.PR_INTERNET_CONTENT_ID, server);
properties.Add((int)Redemption.MAPITags.PR_DISPLAY_NAME, userName);
properties.Add((int)Redemption.MAPITags.PR_PROFILE_HOME_SERVER, server);

properties.Add((int)Redemption.MAPITags.PR_PROFILE_UNRESOLVED_NAME, userName);
properties.Add((int)Redemption.MAPITags.PR_PROFILE_UNRESOLVED_SERVER, server);

properties.Add((int)Redemption.MAPITags.PR_ROH_FLAGS, 47);
properties.Add((int)Redemption.MAPITags.PR_ROH_PROXY_AUTH_SCHEME, Constants.RedemptionPropertyTags.ROHAUTH_BASIC);
properties.Add((int)Redemption.MAPITags.PR_ROH_PROXY_PRINCIPAL_NAME, "msstd:outlook.com");
properties.Add((int)Redemption.MAPITags.PR_ROH_PROXY_SERVER, proxy);
properties.Add((int)Redemption.MAPITags.PR_PROFILE_CONFIG_FLAGS, Constants.RedemptionPropertyTags.CONFIG_OST_CACHE_PRIVATE);

properties.Add((int)Redemption.MAPITags.PR_PROFILE_UI_STATE, 16640);

newService.ProfSect.set_Item((int)Redemption.MAPITags.PR_INTERNET_CONTENT_ID, server);

for (int i = 1; i <= newService.Providers.Count; i++)
{
    ProfMan.IProvider provider = newService.Providers.get_Item(i);
    switch (provider.ResourceType)
    {
        case 33:        //Microsoft Exchange Message Store  todo: constants these
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_DISPLAY_NAME, userName);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_INTERNET_CONTENT_ID, server);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_SERVER, server);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_DISPLAYNAME_SET, 1);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_CONFIG_FLAGS, Constants.RedemptionPropertyTags.CONFIG_OST_CACHE_PRIVATE);
            break;
        case 35:        //Exchange Directory Service
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_INTERNET_CONTENT_ID, server);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_CONFIG_FLAGS, Constants.RedemptionPropertyTags.CONFIG_OST_CACHE_PRIVATE);
            break;
        case 36:        //Exchange Transport
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_INTERNET_CONTENT_ID, server);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_SERVER, server);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_CONFIG_FLAGS, Constants.RedemptionPropertyTags.CONFIG_OST_CACHE_PRIVATE);
            break;
        default:        //0 = MSEMS         This is the provider that is causing the authentication prompt.
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_DISPLAY_NAME, userName);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_INTERNET_CONTENT_ID, server);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_HOME_SERVER, server);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_UNRESOLVED_NAME, userName);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_UNRESOLVED_SERVER, server);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_ROH_PROXY_PRINCIPAL_NAME, "msstd:outlook.com");
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_ROH_PROXY_SERVER, proxy);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_ROH_PROXY_AUTH_SCHEME, Constants.RedemptionPropertyTags.ROHAUTH_BASIC);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_ROH_FLAGS, 
                    Constants.RedemptionPropertyTags.ROHFLAGS_USE_ROH + 
                    Constants.RedemptionPropertyTags.ROHFLAGS_SSL_ONLY +
                    Constants.RedemptionPropertyTags.ROHFLAGS_MUTUAL_AUTH + 
                    Constants.RedemptionPropertyTags.ROHFLAGS_HTTP_FIRST_ON_SLOW + 
                    Constants.RedemptionPropertyTags.ROHFLAGS_HTTP_FIRST_ON_FAST);
            provider.ProfSect.set_Item((int)Redemption.MAPITags.PR_PROFILE_CONFIG_FLAGS, Constants.RedemptionPropertyTags.CONFIG_OST_CACHE_PRIVATE);
            break;
    }
}

newService.Configure(0, 0, properties);   //Prompts for authentication (and if credentials not cached in resultant prompt, when attempting to access the RDOStore later causes errors)

此外,使用上面的代码,如果我尝试在 Outlook 中打开帐户之前打开 RDOStore,或者没有在提示中缓存凭据,则会引发异常,指出 .OST 不是有效的存储。

到目前为止,我已经尝试过:

  • 向 RDOSession 添加凭据(如您在上面的代码示例中所见)
  • 在运行此代码之前手动将凭据添加到 Windows 凭据管理器(然后在 .Configure() 调用中仍会提示输入凭据)。

任何提示或想法将不胜感激!

4

1 回答 1

0

Outlook 使用凭据缓存,您可以使用 RDOSession.Credentials 访问它并预填充凭据: http ://www.dimastr.com/redemption/rdocredentials.htm 确保指定 cpWindowsLogonSession 以使其对 Outlook 可见(不仅仅是 Redemption)。

于 2012-03-27T17:30:33.647 回答