0

我正在尝试进行交换查询以获取用户的同行,如全局地址列表中所示。我的第一个想法是运行一个查询,该查询返回具有同一管理器的所有用户。

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 托管 API。

任何帮助,将不胜感激。

4

1 回答 1

0

下面是如何使用 EWS for Exchange 2007 及更高版本访问 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");
        }
    }
}
于 2013-04-15T14:49:41.777 回答