Forum Discussion

David Grooms's avatar
David Grooms
Copper Contributor
Aug 07, 2017
Solved

DisableSharingForNonOwners with pnp or CSOM

In the admin center - site collections - sharing, there is a dialog with the option :

Allowing Non-Owners to Invite New Users.

 

I'd like to turn this to 'Not Allowed' using CSOM C#.

 

Does any one know where this settings lives ?

 

Thanks,

 

Dave

  • Added disabling "Allow access requests" setting to my original code example. It's just emptying RequestAccessEmail property.

6 Replies

  • Setting actually turns off all Access Request Settings on site permissions (.../_layouts/15/user.aspx)

     

    I have done something similar like this (it's missing Allow Access Request setting):

     

     Group associatedMemberGroup = ctx.Web.AssociatedMemberGroup;
                    Web web = ctx.Web;
                    ctx.Load(associatedMemberGroup);
                    ctx.Load(web);
                    ctx.ExecuteQuery();
                    associatedMemberGroup.AllowMembersEditMembership = false; 
                    associatedMemberGroup.Update();
                    web.MembersCanShare = false; 
    web.RequestAccessEmail = ""; web.Update(); ctx.ExecuteQuery();

     

     

    • David Grooms's avatar
      David Grooms
      Copper Contributor

      I've tried that code already, but it doesn't change the values shown in the Sharing dialog.

      Not sure if ithas the desired effect, I was hoping to verify by seeing the settings int eh form change.

       

      Dave

       

       

      • Matti Paukkonen's avatar
        Matti Paukkonen
        Iron Contributor

        Added disabling "Allow access requests" setting to my original code example. It's just emptying RequestAccessEmail property.