0

This question already has an answer here:

I want to hide Open with Explorer ribbon button only those users has View Only permission and it should appear for other permission user.

I've tried with below custom action reference by this link

<CustomAction
Id="RemoveExplorerButton"
Location="CommandUI.Ribbon"
RegistrationType="List"
RegistrationId="101" Rights="ViewListItems">
<CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition
      Location="Ribbon.Library.Actions.OpenWithExplorer" />
  </CommandUIDefinitions>
</CommandUIExtension>

It's working and removing Open with Explorer button for all the permission users. Is there any way that just remove only for View Only Permission user.

Question : I mean Ribbon button should appear if user have read only or edit permission or any other permission except user has View Only.

marked as duplicate by teylyn, Benny Skogberg Feb 19 '15 at 8:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Can you try and see what happens with higher permission mask like EditListItems. – Nadeem Yousuf Feb 19 '15 at 6:17
  • I wondering to see, I changed right permission to EditListItems.it's hide for all edit permission users and visible for View only permission. but I want it to be the other way (hide only for View Only Users). – Jignesh Rajput Feb 19 '15 at 6:30
  • The reason this is happening is because, when we say ViewListItems, the users with Edit permissions already have this permission and hence they also don't see it. – Nadeem Yousuf Feb 19 '15 at 6:32
1

The problem with your hide custom action is that the Rights attribute says that the custom action must be active for every user having the ViewListItems permission, even if they have further permissions (like EditListItems) as well.

AFAIK, there is no declarative way to restrict the custom action using sime kind of exclusive OR (XOR), for example, for users having ViewListItems but no other permissions.

The solution I propose is to achieve it via JavaScript:

If you would like to apply the same logic for all doc. libraries, I suggest to inject the script via a CustomAction of type ScriptLink. If you need it only for a single library, you can include the script in a Script Editor Web Part.

In the script use JavaScript client object model (getUserEffectivePermissions method) to get the effective permissions of the current user for the current list. If it is read-only, use JQuery to hide the Open with Explorer button.

Don't forget, that although a user might have only read permission for the root folder of the library, he may have write permissions for subfolder and vica versa.

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