开发者

Accessing SharePoint structure and user infpormation from ASP.NET

I am looking at ways of limiting data (pages) visible to users based on their SharePoint group memberships. One option is to run my site on it's own, determine group membership in code, and limit data available, and the other, less attractive option is to deploy my site to several departmental sites, and then determine which data to present according to the parent site that mine is hosted under.

In either case, I need to access some sort of SharePoint API to determine either the location of my site, o开发者_开发百科r the group membership of the logged on user. How can I go about getting this information?


You could use a Web Part and programmatically security trim links in the WP. In any case, Groups are created at the site collection level and assigned to a site. If you have a site located at mycompany/mydeptsite, you could use:

SPSite siteCollection = new SPSite("http://mycompany/mydeptsite");
SPWeb site = siteCollection.OpenWeb();

foreach(SPGroup group in site.Groups)
{
    Console.WriteLine(group.Name);
}

Some more info: http://blog.mastykarz.nl/inconvenient-programmatically-sharepoint-users-spweb-ensureuser/


You don't need to do anything in code. Based on your description, you are trying to limit access to data on pages, based on their membership of a particular SharePoint group. Break the inheritance from the main site and just configure access for those in that SharePoint group...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜