EWS -获取一个用户的同伴(相同的管理者)
本文关键字:管理者 获取 用户 EWS 一个 | 更新日期: 2023-09-27 18:07:45
我试图做一个交换查询来获得用户的对等体,如全局地址列表所示。我的第一个想法是运行一个查询,返回具有相同管理器的所有用户。
FindItemType request = new FindItemType();
DistinguishedFolderIdType[] fid = { new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.contacts } };
request.ParentFolderIds = fid;
request.Traversal = ItemQueryTraversalType.Shallow;
ItemResponseShapeType props = new ItemResponseShapeType();
props.BaseShape = DefaultShapeNamesType.AllProperties;
request.ItemShape = props;
// insert restriction where "someone@somewhere.com" = contactsManager
FindItemResponseType response = _binding.FindItem(request);
不幸的是,这查询我的联系人列表,而不是GAL。我怎样才能正确地做到这一点?
我无法查询AD(应用程序打算在内部网络上运行),而且由于各种其他原因,我也不使用EWS Managed API。
下面是如何在Exchange 2007及以上版本中使用EWS访问GAL的示例;请看一些有效指针的链接。此代码在GAL中搜索特定联系人。
static void Main(string[] args)
{
ExchangeServiceBinding esb = new ExchangeServiceBinding();
esb.Url = @"https://myserver/EWS/Exchange.asmx";
esb.Credentials = new NetworkCredential(
"username",
@"password",
@"domain");
// Create the ResolveNamesType and set
// the unresolved entry.
ResolveNamesType rnType = new ResolveNamesType();
rnType.ReturnFullContactData = true;
rnType.UnresolvedEntry = "test";
// Resolve names.
ResolveNamesResponseType resolveNamesResponse = esb.ResolveNames(rnType);
ArrayOfResponseMessagesType responses = resolveNamesResponse.ResponseMessages;
// Check the result.
if (responses.Items.Length > 0 && responses.Items[0].ResponseClass != ResponseClassType.Error)
{
ResolveNamesResponseMessageType responseMessage = responses.Items[0] as ResolveNamesResponseMessageType;
// Display the resolution information.
ResolutionType[] resolutions =
responseMessage.ResolutionSet.Resolution;
foreach (ResolutionType resolution in resolutions)
{
Console.WriteLine("Name: " + resolution.Contact.DisplayName);
Console.WriteLine("EmailAddress: " + resolution.Mailbox.EmailAddress);
if (resolution.Contact.PhoneNumbers != null)
{
foreach (PhoneNumberDictionaryEntryType phone in resolution.Contact.PhoneNumbers)
{
Console.WriteLine(phone.Key.ToString() + " : " + phone.Value);
}
}
Console.WriteLine("Office location:" + resolution.Contact.OfficeLocation);
Console.WriteLine("'n");
}
}
}