示例
ClientContext oClientContext = new ClientContext("http://MyServer/sites/MySiteCollection/MyWebSite");
Web oWebsite = clientContext.Web;
GroupCreationInformation groupCreationInfo = new GroupCreationInformation();
groupCreationInfo.Title = "My New Group";
groupCreationInfo.Description = "新群组的描述。";
Group oGroup = oWebsite.SiteGroups.Add(groupCreationInfo);
RoleDefinitionBindingCollection collRoleDefinitionBinding = new RoleDefinitionBindingCollection(clientContext);
RoleDefinition oRoleDefinition = oWebsite.RoleDefinitions.GetByType(RoleType.Contributor);
collRoleDefinitionBinding.Add(oRoleDefinition);
oWebsite.RoleAssignments.Add(oGroup, collRoleDefinitionBinding);
clientContext.Load(oGroup,
group => group.Title);
clientContext.Load(oRoleDefinition,
role => role.Name);
clientContext.ExecuteQuery();
Console.WriteLine("{0} created and assigned {1} role.", oGroup.Title, oRoleDefinition.Name); }