Forum Discussion

Reindert de Kok's avatar
Reindert de Kok
Copper Contributor
Feb 26, 2018

SharePoint Online hide "site contents" and "site usage" page (modern sites)

I have a scenario with external users.

 

I created a custom permission level for these users. The custom permission level is a copy of the default "Read" permission level, but I unchecked the "View application pages" permissions.

 

The external users are however still able to see the site contents page and, even worse, the 'site usage' page.

 

I also activated the "Limited-access user permission lockdown mode" site collection feature. And I tried to work with limited access for external users, but then they don't have access at all.

 

Is there a way to achieve what I want? A permission level where (external) users are not able to see site contents and site usage page?

 

Thanks in advance!

  • phil333's avatar
    phil333
    Brass Contributor

    Hey hows it going.Reindert de Kok 

     

     

       A spfx extension seemed to solve my problem.

     

       In my application customizer I imported SPPermission and then used some js to do what I needed.
    My Code below:

    let checkExist = setInterval(function() {
        const element = document.querySelector("#O365_MainLink_Settings_container").firstChild.firstChild.firstChild.firstChild;
        if(typeof(element) != "undefined" && element != null){
           element.parentElement.parentElement.parentElement.remove();
           console.log("GFC user only has view rights.");
           clearInterval(checkExist);
        }
        
    }, 100);

     


    Reference:
    Setup Environment: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment
    Build an extension: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/build-a-hello-world-extension

    • AS3515's avatar
      AS3515
      Copper Contributor

      phil333 hello.

       

      Can you provide additional details/steps to your process (particularly for those this is new to)?

       

      Following the video instructions, I am using Visual Studio Code.

       

      - What specific extension did you import/install?

      - What specific area did you add your provided code?

      - Can you provide guidance on how to make the extension available on a SP site?

       

      Thank you in advance for any help.

      • phil333's avatar
        phil333
        Brass Contributor

        AS3515 

         

        Hey its good to meet a fellow traveler that's new to this stuff too. Ill do my best to answer your question.

         

        • Once build is done add this to top of “The Name of Your Extension”ApplicationCustomizer.ts. Its in the folder “src/extensions/”.

                                         import { SPPermission } from '@microsoft/sp-page-context';

        imports

        • Below your imports you will see a section saying something like: “public onInit(): Promise<void>”. Under “Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);” is where you enter your code.

        standard looking code

        • Here is the JavaScript I used to hide the gear:
        const canEdit = this.context.pageContext.web.permissions.hasAnyPermissions(SPPermission.manageWeb);
        
            if(!canEdit){
        
            let checkExist = setInterval(function() {
              const element = document.querySelector("#O365_MainLink_Settings_container").firstChild.firstChild.firstChild.firstChild;
              if(typeof(element) != "undefined" && element != null){
                 element.parentElement.parentElement.parentElement.remove();
                 console.log("GFC user only has view rights.");
                 clearInterval(checkExist);
              }
              
          }, 100);
            }

         

        • Make sure you save your work.

        • In a cmd console, in the directory of your project, run:

                        gulp bundle –ship

        • Then run:

                        gulp package-solution --ship

        note: your application will be saved in projects directory: 'sharepoint/solutions/'

        • Finally just upload your App to your SharePoint catalog site. You extension will show up just how it would when you add a webpart to a site.

        Again I hope this helps. It does the trick for me.

         

         

  • Mohamed_Gameel's avatar
    Mohamed_Gameel
    Copper Contributor

    You can use the following css at content editor web part

    <style>
    #SuiteMenu_zz5_MenuItem_ViewAllSiteContents {
    display: none;
    }
    </style>

    Note the ID for ViewAllSiteContents item in menu is changed from environment to another so you can get it from browser inspect element

    Reindert de Kok 

  • TristonT's avatar
    TristonT
    Copper Contributor

    Hi,

     

    I had  the same issue I used a custom permission level with the "View application pages" permission disabled and my external users were still able to access the Site Contents.

     

    When I first enabled, "Limited-access user permission lockdown mode" , both the site pages and Site content displayed "Access Denied". However, after playing around with the permissions I was able to find a combination that worked for me.

     

    My Steps:

    1. Enable the "Limited-access user permission lockdown mode" Site Feature (Site Settings > Site collection features > Limited-access user permission lockdown mode).

     

    2. Create Custom Permission Level with the following permissions:

    1. List Permissions
      • Add Items - Add items to lists and add documents to document libraries.
      • Edit Items - Edit items in lists, edit documents in document libraries, and customize Web Part Pages in document libraries.
      • Delete Items - Delete items from a list and documents from a document library.
      • View Items - View items in lists and documents in document libraries.
      • Open Items - View the source of documents with server-side file handlers.
      • View Versions - View past versions of a list item or document.
    2. Site Permissions
      • View Pages - View pages on the Web site.
      • Browse User Information - View information about users of the Web site.
      • Open - Allows users to open the Web site, list, or folder in order to access items inside that container.
      • Use Remote Interfaces - Use SOAP, Web DAV, the Client Object Model or SharePoint Designer interfaces to access the Web site.
      • Edit Personal User Information - Allows a user to change his or her own user information, such as adding a picture.

    Note: These permissions worked for my needs, you may want to modify according to your needs. However, this method didn't work without the "Use Remote Interfaces" permission being enabled.

     

    3. Ensure the external user group has the correct permission level applied to it. (Site Settings > Site Permissions > Check Permissions).

     

    Result:

    The External User group can access the site pages and but Site content and Site usage displays "Access Denied".

     

    I hope this helps someone else!

     

     

    • Gizmaster's avatar
      Gizmaster
      Copper Contributor
      This solution worked for me beautifuly. Telling where to go to change the settings was cruciual here as I'm not an IT person and not very familiar with the different Sharepoint settings.
      Thanks very much.
      • Don0011595's avatar
        Don0011595
        Copper Contributor
        Does anyone have any solution about hiding/disabling the 'Send By Email' link, which keeps appearing on all new Sharepoint pages. One would assume that there should be a feature, which would allow his link to be hidden. It is quite time-consuming trying to get Sharepoint-permissions, tied down, to relevant levels, of users. It seems to be a task, whereby, when issue appears to be solved, that some other thing, is appearing on the screen. I would like to make contact with someone, in Microsoft, who is responsible for Sharepoint 365. These issues, seem to be in Sharepoint 365, for quite some time.
    • Keshav410's avatar
      Keshav410
      Copper Contributor

      TristonT  I tried the solution, it works but my navigation has stopped showing up. My navigation is basically just 3 links to 3 different view of the same list. when i access the link my manually i do get access to it though. 

       

      I tried re-enabling the view application pages permission back then my navigation show up. But the issue with site content and site usage access come back 

  • cbraafhart's avatar
    cbraafhart
    Brass Contributor

    Reindert de Kok 

     

    I am currently testing and in the same situation as everyone that has requested and posted regarding this problem. as rpawa posted it is a permission thing but i will test what i may found as being everyone solution. Discovery needs experimentation :xd:. As soon as i am done testing fully with a few other users and a test user i am cramming with i will repost my findings and maybe the solution.

    • cbraafhart's avatar
      cbraafhart
      Brass Contributor
      I take it back, it was just a fluke, got the site usage and site content option to be hidden for users but after permissions were propagated correctly the user could have seen them again. I am currently trying to limit what the user can see by playing with the permissions levels of share point. i gave users the following permissions: View Items under List Permissions and View pages + Open Under Site permissions. with these 3 permission the user can still get to the site content. I tried but without any success. it was a REAL fluke
  • Petrix's avatar
    Petrix
    Copper Contributor

    Hi, same issue here, i whant to Hide Info about Members, but in SPO Teams Site, the external user (my domain account but without licences) he can see the Team Group Members. :( .... is not GDPR OK because my user have phone nr. etc on there profile. :(((

  • Reindert de Kok's avatar
    Reindert de Kok
    Copper Contributor

    I did some further research, here are my findings:

     

    When you uncheck the "view application pages" permissions, users are not able to view the 'site contents' and 'site usage' pages. This works fine in a SharePoint site that uses sitepages that are based on the classic interface. Because users can browse the site pages, but not the application pages.

     

    If you however use modern site pages, user will not be able to view those pages if they don't have the 'view application pages' permissions. In other words, SharePoint sees the modern pages as application pages.

     

    Therefore there does not seem to be a way to restrict the access to the site contents and site usage pages while being able to view modern site pages. Which in my opinion is a clear bug...

    • Ann_M's avatar
      Ann_M
      Brass Contributor

      This is very important to us, as well, and is driving us to look at alternatives that we would rather not pursue.

      • Deleted's avatar
        Deleted

        Ann_M Yeah this is kinda bad. Anyone with read permissions on modern sites her has access to all the admin functions on the menus, but jsut read access on the pages. What in the world is going on.

    • Deepak Shakya's avatar
      Deepak Shakya
      Copper Contributor

      Has this been recolved or is there a way to hide the site content menu item? I have hidden access to site assests, styles and other folder except document using custom permissions by not inheriting from parent. But visitors still have access to site usage and site workflows. I need to not show this in the UI.

       

      any help would be great.

      • Jeroen Lammens's avatar
        Jeroen Lammens
        Brass Contributor

        I would like to hide the site permissions as well. Haven't figured out a way of doing so as of yet. Any input would be great.

Resources