GetRoomLists succeeds but returns no data

后端 未结 1 914
北海茫月
北海茫月 2021-01-12 18:00

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 t

相关标签:
1条回答
  • 2021-01-12 18:24

    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.

    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.

    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;
    }
    
    0 讨论(0)
提交回复
热议问题