本文整理汇总了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;
}
}
示例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 "";
}
示例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;
}
}
}
}
}
示例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);
}
}