Pages

Showing posts with label User. Show all posts
Showing posts with label User. Show all posts

Monday, January 18, 2016

Manage Permissions on List Views for Different Users / Groups in SharePoint 2013

Follow these steps: -
  • Open the list with all items view (ex. Lists/EmployeeMaster/Allitems.aspx). 
  • Go to Site Actions and select Edit Page 
 Now the web part Allitems.aspx will change to the edit mode.
  • Go to the Web Part section and click Web Part Properties.
 Now the web part properties window will displayed in the right side of the web part.
  • In the List Views pane select the view from the dropdown which you need to manage the permissions.
  • In the Advanced pane select the users/ groups under Target Audiences
  • Click OK.
Follow the above steps to manage access levels and grant permission to user/ groups for different list views.

Sunday, January 17, 2016

Manage permissions for a list, library, or single item or document


This post is going to describe that how to assign unique permissions for a list, library or single list item, or document.

List / Library

Remove inherited permission from Users/Group in list
1. Open the list/library that you want to edit permission
2. Go to List Settings (or Library Settings if it is and library)
3. Go to Permission for this List (or Permission for this Library) under Permission and Management Section.
Permission page for the list will be displayed and you can see that list has inherited permission from site.
4. Click Stop inheriting permissions.
Now the list will be removed inherited permission and it has copy of its own permission.

Remove permission from Users/Group in list
1. Click check box in the left side of user/group name in the name section.
2. Click Remove User Permission under Permissions tab.
 
Grant permission to Users/Groups for list
1. Click Grant Permissions under Permissions tab and then the list permission pop window will displayed.
2. Type names of the users / groups which you need to grant permissions to the list.
3. Click SELECT OPTIONS to edit permission levels for selected users/ groups.
4. Click Share.

Inherit Permissions from Parent
1. Open the list/library that you want to edit permission
2. Go to List Settings ( or Library Settings if it is and library)
3. Go to Permission for this List (or Permission for this Library) under Permission and Management Section
Permission page for the list will be displayed and you can see that list has inherited permission from site.
4. Click Delete unique permissions.
Now the list will be removed inherited permission and it has copy of its own permission.

Note:- Managing permission on single list item or library document will follow the same steps above.

Friday, January 15, 2016

Get values from Person or Group field programmatically


We are using different types of fields when working with SharePoint applications.
One of an important type among them is Person or Group field which is manage user values in site contents. This post has described that how to work with Person or Group field programmatically.

1. Get SPUser from Person or Group field in the list – (When multiple choice and groups are not allowed in the field):
//Get SPUser
SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users");
SPFieldUserValue userFieldValue = (SPFieldUserValue)userField.GetFieldValue(item["Users"].ToString());

SPUser user = userFieldValue.User;

2. Get SPUser when multiple choice is allowed and groups are not allowed:
//Multiple choices are allowed
SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users");
SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString());
foreach (SPFieldUserValue userFieldValue in userFieldValueCollection)
{
    Console.WriteLine("     " + userFieldValue.User.LoginName);
}

3. Get SPUser when group is allowed:
//Group or User are allowed
SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users");
SPFieldUserValue userFieldValue = (SPFieldUserValue)userField.GetFieldValue(item["Users"].ToString());

//Tries to get SPUser
if (userFieldValue.User != null)
{
   SPUser user = userFieldValue.User;
}

//if the field contain group
else
{
  SPGroup group = web.SiteGroups.GetByID(userFieldValue.LookupId);
}