GetRoomLists成功,但不返回任何数据 [英] GetRoomLists succeeds but returns no data

查看:62
本文介绍了GetRoomLists成功,但不返回任何数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Exchange Web服务调用GetRoomLists,我们正在运行Exchange2010.下面的代码正在通过控制台应用程序执行.根据无错误"的XML响应,调用成功,但是没有数据返回.当您尝试通过Outlook约会添加一个房间时,我们列出了几百个房间,所以不确定为什么会发生这种情况.

I am calling GetRoomLists using Exchange Web Services, we are running Exchange 2010. The below code is being executed through a Console application. The call succeeds, per the XML response of "No Error", but no data is returned. We have several hundred rooms listed when you try to add one through an Outlook Appointment, so not sure why this would happen.

我尝试使用EWS DLL 1.2版和2.0版,使用默认凭据或传入凭据.在最初发布此消息后,我注意到响应标头说我们正在使用Exchange 2012 SP2,因此我尝试更新代码以使用该ExchangeVersion枚举值,但结果没有变化.

I've tried using both EWS DLL version 1.2 and 2.0, using default credentials or passing in credentials. I noticed after originally posting this that the response header says we are using Exchange 2012 SP2, so I tried updating my code to use that ExchangeVersion enum value, but no change in the result.

我已成功使用此Exchange服务器上的EWS读取邮箱,但之前从未有过房间.

I have successfully used EWS on this Exchange server to read mailboxes, but never rooms before.

C#

        ExchangeService es = new ExchangeService(ExchangeVersion.Exchange2010);
        es.TraceFlags = TraceFlags.EwsResponse | TraceFlags.EwsRequest;
        es.TraceEnabled = true;
        es.UseDefaultCredentials = true;
        es.AutodiscoverUrl("autodiscover@example.com");
        //this collection is empty after processing
        EmailAddressCollection eac = es.GetRoomLists();

来自Web服务请求/响应的XML跟踪

<Trace Tag="EwsRequest" Tid="9" Time="2013-03-13 20:39:41Z" Version="14.03.0032.000">
  <?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
      <t:RequestServerVersion Version="Exchange2010" />
    </soap:Header>
    <soap:Body>
      <m:GetRoomLists />
    </soap:Body>
  </soap:Envelope>
</Trace>

<Trace Tag="EwsResponse" Tid="9" Time="2013-03-13 20:39:41Z" Version="14.03.0032.000">
  <?xml version="1.0" encoding="utf-8"?>
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
      <h:ServerVersionInfo MajorVersion="14" MinorVersion="2" MajorBuildNumber="328" MinorBuildNumber="9" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <GetRoomListsResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
        <ResponseCode>NoError</ResponseCode>
        <m:RoomLists xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" />
      </GetRoomListsResponse>
    </s:Body>
  </s:Envelope>
</Trace>

GetRoomLists上的MSDN文档: http://msdn.microsoft.com/zh-CN/library/dd899416(v=exchg.140).aspx

MSDN Documentation on GetRoomLists: http://msdn.microsoft.com/en-us/library/dd899416(v=exchg.140).aspx

推荐答案

好了,我找到了原因/解决方案.混乱之处在于GetRoomLists不返回房间列表,而是返回房间列表或"Room Lists"集合的列表.这些是一种特殊的通讯组列表,其中包含房间列表.

Well I found the cause/solution. The confusion was in that GetRoomLists does not return a list of rooms, but instead a list of a list of rooms, or a collection of "Room Lists". These are a special type of distribution list that contains a list of rooms.

如此处所述, http://social .msdn.microsoft.com/Forums/zh-CN/exchangesvrdevelopment/thread/4ff04c60-48c2-4a69-ab75-2383e73bfde2 ,您要么需要设置会议室列表,要么需要查询AD并检查msExchRecipientDisplayType属性以追踪房间.

As outlined here, http://social.msdn.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/4ff04c60-48c2-4a69-ab75-2383e73bfde2, you either need to setup room lists or you need to query AD and check the msExchRecipientDisplayType attribute to track down the rooms.

此链接显示了如何编写LDAP查询以返回房间的示例:

This link shows an example of how to write the LDAP query to return rooms: http://social.msdn.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/e2d10953-a8f9-459c-8a0e-f10c2e568b26

我为寻找房间而组合的代码:

Code I put together for finding rooms:

private List<string> GetConfRooms(string filter)
{
    List<string> sRooms = new List<string>();

    DirectoryEntry deDomain = System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain().GetDirectoryEntry();
    DirectorySearcher dsRooms = new DirectorySearcher(deDomain);

    dsRooms.Filter = string.Format("(&(&(&(mailNickname={0}*)(objectcategory=person)(objectclass=user)(msExchRecipientDisplayType=7))))", filter);

    dsRooms.PropertiesToLoad.Add("sn");
    dsRooms.PropertiesToLoad.Add("mail");

    foreach (SearchResult sr in dsRooms.FindAll())
    {
        sRooms.Add(sr.Properties["mail"][0].ToString());
    }

    return sRooms;
}

这篇关于GetRoomLists成功,但不返回任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆