使用EWS托管API验证登录凭证 [英] Validate login credentials using EWS Managed API

查看:96
本文介绍了使用EWS托管API验证登录凭证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以验证用户使用EWS托管API提供的登录凭据,而无需发送电子邮件.我在[ExchangeService]对象上使用AutodiscoverUrl方法,但是花费的时间太长?任何建议将不胜感激.

Is there a way to validate login credentials provided by a user using EWS Managed API without sending an email. I am using AutodiscoverUrl method on an [ExchangeService] object but it takes too long? Any suggestion would be appreciate it.

        try
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
            service.Credentials = new WebCredentials("xxxx@yyy.com", "password");
            service.AutodiscoverUrl("xxxx@yyy.com", RedirectionUrlValidationCallback);    

            Console.WriteLine("Credentials validated successfully");
            Console.ReadLine();

        }

        catch(Exception e)
        {
            Console.WriteLine(e.Message);
            Console.ReadLine();
        }

推荐答案

一种加快速度的方法(虽然不错,但可以正常工作)是自己设置服务网址. 首先通过在调试模式下运行autodiscoverurl方法获取交换服务URL:

One way to get this up to speed, not nice but it works, is to set the service url yourself. First get the exchange service url by running the autodiscoverurl method in debug mode:

然后,不要在服务上运行autodiscoverurl方法,而是添加从autodiscoverurl方法获得的url:

Then instead of running autodiscoverurl method on the service, add the url you got from the autodiscoverurl method:

 service.Url = new Uri("https://yourExchangeURL.com/EWS/Exchange.asmx");

您可以调用邮件帐户(

Instead of calling autodiscover to verify user credentials, you can make a request on the mail account (Check exchange credentials remotely and check user logged in)

var findFolderResults = service.FindFolders(WellKnownFolderName.Root, new SearchFilter.IsGreaterThan(FolderSchema.TotalCount, 0), new FolderView(10));

您的最终代码将如下所示

Your final code will then look like this

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials("xxxx@yyy.com", "password");
service.Url = new Uri("https://yourExchangeURL.com/EWS/Exchange.asmx");
var findFolderResults = service.FindFolders(WellKnownFolderName.Root, new SearchFilter.IsGreaterThan(FolderSchema.TotalCount, 0), new FolderView(10));

这篇关于使用EWS托管API验证登录凭证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆