特定组的SharePoint权限

特定组的SharePoint权限,sharepoint,permissions,usergroups,Sharepoint,Permissions,Usergroups,我试图确定某个特定组是否具有对特定网站集的读取权限 我已经尝试了一天半,但感觉好像我找到了三种不同的解决方案 到目前为止,我掌握的代码片段有: using (SPSite site = new SPSite(this.GenerateAbsoluteUri(moduleCode, academicYear))) { using (SPWeb web = site.OpenWeb()) { for (int i = web.SiteGroups.Count - 1;

我试图确定某个特定组是否具有对特定网站集的读取权限

我已经尝试了一天半,但感觉好像我找到了三种不同的解决方案

到目前为止,我掌握的代码片段有:

using (SPSite site = new SPSite(this.GenerateAbsoluteUri(moduleCode, academicYear)))
{
    using (SPWeb web = site.OpenWeb())
    {
        for (int i = web.SiteGroups.Count - 1; i >= 0; i--)
        {
            SPGroup group = web.SiteGroups[i];

            if (Regex.IsMatch(group.Name, theGroupImLookingFor))
            {
那又怎么样

我的大多数谷歌搜索结果都告诉我角色,但我不知道如何将角色与团队联系起来


请帮忙

这里是我自己的代码片段(Sharepoint 2010)。 创建角色:

SPRoleDefinition network_role = new SPRoleDefinition();
                network_role.BasePermissions = SPBasePermissions.AddListItems |
                    SPBasePermissions.BrowseDirectories |
                    SPBasePermissions.EditListItems |
                    SPBasePermissions.DeleteListItems;
                network_role.Name = "Network - Project Member";
                network_role.Description = "Provides permissions required for a member of a project.";

                web.RoleDefinitions.Add(network_role);
向组中添加角色:

var assign = new SPRoleAssignment(oweb.SiteGroups["Network Project - " + item.Code]);
assign.RoleDefinitionBindings.Add(network_role);

要将权限分配给用户(帐户)或SharePoint组,我们需要按特定顺序查看一些对象。我们需要做的第一件事是获取要将角色分配给的安全主体(SPUser或SPGroup)。接下来我们需要做的事情是获得我们想要分配的实际权限(角色)(例如:读取、完全控制等)。然后,我们需要创建一个SPRoleAssignment对象,并在构造函数上将其传递到我们要向其分配权限的SPUser或SPGroup(安全主体)中。现在我们需要将角色定义添加到角色分配对象的RoleDefinitionBindings集合中。然后我们需要将实际的角色分配添加到web(站点)并更新web。下面是完整的代码lisitng

// Create the site that contains our list
using(SPSite oSite = new SPSite("<<my site url>>"))
{
    // Open the web object
  using(SPWeb oWeb = oSite.OpenWeb())
  {

    // Get the group that we want to add the user to
    SPGroup oGroup = oWeb.Groups["<<group name>>"];

    // Get the role definition we want to assign ex: Full Control
    SPRoleDefinition oRole = oWeb.RoleDefinitions["<< role name>>"];

    // Create the role assignment object
    SPRoleAssignment oRoleAssignment = new SPRoleAssignment(oGroup);

    // Add the role definition to the role assignemnt. 
    // This will assign the specific permission to the security principal for this role          assignemnt.
    oRoleAssignment.RoleDefinitionBindings.Add(oRole);

     // Now we need to add the role assignment to the web
     oWeb.RoleAssignments.Add(oRoleAssignment);

    // Now update the web
    oWeb.Update();
   }
}
//创建包含我们列表的站点
使用(SPSite oSite=new SPSite(“”)
{
//打开web对象
使用(SPWeb oWeb=oSite.OpenWeb())
{
//获取要将用户添加到的组
SPGroup oGroup=oWeb.Groups[“”);
//获取要分配的角色定义ex:Full Control
SPRoleDefinition oRole=oWeb.RoleDefinitions[“>”];
//创建角色分配对象
SPRoleAssignment或leassignment=新的SPRoleAssignment(oGroup);
//将角色定义添加到角色分配中。
//这将为此角色assignemnt向安全主体分配特定权限。
oRoleAssignment.RoleDefinitionBindings.Add(oRole);
//现在我们需要将角色分配添加到web
oWeb.角色分配。添加(或删除分配);
//现在更新网页
更新();
}
}