private static ObjectSecurity GetPipeSecurity(PipeStream pipeStream) { #if NETSTANDARD1_3 return((ObjectSecurity)typeof(PipeStream) .GetTypeInfo() .GetDeclaredMethod("GetAccessControl") ?.Invoke(pipeStream, parameters: null)); #else return(pipeStream.GetAccessControl()); #endif }
static void AddDenyEveryone(PipeStream stream) { PipeAccessRule rule; PipeSecurity security; AuthorizationRuleCollection inRules, outRules; // Let's add a Deny for Everyone. security = stream.GetAccessControl(); inRules = security.GetAccessRules(true, false, typeof(SecurityIdentifier)); Assert.AreNotEqual(0, inRules.Count); rule = new PipeAccessRule(new SecurityIdentifier("WD"), PipeAccessRights.FullControl, AccessControlType.Deny); security.AddAccessRule(rule); stream.SetAccessControl(security); security = stream.GetAccessControl(); outRules = security.GetAccessRules(true, false, typeof(SecurityIdentifier)); Assert.AreEqual(inRules.Count + 1, outRules.Count); }
private static ObjectSecurity GetPipeSecurity(PipeStream pipeStream) { return(pipeStream.GetAccessControl()); }