SOLVED

DisableSharingForNonOwners with pnp or CSOM

Copper Contributor

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

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();

 

 

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

 

 

My example turns off "Allow members to share..." and "Allow members to invite..." check boxes on Access Request Settings. If you turn off "Allow access requests" checkbox, admin center Sharing dialog displays "Status: Not allowed.", at least in my dev tenant.

Any Idea where the 'Allow Access Requests' flag is in CSOM ?

 

I'm seeing the same thing where my code unchecks the top two boxes, and unchecking the third gives the result I want.

 

Thanks,

 

Dave

best response confirmed by David Grooms (Copper Contributor)
Solution

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

That worked !

 

Thanks,

 

Dave

1 best response

Accepted Solutions
best response confirmed by David Grooms (Copper Contributor)
Solution

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

View solution in original post