Hot answers tagged

13

To get claim for All Authenticated Users in PS you need to use: $claim = New-SPClaimsPrincipal -EncodedClaim "c:0(.s|true" for windows users (NT AUTHORITY\authenticated users): $claim = New-SPClaimsPrincipal -EncodedClaim "c:0!.s|windows" and for all forms authenticated users (basic asp.net membership provider) $claim = New-SPClaimsPrincipal -...


4

Check this out: public static bool IsUserInRole(SPUser user, SPWeb web, string roleName) { SPPermissionInfo info = web.GetUserEffectivePermissionInfo(user.LoginName); SPRoleDefinition roleDefinition = web.RoleDefinitions[roleName]; foreach (SPRoleAssignment roleAssignment in info.RoleAssignments) { ...


3

Answer to both of your question is - no, from msdn breaking role inheritance means - "role assignments on the parent object no longer apply to the child object, for example, so that role assignments on a list no longer apply to a list item." So permission granted on the document library (parent object in your case) never overrides the item level permission (...


3

Reseting role definitions could possibly lead to an inconsistency if new definitions have been added and used in assignments. That's why, I presume, you canno't revert définitions without also reverting assignments. I checked in the SharePoint OM assemblies, and even internally there's no method to revert defintions only...


3

It is tricky, and I think there is no straight forward way to retain the unique permissions when you roll back to inherit parent's permissions. If you read and compare the definitions of SPWeb.BreakRoleInheritance and SPWeb.ResetRoleInheritance You will notice that SPWeb.ResetRoleInheritance has no parameters to pass where we can instruct SharePoint to ...


2

Maybe you can try different approach. You can secure application in page code rather to alter/add web.config file(s). This link is bit old but for general info will be ok: http://msdn.microsoft.com/en-us/library/dd878359(v=office.12).aspx#SecuringAppPages_ValidatingUserPermissions I still have few scars left from my last fight with Sharepoint web.config.


2

Here is a sample code to get the groups in Silverlight app by calling the GetGroupCollectionFromUserAsync method of UserGroup.asmx web service. http://www.innovawiz.com/get-the-sharepoint-groups-a-user-is-part-of-using-sharepoint-object-model


2

It is automatically configured by the prerequisites installer.


2

The URI for a claim that specifies the role of a Windows user Admin,Manager or A list of all groups that the user is a member of . A claim as a piece of identity information (for example, name, e-mail address, age, or user role). The more claims your application receives, the more you know about your user. To understand more about the claims you need to ...


2

Simple answer of this question is: Farm Administrator is the father and Site Collection administrators the kids. Farm Administrator have full control on SharePoint farm; can create services applications, Web Application, manage quota, deploy solutions, configure the farm level settings, run PowerShell scripts etc. While site collection administrators, only ...


2

Following example shows how to break role inheritance of a list item and give current user Contribute permissions to the item. var siteUrl = '/sites/MySiteCollection'; function breakSecurityInheritanceAddUser() { var clientContext = new SP.ClientContext(siteUrl); var oList = clientContext.get_web().get_lists().getByTitle('MyList'); var itemId ...


2

You could consider the following solution to get permission levels/roles: get the effective permissions that the specified user using /_api/web/getusereffectivepermissions endpoint determine user roles using SP.BasePermissions.has(perm) Method JavaScript example function getUserEffectivePermissions(webUrl,accountName) { var endpointUrl = webUrl + ...


2

You can't quite impersonate over REST API since the code runs client-side and any user could capture the request and use it maliciously to impersonate the user for other operations. If you have a High-Trust (Provider Hosted) App SharePoint trusts who your signed token claims the user is, but even then, you shouldn't use it client side. You might try using ...


2

You should use microsoft.SharePoint.Client.RoleDefinitionBindingCollection instead of Microsoft.SharePoint.Client.RoleAssignment. Try below snippet (Not tested but will give you idea of what all steps are required): # Get the list by Title and load. $web = $ctx.Web $list = $web.Lists.GetByTitle("Quiz") $ctx.Load($list) # Load in list of groups on the ...


2

Microsoft.sharepoint.client.folder does not have property for "BreakRoleInheritance" You can use as below to break permission inheritance $RootFolder.ListItemAllFields.BreakRoleInheritance($true,$false) Hope it will help to you.


2

Site owner can not view site from Viewer's angle. Your given permission must be appeared whenever you login in a site. When I test permission in sites, I used to create several users like Editor, Reader, Admin and so on.


1

After further investigating I found that Notes is a property of the SPUser class. Thus, following would work: var spRole = new SPRoleAssignment("domain\\name", "abc@xyz.com", "name", "notes for user"); var spUser = (SPUser)spRole.Member; var notes = spUser.Notes;


1

Using csom PowerShell you can try below function to give a group your desired permissions it uses Microsoft.SharePoint.Client.RoleDefinitionBindingCollection and Microsoft.SharePoint.Client.RoleType to get role types. function Set-PermissionsOnList() { param( [Parameter(Mandatory=$true)][string]$url, [Parameter(Mandatory=$true)][System....


1

Yeah, It is possible in Sharepoint. Follow my answer here : Set Offline Client Availability of sharepoint document library You have to set Offline Client Availability to No


1

This happens because web has not been loaded. Load the web i.e. context.Load(currentweb);. Finally Load the RoleAssignmentCollection and then execute query before looping through them. Example: RoleAssignmentCollection roleAssignment = currentweb.RoleAssignments; context.Load(roleAssignment); context.ExecuteQuery(); for (int i = roleAssignment.Count - 1; i ...


1

Try this var ogroup = context.Web.AssociatedOwnerGroup; var mgroup = context.Web.AssociatedMemberGroup; var vgroup = context.Web.AssociatedVisitorGroup; context.Load(ogroup); context.Load(mgroup); context.Load(vgroup); context.ExecuteQuery(); var ...


1

Have you tried just getting the Group object and passing that in the roleAssignments.Add call in place of the user object? Something like this: var memberGroup = web.get_siteGroups().getByName("Members"); roleAssignments.add(memberGrooup, binding); I know I've done this but don't recall exactly how.


1

In addition to John's - the Prerequisites are only properly installed on Windows Server (2008 or 2012). If however you install SharePoint 2010 on the client (e.g. Windows 7 or Windows 8) you would need to install and configure prerequisites by yourself, and that includes manually downloading and installing them all from web, and configuring your OS by ...


1

Yes its a little confusing, the thing to note is that a folder is really a SPListItem so the permissions are applies at that object. once you have created your role in the appropriate site or web. To be able to use it you need to grab it from the SPWeb.RoleDefinitions collection. You can do something like, you need to add reference to System.Linq for ...


1

Recursion is the answer to this my friend. private StringCollection sc = new StringCollection(); private void CheckPermissionsOnWeb(SPWeb web, string groupName) { foreach (SPGroup group in web.Groups) { if (group.Name == groupName) sc.Add(web.Url); // Or web.Name or whatever your custom logic is } foreach (SPWeb child in web....


1

Hope this helps! public void addPermissionToGroup() { SPSite site = new SPSite("http://mysite:5050/"); SPWeb spWeb = site.OpenWeb(); string permissionName = "Read"; string groupName = "Project Manager"; try { spWeb.AllowUnsafeUpdates = true; SPRoleAssignment roleAssignment = new SPRoleAssignment(spWeb.SiteGroups[groupName]); ...


1

I don't see anything evidently wrong with that code. Can you try "AllowingUnsafeUpdates" before doing the whole operation? Such as: web.AllowUnsafeUpdates = true; Also: were you able to debug into this piece of code? Does everything run as expected? Here are some things that you would want to check: . The group does exist . It finds the contributor ...


1

I create one method that works for me. This method must be called within SPSecurity.RunWithElevatedPrivileges method private void CopyRoles(SPListItem source, SPListItem taget) { if (!taget.HasUniqueRoleAssignments) taget.BreakRoleInheritance(false); for (int i = taget.RoleAssignments.Count - 1; i >= 0; i--) ...


1

I ended up with a solution loosely based on the concept of Role Definitions presented here. Here's a brief description of how this was implemented. For every AD Security Group, create an SPGroup, whose sole member is the corresponding directory group. Then, create an SPRoleDefinition for each required page access, e.g., Page_1.aspx - Read, and an ...



Only top voted, non community-wiki answers of a minimum length are eligible