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'm disabling, for all user Rights, the 'Open with Explorer' button in the SPRibbon with the following code:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
       <CustomAction
         Id="RemoveRibbonButton"
         Location="CommandUI.Ribbon">
              <CommandUIExtension>
                     <CommandUIDefinitions>
                           <CommandUIDefinition
                             Location="Ribbon.Library.Actions.OpenWithExplorer" />
                     </CommandUIDefinitions>
              </CommandUIExtension>
       </CustomAction>
</Elements>

reference

I intend to display only for user with 'ManageWeb' Rights, however the Rights attribute works in the opposite way(Removes ribbon to every SPBasePermissions set). Any idea how to make this work?


update

I try to remove, with the above code, and add a new custom action of the same button with the intended Rights, but it display to all user Rights anyway:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction Id="AddExplorerButton"
            Location="CommandUI.Ribbon"
            Rights="ManageWeb"
            xmlns="http://schemas.microsoft.com/sharepoint/">
        <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
            <CommandUIDefinitions>
                <CommandUIDefinition Location="Ribbon.Library.Actions.OpenWithExplorer">
                    <Button Id="AddOpenWithExplorer"
                            Sequence="50"
                            Command="OpenWithExplorer"
                            Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png"
                            Image16by16Top="-112"
                            Image16by16Left="-176"
                            Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png"
                            Image32by32Top="-64"
                            Image32by32Left="-352"
                            LabelText="$Resources:core,cui_ButOpenWithExplorer;"
                            ToolTipTitle="$Resources:core,cui_ButOpenWithExplorer;"
                            ToolTipDescription="$Resources:core,cui_STT_ButOpenWithExplorer;"
                            TemplateAlias="o2" />
                </CommandUIDefinition>
            </CommandUIDefinitions>
        </CommandUIExtension>
    </CustomAction>
</Elements>

update 2 - solution:

In a custom ControlTemplate called in the .master:

    SPWeb currentWeb = SPContext.Current.Web;
    SPRibbon spRibbon = SPRibbon.GetCurrent(Page);
    if (!currentWeb.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
        spRibbon.TrimById("Ribbon.Library.Actions.OpenWithExplorer");
share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

This is afaik the only way to do it SECURELY the ajax answer on that page is a bad example however of how to acheive this, the accepted answer is the correct way:

Hiding buttons of the Ribbon Bar

share|improve this answer
add comment

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.