开发者

How to programmatically retrieve SharePoint My-Sites users' blog posts using C#?

开发者 https://www.devze.com 2023-03-23 11:32 出处:网络
I managed to access user profile con开发者_JS百科tent: using (SPSite ospSite = new SPSite(\"http://localhost:80/\"))

I managed to access user profile con开发者_JS百科tent:

    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();
    }

But I don't know how to access users' blog posts collection.

Any advice?


Use the PersonalSite property of UserProfile object to retrieve the user's My Site.

In the SPSite loop through, child SPWeb objects which are of template "Blog". Check out the templates names here:

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

Once you find the blog site, you can simply access the items in "Posts" List of the SPWeb object.

0

精彩评论

暂无评论...
验证码 换一张
取 消