Featured post
SharePoint permissions for a specific group -
i'm trying establish whether specific group has read access particular site collection.
i have been trying day , half feel if have found 3 halves of different solutions!
the code fragments have far are:
using (spsite site = new spsite(this.generateabsoluteuri(modulecode, academicyear))) { using (spweb web = site.openweb()) { (int = web.sitegroups.count - 1; >= 0; i--) { spgroup group = web.sitegroups[i]; if (regex.ismatch(group.name, thegroupimlookingfor)) {
but what?!
most of google results tell me roles don't know how tie role group.
please help!
cheers
patrick
to assign permission user (account) or sharepoint group there objects need @ in order. first thing need the security principal want assign role (spuser or spgroup). next thing need actual permission (role) want assign (ex: read, full control etc…). need create sproleassignment object , on constructor pass in spuser or spgroup (security principal) want assign permissions to. need add role definition roledefinitionbindings collection of role assignment object. need add actual role assignment web (site) , update web. below full code lisitng.
// create site contains our list using(spsite osite = new spsite("<<my site url>>")) { // open web object using(spweb oweb = osite.openweb()) { // group want add user spgroup ogroup = oweb.groups["<<group name>>"]; // role definition want assign ex: full control sproledefinition orole = oweb.roledefinitions["<< role name>>"]; // create role assignment object sproleassignment oroleassignment = new sproleassignment(ogroup); // add role definition role assignemnt. // assign specific permission security principal role assignemnt. oroleassignment.roledefinitionbindings.add(orole); // need add role assignment web oweb.roleassignments.add(oroleassignment); // update web oweb.update(); } }
- Get link
- X
- Other Apps
Comments
Post a Comment