Exchange2010 Ews 调用的时候需要注意到事项(模拟用户权限)

阅读: 267 评论: 2 作者: kaiser 发表于 2010-06-01 09:50 原文链接

第一:在调用的时候需要(2010 采用的是SSL加密的形式,所以我们调用的时候需要加上如下的代码,)

 

代码
<

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

>  ExchangeVersion RequestedServerVersion  =  config.ExchangeVersion  ==   " 2007 "   ?  ExchangeVersion.Exchange2007_SP1 : ExchangeVersion.Exchange2010;
            System.Net.ServicePointManager.CertificatePolicy 
=   new  TrustAllCertificatePolicy();
            service 
=   new  ExchangeService(RequestedServerVersion)
                          {
                              Url 
=   new  Uri(config.EWSServiceUrl),
                              Credentials 
=   new  NetworkCredential(config.ExchangeAdministrator,
                                                                  config.ExchangeAdministratorPassword,
                                                                  config.Domain),
                            


                          };

 

代码
<

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

>      public   class  TrustAllCertificatePolicy : System.Net.ICertificatePolicy
    {
        
public  TrustAllCertificatePolicy()
        { }

        
public   bool  CheckValidationResult(ServicePoint sp,
            System.Security.Cryptography.X509Certificates.X509Certificate cert,
            WebRequest req, 
int  problem)
        {
            
return   true ;
        }
    }

 

关键是如下句:

 

<

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

> System.Net.ServicePointManager.CertificatePolicy  =   new  TrustAllCertificatePolicy();

 
 

第二:打开Exchange 2010 服务器在命令行中输入

New-ManagementRoleAssignment -Name:impersonationAssignmentName -Role:ApplicationImpersonation -User:serviceAccount
serviceAccount:就是我们要模拟其他人的账户

参考资料:http://msdn.microsoft.com/en-us/library/bb204095.aspx

评论: 2 查看评论 发表评论

沪江网招聘ASP.NET开发工程师

最新新闻:
· 当微博连通大屏幕(2010-06-01 12:42)
· 从1.0到2.2 细数Android系统18个月历程(2010-06-01 12:07)
· 只因有你 回眸Qzone五年成长历程(2010-06-01 12:04)
· 谷歌手机Adsense冻结开发者账户遭质疑(2010-06-01 11:58)
· Chrome推送网页至手机功能视频展示(2010-06-01 11:55)

编辑推荐:关于Java与.NET的讨论

网站导航:博客园首页  个人主页  新闻  闪存  小组  博问  社区  知识库

你可能感兴趣的:(Exchange2010 Ews 调用的时候需要注意到事项(模拟用户权限))