如何使用C#以编程方式检索SharePoint My-Sites用户的博客文章?

时间:2011-07-27 12:01:42

标签: c# sharepoint sharepoint-2010 blogs mysite

我设法访问用户个人资料内容:

    using (SPSite ospSite = new SPSite("http://localhost:80/"))
    {
        ServerContext s = ServerContext.GetContext(ospSite);
        UserProfileManager profileManager = new UserProfileManager(s);
        UserProfile p = profileManager.GetUserProfile("some_user");

        // e.g. responsibility retrieval
        var r = p["SPS-Responsibility"];
        var responsibilities = r.GetTaxonomyTerms();
    }

但我不知道如何访问用户的博客文章集。

有什么建议吗?

1 个答案:

答案 0 :(得分:4)

使用PersonalSite对象的UserProfile属性来检索用户的“我的网站”。

在SPSite循环中,子模板“博客”的SPWeb对象。在这里查看模板名称:

http://blogs.msdn.com/b/richin/archive/2011/07/04/sharepoint-2010-site-template-names.aspx

找到博客站点后,您只需访问SPWeb对象的“帖子”列表中的项目。