One of the projects I came across a scenario where I need to pre populate custom security groups with “All authenticated Users”. I have wrote a code and run it as a part of the feature receiver.

If you have a security group with read access to a site collection, you can add “All authenticated users” into this groups and every user will have read access to that site.

In the feature receiver class FeatureActivated event I have used the following code.

SPWeb myWeb = properties.Parent as SPWeb;
permissionLevel = "Read";
myWeb.SiteGroups.Add("Site Read Group", owner, owner, "My New Category");
SPRoleAssignment roleAssignment = new SPRoleAssignment(myWeb.SiteGroups["Site Read Group"]);
myWeb.SiteGroups["Site Read Group "].AddUser("c:0(.s|true", string.Empty,
string.Empty, string.Empty);

Note: The “c:0(.s|true” means “All Authenticated Users”

About Us

Follow Us

Email: contact@keapoint.com
Phone:  0208 7852 888

Registered Address: 1 Amber Close, Reading, RG6 7ED. United Kingdom

Company No. 11586817