当前位置: 首页>>代码示例>>C#>>正文


C# ExchangeService.GetNetworkCredential方法代码示例

本文整理汇总了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;
        }
开发者ID:haiyangIt,项目名称:Haiyang,代码行数:68,代码来源:ExchangeServiceExtensions.cs


注:本文中的ExchangeService.GetNetworkCredential方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。