Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i have a custom webpart , this webpart needs to be available for all users in site. It has a button which redirects to newform.aspx . Everything works for all users except visitors cannot access the newform.aspx to add items . How is it possible to make this work ?

share|improve this question
    
eggheadcafe.com/tutorials/aspnet/… –  Nikhil Sep 27 '11 at 16:21

3 Answers 3

Give visitors the ability to add items to the list where the newform resides. You may need to create a custom permission level, break permissions inheritance on the list and apply this custom permission level to the Visitors group.

share|improve this answer
    
can anyone provide me with some links on hw to achieve this ? –  Nikhil Sep 27 '11 at 16:14

By default the visitors group has a Read Only permission level. We need add item permission for adding the items to list, then only the user within that group gets the permission to view newform.aspx and add the item.

So, we have to break the permission for the group and associate the contribute (which has add, edit, and delete permissions) Permission level to Visitors Group.

share|improve this answer
up vote 0 down vote accepted

web.AllowUnsafeUpdates = true; SPList list = web.Lists[adidas.Intranet.MySite.Code.Constants.ListQuickLinks.LISTQUICKLINKS]; list.BreakRoleInheritance(true);

                    //SPGroupCollection groupCollection = list.ParentWeb.SiteGroups;
                    //SPGroup group = groupCollection["NT AUTHORITY\\Authenticated Users"];
                    SPUser allUser = web.AllUsers["NT Authority\\Authenticated Users"];



                    SPRoleDefinitionCollection roleDefCollection = list.ParentWeb.RoleDefinitions;
                    SPRoleDefinition roleDefinition = roleDefCollection["Contribute"];

                    SPRoleAssignment roleAssignment = new SPRoleAssignment((SPPrincipal)allUser);
                    roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
                    list.RoleAssignments.Add(roleAssignment);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.