获取if"允许管理内容类型"使用SharePoint WebServices进行检查

时间:2015-01-05 05:23:45

标签: c# sharepoint sharepoint-webservice

我是否需要有关SharePoint文档库的信息是否选中“允许管理内容类型”。我必须使用SharePoint Web服务。

我在Lists.asmx中查找了GetListAndView方法,但在“List”节点或“View”节点中没有找到引用内容类型管理的属性。

有人可以帮帮我吗?

谢谢:)

1 个答案:

答案 0 :(得分:0)

您可以从lists.asmx的GetList()方法获取它。看看Flags属性。

更好的是,来自https://social.technet.microsoft.com/Forums/sharepoint/en-US/9d6c26a5-279e-4f4e-8dfc-b31acff81813/web-service-to-check-if-the-management-of-content-types-are-allowed?forum=sharepointgeneralprevious

的示例代码
public static bool GetAllowContentTypes(string listName)
  {
            listservice.Lists ls = new listservice.Lists();
            ls.Url = "http://basesmc2008/_vti_bin/lists.asmx";
            ls.UseDefaultCredentials = true;
            UInt64 flags = 0;
            bool contentTypesAllowed = false;

            XmlNode node = ls.GetList(listName);
            XElement element = XElement.Parse(node.OuterXml);

            var result = from e in element.Attributes("Flags")
                                                  select  e.Value;

            if (result != null && UInt64.TryParse(result.First().ToString(), out flags))
                contentTypesAllowed = ((flags & ((ulong)0x400000L)) != 0L);
            else
                return false;

            return contentTypesAllowed;

}