以下是代码片段: 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), }; |
以下是代码片段: 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; } } |
关键是如下句:
以下是代码片段: System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); |
第二:打开Exchange 2010 服务器在命令行中输入
以下是代码片段: New-ManagementRoleAssignment -Name:impersonationAssignmentName -Role:ApplicationImpersonation -User:serviceAccount |
serviceAccount:就是我们要模拟其他人的账户