SOLVED

DisableSharingForNonOwners with pnp or CSOM

%3CLINGO-SUB%20id%3D%22lingo-sub-93912%22%20slang%3D%22en-US%22%3EDisableSharingForNonOwners%20with%20pnp%20or%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-93912%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20the%20admin%20center%20-%20site%20collections%20-%20sharing%2C%20there%20is%20a%20dialog%20with%20the%20option%20%3A%3C%2FP%3E%3CP%3EAllowing%20Non-Owners%20to%20Invite%20New%20Users.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'd%20like%20to%20turn%20this%20to%20'Not%20Allowed'%20using%20CSOM%20C%23.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20any%20one%20know%20where%20this%20settings%20lives%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDave%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-93959%22%20slang%3D%22en-US%22%3ERe%3A%20DisableSharingForNonOwners%20with%20pnp%20or%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-93959%22%20slang%3D%22en-US%22%3E%3CP%3EThat%20worked%20!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDave%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-93955%22%20slang%3D%22en-US%22%3ERe%3A%20DisableSharingForNonOwners%20with%20pnp%20or%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-93955%22%20slang%3D%22en-US%22%3E%3CP%3EAdded%20disabling%20%22Allow%20access%20requests%22%20setting%20to%20my%20original%20code%20example.%20It's%20just%20emptying%20RequestAccessEmail%20property.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-93954%22%20slang%3D%22en-US%22%3ERe%3A%20DisableSharingForNonOwners%20with%20pnp%20or%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-93954%22%20slang%3D%22en-US%22%3E%3CP%3EAny%20Idea%20where%20the%20'Allow%20Access%20Requests'%20flag%20is%20in%20CSOM%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20seeing%20the%20same%20thing%20where%20my%20code%20unchecks%20the%20top%20two%20boxes%2C%20and%20unchecking%20the%20third%20gives%20the%20result%20I%20want.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDave%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-93945%22%20slang%3D%22en-US%22%3ERe%3A%20DisableSharingForNonOwners%20with%20pnp%20or%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-93945%22%20slang%3D%22en-US%22%3E%3CP%3EMy%20example%20turns%20off%20%22Allow%20members%20to%20share...%22%20and%20%22Allow%20members%20to%20invite...%22%20check%20boxes%20on%20Access%20Request%20Settings.%20If%20you%20turn%20off%20%22Allow%20access%20requests%22%20checkbox%2C%20admin%20center%20Sharing%20dialog%20displays%20%22%3CSPAN%3EStatus%3A%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ENot%20allowed.%22%2C%20at%20least%20in%20my%20dev%20tenant.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-93944%22%20slang%3D%22en-US%22%3ERe%3A%20DisableSharingForNonOwners%20with%20pnp%20or%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-93944%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20tried%20that%20code%20already%2C%20but%20it%20doesn't%20change%20the%20values%20shown%20in%20the%20Sharing%20dialog.%3C%2FP%3E%3CP%3ENot%20sure%20if%20ithas%20the%20desired%20effect%2C%20I%20was%20hoping%20to%20verify%20by%20seeing%20the%20settings%20int%20eh%20form%20change.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDave%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-93938%22%20slang%3D%22en-US%22%3ERe%3A%20DisableSharingForNonOwners%20with%20pnp%20or%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-93938%22%20slang%3D%22en-US%22%3E%3CP%3ESetting%20actually%20turns%20off%20all%20Access%20Request%20Settings%20on%20site%20permissions%20(...%2F_layouts%2F15%2Fuser.aspx)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20done%20something%20similar%20like%20this%20(it's%20missing%20Allow%20Access%20Request%20setting)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%20Group%20associatedMemberGroup%20%3D%20ctx.Web.AssociatedMemberGroup%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Web%20web%20%3D%20ctx.Web%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.Load(associatedMemberGroup)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.Load(web)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.ExecuteQuery()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20associatedMemberGroup.AllowMembersEditMembership%20%3D%20false%3B%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20associatedMemberGroup.Update()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20web.MembersCanShare%20%3D%20false%3B%20%3CBR%20%2F%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20web.RequestAccessEmail%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20web.Update()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.ExecuteQuery()%3B%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional 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 (Occasional Contributor)
Solution

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

That worked !

 

Thanks,

 

Dave