本文整理汇总了C#中ExchangeService.GetNetworkCredential方法的典型用法代码示例。如果您正苦于以下问题:C# ExchangeService.GetNetworkCredential方法的具体用法?C# ExchangeService.GetNetworkCredential怎么用?C# ExchangeService.GetNetworkCredential使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExchangeService
的用法示例。
在下文中一共展示了ExchangeService.GetNetworkCredential方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsEqual
/// <summary>
/// Determine if this ExchangeService instance is the same as the
/// given ExchangeService instance.
/// </summary>
/// <param name="service">"this" instance of ExchangeService</param>
/// <param name="service2">ExchangeService to compare to</param>
/// <returns>True if the connection properties of the given
/// ExchangeService are the same, False if not.</returns>
public static bool IsEqual(this ExchangeService service, ExchangeService service2)
{
if (service.Url != service2.Url)
{
return false;
}
// If RequestedServerVersion is specified they should be the same
if (service.RequestedServerVersion != service2.RequestedServerVersion)
{
return false;
}
// If both services have specified credentials they should be the same
if (service.Credentials != null && service2.Credentials != null)
{
NetworkCredential cred1 = service.GetNetworkCredential();
NetworkCredential cred2 = service2.GetNetworkCredential();
if ((cred1.UserName != cred2.UserName) ||
(cred1.Password != cred2.Password) ||
(cred1.Domain != cred2.Domain))
{
return false;
}
}
else
{
// If one doesn't have credentials setup then neither should
if (!(service.Credentials == null && service2.Credentials == null))
{
return false;
}
}
// If both services have impersonation setup, verify the values are the same
if (service.ImpersonatedUserId != null && service2.ImpersonatedUserId != null)
{
if (service.ImpersonatedUserId.Id != service2.ImpersonatedUserId.Id)
{
return false;
}
if (service.ImpersonatedUserId.IdType != service2.ImpersonatedUserId.IdType)
{
return false;
}
}
else
{
// If one doesn't have impersonation setup, then the should both not
// have it setup.
if (!(service.ImpersonatedUserId == null && service2.ImpersonatedUserId == null))
{
return false;
}
}
return true;
}