获取房间列表? [英] Get a List of Rooms?

查看:84
本文介绍了获取房间列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Exchange 2007网络服务将日历集成到我的应用程序中。

I'm using the Exchange 2007 web service to integrate calendaring into my application.

 

我想知道是否有办法获得所有房间的清单吗?

I am wondering if there is a way to get a list of all rooms?

 

谢谢

推荐答案

在2007年的EWS中,没有任何东西可以轻松地做到这一点(在2010年的特定操作中)你更好地使用活动目录的LDAP查询,例如这是一个例子我在2007年用于房间和设备邮箱

In 2007 with EWS there is nothing that will do this easily (in 2010 there in a specific operation for this) your better of using a LDAP query of active directory instead eg this is one example I use for room and equipment mailboxes in 2007


  public XmlDocument FindRooms() {
    return FindMailboxes(7);
  }
  [WebMethod]
  public XmlDocument FindEquipment()
  {
    return FindMailboxes(8);
  }

  private XmlDocument FindMailboxes(int MailboxType) {
    string sqSearchQuery = "";
    string mtMailboxType = "";
    switch(MailboxType){ 
      case 7:
        sqSearchQuery = "(&(&(&(mailNickname=*)(objectcategory=person)(objectclass=user)(msExchRecipientDisplayType=7))))";
        mtMailboxType = "Room Mailbox";
        break;
      case 8:
        sqSearchQuery = "(&(&(&(mailNickname=*)(objectcategory=person)(objectclass=user)(msExchRecipientDisplayType=8))))";
        mtMailboxType = "Equipment";
        break;    
    }
    XmlDocument rdReturnResult = new XmlDocument();
    StringWriter xsXmlString = new StringWriter();
    XmlWriter xrXmlWritter = new XmlTextWriter(xsXmlString);
    xrXmlWritter.WriteStartDocument();
    xrXmlWritter.WriteStartElement("Resources");
    xrXmlWritter.WriteAttributeString("type", mtMailboxType);
    SearchResultCollection srSearchResults;
    string roRootDSE = dsDirectorySearcher.SearchRoot.Path;
	DirectoryEntry deDirectoryEntry = new DirectoryEntry(roRootDSE);
    DirectorySearcher dsDirectorySearcher = new DirectorySearcher(deDirectoryEntry);
    dsDirectorySearcher.SearchScope = SearchScope.Subtree;
    dsDirectorySearcher.Filter = sqSearchQuery;
    dsDirectorySearcher.PropertiesToLoad.Add("mail");
    dsDirectorySearcher.PropertiesToLoad.Add("msExchResourceCapacity");
    dsDirectorySearcher.PropertiesToLoad.Add("msExchResourceDisplay");
    dsDirectorySearcher.PropertiesToLoad.Add("co");
    dsDirectorySearcher.PropertiesToLoad.Add("displayName");
    dsDirectorySearcher.PropertiesToLoad.Add("department");
    dsDirectorySearcher.PropertiesToLoad.Add("description");
    dsDirectorySearcher.PropertiesToLoad.Add("physicalDeliveryOfficeName");
    dsDirectorySearcher.PropertiesToLoad.Add("postalCode");
    dsDirectorySearcher.PropertiesToLoad.Add("postOfficeBox");
    dsDirectorySearcher.PropertiesToLoad.Add("st");
    dsDirectorySearcher.PropertiesToLoad.Add("streetAddress");
    dsDirectorySearcher.PropertiesToLoad.Add("telephoneNumber");


    srSearchResults = dsDirectorySearcher.FindAll();
    foreach (SearchResult srSearchResult in srSearchResults)
    {
      xrXmlWritter.WriteStartElement("Mailbox");
      xrXmlWritter.WriteAttributeString("emailaddress",srSearchResult.Properties["mail"][0].ToString());
      WriteAttributeValue(xrXmlWritter, srSearchResult, "msExchResourceCapacity");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "msExchResourceDisplay");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "displayName");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "co");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "department");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "physicalDeliveryOfficeName");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "postalCode");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "postOfficeBox");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "st");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "streetAddress");
      WriteAttributeValue(xrXmlWritter, srSearchResult, "telephoneNumber");
      xrXmlWritter.WriteEndElement();



    }
    xrXmlWritter.WriteEndElement();
    xrXmlWritter.WriteEndDocument();
    rdReturnResult.LoadXml(xsXmlString.ToString());
    return rdReturnResult;

  }
 


这篇关于获取房间列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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