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


C# ExchangeService.ResolveName方法代码示例

本文整理汇总了C#中ExchangeService.ResolveName方法的典型用法代码示例。如果您正苦于以下问题:C# ExchangeService.ResolveName方法的具体用法?C# ExchangeService.ResolveName怎么用?C# ExchangeService.ResolveName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExchangeService的用法示例。


在下文中一共展示了ExchangeService.ResolveName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckLogin

        /// <summary>
        /// Connects with the Sioux Exchange server to check whether the given username/password are valid
        /// Sioux credentials. Note: this method may take a second or two.
        /// </summary>
        public static bool CheckLogin(string username, string password)
        {
            Console.WriteLine("Connecting to exchange server...");
            ServicePointManager.ServerCertificateValidationCallback = StolenCode.CertificateValidationCallBack;

            var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
            service.Credentials = new WebCredentials(username, password, Domain);
            service.Url = new Uri("https://" + ExchangeServer + "/EWS/Exchange.asmx");
            service.UseDefaultCredentials = false;

            try
            {
                // resolve a dummy name to force the client to connect to the server.
                service.ResolveName("garblwefuhsakldjasl;dk");
                return true;
            }
            catch (ServiceRequestException e)
            {
                // if we get a HTTP Unauthorized message, then we know the u/p was wrong.
                if (e.Message.Contains("401"))
                {
                    return false;
                }
                throw;
            }
        }
开发者ID:eteeselink,项目名称:sioux_tech_radar,代码行数:30,代码来源:SiouxExchangeServer.cs

示例2: GetPrimarySmtpAddress

 /// <summary>
 /// This function resolve the primary smtp email
 /// </summary>
 /// <param name="service"></param>
 /// <param name="email"></param>
 /// <returns></returns>
 public string GetPrimarySmtpAddress(ref ExchangeService service, string email)
 {
     foreach (var resolution in service.ResolveName("smtp:" + email))
     {
         if (resolution.Mailbox.MailboxType == MailboxType.Mailbox)
         {
             return resolution.Mailbox.Address;
         }
     }
     return "";
 }
开发者ID:NosDeveloper2,项目名称:RecruitGenie,代码行数:17,代码来源:ExchangeProcessor.cs

示例3: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["EmployeeId"] != null)
            {
                if (!IsPostBack)
                {
                    EmployeeView view = new EmployeeMapper().Get(new EmployeeEntity() { Id = Convert.ToInt32(Request.QueryString["EmployeeId"]) });
                    if (view.Id != 0)
                    {
                        EmployeeNameLabel.Text = view.ToString();
                        JobTitleAndUnitLabel.Text = view.Job + " at " + view.OrganizationalUnit;
                        EmployeeNoLabel.InnerText = view.EmployeeNo;
                        PersonalNoLabel.InnerText = view.PersonalNumber;
                        DateOfBirthLabel.InnerText = view.DateOfBirth.ToShortDateString();
                        GenderLabel.InnerText = view.Gender.ToString();
                        CountryLabel.InnerText = view.Country;
                        NationalityNoLabel.InnerText = view.Nationality;
                        CityLabel.InnerText = view.City;
                        tMobilePhoneLabel.InnerText = view.MobilePhone;
                        WorkEmailLabel.InnerText = view.WorkEmail;
                    }
                    else
                    {
                        Response.Redirect("List.aspx");
                    }
                }
                else
                {
                    if (userTextBox.Text != "")
                    {
                        //PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
                        //UserPrincipal user = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, userTextBox.Text);
                        //if (user != null)
                        //{
                        //    if (user.UserPrincipalName != null)
                        //    {
                        //        EmailAddressTextBox.Text = user.UserPrincipalName;
                        //    }
                        //}
                        //else
                        //{
                        //    EmailAddressTextBox.Text = "";
                        //}

                        // Get the number of items in the Contacts folder. To keep the response smaller, request only the TotalCount property.
                        ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
                        service.Url = new Uri(@"https://mail.kpaonline.org/EWS/Exchange.asmx");
                        service.Credentials = new NetworkCredential("[email protected]", "Passsygtech456");

                        System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender1, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

                        NameResolutionCollection nameResolutions = service.ResolveName(
                         userTextBox.Text,
                         ResolveNameSearchLocation.DirectoryOnly,
                         true);

                        foreach (NameResolution nameResolution in nameResolutions)
                        {
                            EmailAddressTextBox.Text = nameResolution.Mailbox.Address;
                        }
                    }
                }
            }
        }
开发者ID:GramozKrasniqi,项目名称:HRMS,代码行数:64,代码来源:LinkToUser.aspx.cs

示例4: resolveAccount

        private void resolveAccount(ExchangeAccount account)
        {
            ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

            ExchangeService service = new ExchangeService((ExchangeVersion)account.EwsVersion)
            {
                Credentials = new WebCredentials(
                    account.Account,
                    RsaUtil.Decrypt(account.Password)
                    ),
            };

            try
            {
                if (!string.IsNullOrWhiteSpace(account.Url))
                {
                    service.Url = new Uri(account.Url);
                }
                else
                {
                    service.AutodiscoverUrl(account.Account, RedirectionUrlValidationCallback);
                }

                var match = service.ResolveName(account.Account);
                if (match.Count == 0)
                {
                    throw new Exception();
                }
            }

            catch (Exception)
            {
                ModelState.AddModelError("Account", Resources.CouldNotBeResolved);
            }
        }
开发者ID:Fivebread,项目名称:DisplayMonkey,代码行数:35,代码来源:ExchangeAccountController.cs


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