I'm trying to do an exchange query to get a user's peers, as it is shown in Global Address List. My first thought is to run a query that returns all users with the same manager.
我正在尝试进行一个交换查询以获得一个用户的对等点,因为它显示在全局地址列表中。我的第一个想法是运行一个查询,该查询返回所有与同一个管理器的用户。
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);
Unfortunately this queries my contacts list, not the GAL. How can I do this correctly?
不幸的是,这个查询我的联系人列表,而不是GAL。我怎么能正确地做这个?
I cannot query AD (app is intended to run off of internal network) and also I don't use the EWS Managed API for various other reasons.
我不能查询AD(应用程序是为了运行内部网络),而且由于各种其他原因,我也不使用EWS托管API。
any help would be appreciated.
如有任何帮助,我们将不胜感激。
1 个解决方案
#1
0
Here's an example of how to access the GAL using EWS for Exchange 2007 and above; Taken From Here See the link for some valid pointers. This code searches the GAL for a particular contact.
这里有一个例子,说明如何使用EWS来访问2007年和以上的Exchange;从这里可以看到一些有效指针的链接。该代码在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");
}
}
}
#1
0
Here's an example of how to access the GAL using EWS for Exchange 2007 and above; Taken From Here See the link for some valid pointers. This code searches the GAL for a particular contact.
这里有一个例子,说明如何使用EWS来访问2007年和以上的Exchange;从这里可以看到一些有效指针的链接。该代码在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");
}
}
}