Search This Blog

Showing posts with label Permissions. Show all posts
Showing posts with label Permissions. Show all posts

Monday, August 3, 2015

Adding User Permissions using Power shell script in SharePoint 2013


In SharePoint we are having permission level operations. To that SharePoint group we can add users through Site Settings -> Site Permissions.

And also we can give permissions using PowerShell scripts.

For Single User:

new-spuser -UserAlias "User1" -Web "http://test:100/sites/home1" -Group "TestUsers"

For Every One:

new-spuser -UserAlias "Everyone" -Web "http://test:100/sites/home1" -Group "TestUsers"

By executing this PowerShell script we can add users to the SharePoint groups.


thank you,

Friday, April 17, 2015

How to check a value is SPGroup or SPUser

SPList olist = oweb.Lists.TryGetList("Test_List");
if (olist != null)
{
SPListItemCollection ocoll = olist.Items;
foreach(SPItem oitem in ocoll)
{
SPFieldUserValueCollection GetAllGroup = new SPFieldUserValueCollection(oweb, Convert.ToString(oitem["SPGroups"]));

for (int i = 0; i < GetAllGroup.Count; i++)
{
SPFieldUserValue singlevalue = GetAllGroup[i];
if (singlevalue.User == null)   // If it is GROUP condition is true
{
SPGroup group = oweb.Groups[singlevalue.LookupValue];
foreach (SPUser user in group.Users)
{
if (ouser.Name == user.Name)
{
isuserval = true;
break;
}
}
}
else
{
if (ouser.Name == singlevalue.User.Name) // Checks User is Current Login User
{
isuserval = true;
break;
}
}
}
}
}


Restricting Custom People Picker to only one Sharepoint group programatically

Refer the following script files in your page,     <!-- For People Picker -->     <script type="text/javascript" src...