Closed andreasblueher closed 6 years ago
use AddSecurityGroupLink for each group separately
Why not to build a method which would receive the list and group, and then would add the right permissions altogether?
Could you please share a problematic piece of code which you have to duplicate? Just to get a broader idea of the issue.
I don't know but maybe I found the solution myself. Would the code below work in your opionion
var securityGroups = Definitions.SecurityGroupDefinitions.ServiceteamDefinitions.Select(serviceTeam => new SecurityGroupDefinition { Name = serviceTeam.Name, Description = serviceTeam.Description, Owner = "owneraccount", }).ToList(); var webModel = SPMeta2Model.NewWebModel(); foreach (var groupDefinition in securityGroups) { webModel = webModel.AddList(Definitions.Lists.MyList, list => list .AddSecurityGroupLink(securityGroup)
Would this code aggregate the SecurityGroupLinks for the groups?
Sorry for the messed up code, but can't get it to format nicer.
Hey guys,
I wasn't aware that you could simply take the webModelNode element and alter it just like you do within the lamdba function.
None of the code I found yet within the documentation shows this kind of approach, so maybe this would be something to consider for further doc changes.
Hey,
I got about 30 groups which I defined in my own custom type and convert them into SecurityGroupDefinitions to add them to my site. AddSecurityGroups works like a charm there.
After adding them to my site I want to assign custom permissions for specific lists to those 30 groups and to do that I have to use AddSecurityGroupLink for each group separately, although they all get the same permissionset/role.
Is there an easier way to maybe pre build the listdefinition or the webmodel for that matter, so I could iterate through my securityGroups and assign the same permission again and again? Thanks for your input Andreas