当前位置: 首页>>代码示例>>C#>>正文


C# PipeSecurity.AddAccessRule方法代码示例

本文整理汇总了C#中System.IO.Pipes.PipeSecurity.AddAccessRule方法的典型用法代码示例。如果您正苦于以下问题:C# PipeSecurity.AddAccessRule方法的具体用法?C# PipeSecurity.AddAccessRule怎么用?C# PipeSecurity.AddAccessRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Pipes.PipeSecurity的用法示例。


在下文中一共展示了PipeSecurity.AddAccessRule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateServerStream

        static NamedPipeServerStream CreateServerStream()
        {
            var user = WindowsIdentity.GetCurrent().User;
            var security = new PipeSecurity();
            security.AddAccessRule( new PipeAccessRule( user, PipeAccessRights.FullControl, AccessControlType.Allow ) );
            security.SetOwner( user );
            security.SetGroup( user );

            IncrementServers();
            try
            {
                return new NamedPipeServerStream(
                    ProtocolConstants.PipeName,
                    PipeDirection.InOut,
                    20,
                    PipeTransmissionMode.Byte,
                    PipeOptions.Asynchronous,
                    CommandLineLength,
                    CommandLineLength,
                    security );
            }
            catch ( Exception )
            {
                DecrementServers();
                throw;
            }
        }
开发者ID:DeCarabas,项目名称:sudo,代码行数:27,代码来源:SudoServer.cs

示例2: MyServiceTasks

        public MyServiceTasks()
        {
            SetupEventLog();

            PipeSecurity ps = new PipeSecurity();
            ps.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow));
            ps.AddAccessRule(new PipeAccessRule("CREATOR OWNER", PipeAccessRights.FullControl, AccessControlType.Allow));
            ps.AddAccessRule(new PipeAccessRule("SYSTEM", PipeAccessRights.FullControl, AccessControlType.Allow));

            pipe = new NamedPipeServerStream("MyServicePipe", PipeDirection.In, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous, 1024, 1024, ps);
            InterProcessSecurity.SetLowIntegrityLevel(pipe.SafePipeHandle);
        }
开发者ID:jmguill,项目名称:my-service,代码行数:12,代码来源:MyServiceTasks.cs

示例3: NpListener

 public NpListener(string pipeName, int maxConnections = 254, ILog log = null, IStats stats = null)
 {
     _log = log ?? _log;
     _stats = stats ?? _stats;
     if (maxConnections > 254) maxConnections = 254;
     _maxConnections = maxConnections;
     this.PipeName = pipeName;
     _pipeSecurity = new PipeSecurity();
     _pipeSecurity.AddAccessRule(new PipeAccessRule(@"Everyone", PipeAccessRights.ReadWrite, AccessControlType.Allow));
     _pipeSecurity.AddAccessRule(new PipeAccessRule(WindowsIdentity.GetCurrent().User, PipeAccessRights.FullControl, AccessControlType.Allow));
     _pipeSecurity.AddAccessRule(new PipeAccessRule(@"SYSTEM", PipeAccessRights.FullControl, AccessControlType.Allow));
 }
开发者ID:WuxiCodeMonkey,项目名称:ServiceWire,代码行数:12,代码来源:NpListener.cs

示例4: createPipeSecurity

 PipeSecurity createPipeSecurity()
 {
     var pipeSecurity = new PipeSecurity();
     pipeSecurity.AddAccessRule(new PipeAccessRule(
         new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null),
         PipeAccessRights.ReadWrite,
         AccessControlType.Allow));
     pipeSecurity.AddAccessRule(new PipeAccessRule(
         WindowsIdentity.GetCurrent().Owner,
         PipeAccessRights.FullControl,
         AccessControlType.Allow));
     return pipeSecurity;
 }
开发者ID:avocadianmage,项目名称:avocado,代码行数:13,代码来源:NamedPipeServer.cs

示例5: Create

 public static NamedPipeServerStream Create(string name, int maxInstances = NamedPipeServerStream.MaxAllowedServerInstances) {
     PipeSecurity ps = new PipeSecurity();
     SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
     PipeAccessRule par = new PipeAccessRule(sid, PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow);
     ps.AddAccessRule(par);
     return new NamedPipeServerStream(name, PipeDirection.InOut, maxInstances, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 1024, 1024, ps);
 }
开发者ID:Microsoft,项目名称:RTVS,代码行数:7,代码来源:NamedPipeServerStreamFactory.cs

示例6: NamedPipesReadQueue

 public NamedPipesReadQueue()
 {
     var ps = new PipeSecurity();
     ps.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow));
     _serverStream = new NamedPipeServerStream(Whitebox.Connector.Constants.PipeName, PipeDirection.In, MaxInstances,
                                               PipeTransmissionMode.Message, PipeOptions.None, MaxMessage * MaxMessagesInBuffer,
                                               MaxMessage, ps);
 }
开发者ID:mustafatig,项目名称:whitebox,代码行数:8,代码来源:NamedPipesReadQueue.cs

示例7: PipeThreadStart

        private void PipeThreadStart()
        {
            PipeSecurity pSec = new PipeSecurity();
            PipeAccessRule pAccRule = new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null)
            , PipeAccessRights.ReadWrite | PipeAccessRights.Synchronize, System.Security.AccessControl.AccessControlType.Allow);
            pSec.AddAccessRule(pAccRule);

            using (_pipeServer = new NamedPipeServerStream("NKT_SQLINTERCEPT_PIPE",
                PipeDirection.InOut,
                NamedPipeServerStream.MaxAllowedServerInstances,
                PipeTransmissionMode.Byte,
                PipeOptions.None,
                MAX_STRING_CCH * 2,
                MAX_STRING_CCH * 2,
                pSec,
                HandleInheritability.Inheritable))
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("(pipe thread) Waiting for connection...");
                Console.ForegroundColor = ConsoleColor.Gray;

                try
                {
                    _pipeServer.WaitForConnection();

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("(pipe thread) Client connected.");
                    Console.ForegroundColor = ConsoleColor.Gray;

                    while (true)
                    {
                        byte[] readBuf = new byte[MAX_STRING_CCH * 2];

                        int cbRead = _pipeServer.Read(readBuf, 0, MAX_STRING_CCH * 2);

                        string str = Encoding.Unicode.GetString(readBuf, 0, cbRead);

                        Console.WriteLine(str);
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine("--------------------------------------------------------");
                        Console.ForegroundColor = ConsoleColor.Gray;

                        if (_blockQuery)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("(pipe thread) QUERY ABORTED");
                            Console.ForegroundColor = ConsoleColor.Gray;
                        }

                    }
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("(pipethread) Pipe or data marshaling operation exception! ({0})", ex.Message);
                }
            }
        }
开发者ID:llenroc,项目名称:SQLSvrIntercept,代码行数:57,代码来源:PipeServer.cs

示例8: CreateNamedPipeServerStream

        private static NamedPipeServerStream CreateNamedPipeServerStream(string pipeName) {
            var pipeSecurity = new PipeSecurity();
            pipeSecurity.AddAccessRule(
                new PipeAccessRule(
                    new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null),
                    PipeAccessRights.ReadWrite, AccessControlType.Allow));

            return new NamedPipeServerStream(pipeName,
                PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.None,
                4096, 4096, pipeSecurity);
        }
开发者ID:slieser,项目名称:sandbox,代码行数:11,代码来源:TimeServer.cs

示例9: ServerWorker

 public ServerWorker()
 {
     connected = false;
     disconnected = false;
     PipeSecurity ps = new PipeSecurity();
     ps.SetAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));
     ps.AddAccessRule(new PipeAccessRule(WindowsIdentity.GetCurrent().User, PipeAccessRights.FullControl, AccessControlType.Allow));
     pipeServer = new NamedPipeServerStream("testpipe", PipeDirection.InOut, MAXCLIENTS, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 5000, 5000, ps);
     thread = new Thread(ThreadRun);
     thread.Start();
 }
开发者ID:ActiveAuthentication,项目名称:ActiveAuthentication,代码行数:11,代码来源:ServerWorker.cs

示例10: Start

        public void Start(string pipeName)
        {
            _pipeName = pipeName;

            var security = new PipeSecurity();
            var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
            security.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.FullControl, AccessControlType.Allow));
            _pipeServer = new NamedPipeServerStream(_pipeName, PipeDirection.In, 254,
                PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 4096, 4096, security);
            _pipeServer.BeginWaitForConnection(WaitForConnectionCallBack, _pipeServer);
            _logger.Info("Opened named pipe '{0}'", _pipeName);
            _closed = false;
        }
开发者ID:SpoinkyNL,项目名称:Artemis,代码行数:13,代码来源:PipeServer.cs

示例11: QuestionWindow

        /*
        *METHOD		    :	QuestionWindow
        *
        *DESCRIPTION	:	Constructor for the QuestionWindow class. takes in users name, the computers name to connect to and name of the pipe to use.
         *                  Opens connestion to the service and starts the first qestion
        *
        *PARAMETERS		:	string userName     The name of the user
         *                  string serverName   The name of the computer running the server
         *                  string pipeName     The name of the por to connect to
        *
        *RETURNS		:
        *
        */
        public QuestionWindow(string userName, string serverName, string pipeName)
        {
            InitializeComponent();
            this.userName = userName;
            this.serverName = serverName;
            this.pipeName = pipeName;

            answers = new string[4];

            PipeSecurity ps = new PipeSecurity();
            System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
            PipeAccessRule par = new PipeAccessRule(sid, PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow);
            ps.AddAccessRule(par);

            questionNumber = 1;
            answers[0] = "";
            answers[1] = "";
            answers[2] = "";
            answers[3] = "";

            //start timer for counting down users score (1 per second)
            timer = new System.Timers.Timer();
            timer.Elapsed += on_Timer_Event;
            timer.Interval = 1000;

            //connect to service
            client = new NamedPipeClientStream(serverName, pipeName + "service");//naming convention for pipe is given name(pipeName) and who has the server (service or user)
            client.Connect(30);
            output = new StreamWriter(client);

            //tell service the name of the computer to connect back to
            output.WriteLine(Environment.MachineName);
            output.Flush();

            server = new NamedPipeServerStream(pipeName + "User", PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 5000, 5000, ps);//naming convention for pipe is given name(pipeName) and who has the server (service or user)
            server.WaitForConnection();
            input = new StreamReader(server);

            Thread.Sleep(100);//allow server time complete actions
            //tell service name of new user
            newUser();
            Thread.Sleep(200);//allow server time complete actions
            //get the first question
            getGameQuestion();
            //start score counter
            timer.Start();
        }
开发者ID:brandond12,项目名称:Trivia-Game,代码行数:60,代码来源:QuestionWindow.cs

示例12: Main

        static void Main(string[] args)
        {
            argCallbacks = new Dictionary<string, ArgCallback>();
            argCallbacks.Add("--list-mods", Command.ListMods);
            argCallbacks.Add("-l", Command.ListMods);
            argCallbacks.Add("--mod-info", Command.ListModInfo);
            argCallbacks.Add("-i", Command.ListModInfo);
            argCallbacks.Add("--download-url", Command.DownloadUrl);
            argCallbacks.Add("--extract-zip", Command.ExtractZip);
            argCallbacks.Add("--install-ra-packages", Command.InstallRAPackages);
            argCallbacks.Add("--install-cnc-packages", Command.InstallCncPackages);
            argCallbacks.Add("--settings-value", Command.Settings);

            if (args.Length == 0) { PrintUsage(); return; }
            var arg = SplitArgs(args[0]);

            bool piping = false;
            if (args.Length > 1 && SplitArgs(args[1]).Key == "--pipe")
            {
                piping = true;
                string pipename = SplitArgs(args[1]).Value;
                NamedPipeServerStream pipe;
                var id = WindowsIdentity.GetCurrent();
                var principal = new WindowsPrincipal(id);
                if (principal.IsInRole(WindowsBuiltInRole.Administrator))
                {
                    var ps = new PipeSecurity();
                    ps.AddAccessRule(new PipeAccessRule("EVERYONE", (PipeAccessRights)2032031, AccessControlType.Allow));
                    pipe = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.None, 1024*1024, 1024*1024, ps);
                }
                else
                    pipe = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.None, 1024*1024,1024*1024,null);

                pipe.WaitForConnection();
                Console.SetOut(new StreamWriter(pipe) { AutoFlush = true });
            }

            ArgCallback callback;
            if (argCallbacks.TryGetValue(arg.Key, out callback))
                callback(arg.Value);
            else
                PrintUsage();

            if (piping)
                Console.Out.Close();
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:46,代码来源:Program.cs

示例13: Init

 public void Init()
 {
     lock (pipeServerLock)
     {
         if (pipeServer != null)
         {
             return;
         }
         var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
         var rule = new PipeAccessRule(sid, PipeAccessRights.ReadWrite,
         System.Security.AccessControl.AccessControlType.Allow);
         var sec = new PipeSecurity();
         sec.AddAccessRule(rule);
         pipeServer = new NamedPipeServerStream(HealthCheckSettings.HEALTH_CHECK_PIPE, PipeDirection.In, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous, 0, 0, sec);
         pipeServer.BeginWaitForConnection(new AsyncCallback(WaitForConnectionCallBack), pipeServer);
     }
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:17,代码来源:CredentialReceiver.cs

示例14: RpcPipeServerChannel

        public RpcPipeServerChannel(string pipeName, int instanceCount)
        {
            _pipeName = pipeName;
            _pipeServers = new NamedPipeServerStream[instanceCount];
            for (int i = 0; i < instanceCount; i++) {
                //
                // TODO: Add PipeSecurity
                PipeSecurity security = new PipeSecurity();
                // new PipeAccessRule(.

                security.AddAccessRule(new PipeAccessRule(new NTAccount("Everyone"), PipeAccessRights.FullControl, AccessControlType.Allow));

                _pipeServers[i] = new NamedPipeServerStream(pipeName, PipeDirection.InOut,
                    instanceCount, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 0,
                    security);

            }
        }
开发者ID:amwtke,项目名称:commonlibrary,代码行数:18,代码来源:RpcPipeServerChannel.cs

示例15: StartServer

 public void StartServer(SelectCounter selectCountersDelegate, ReceivedValues receivedValuesDelegate)
 {
     selectCounters = selectCountersDelegate;
     receivedValues = receivedValuesDelegate;
     System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
     PipeAccessRule pac = new PipeAccessRule(sid, PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow);
     PipeSecurity ps = new PipeSecurity();
     ps.AddAccessRule(pac);
     sid = null;
     pipeServer = new NamedPipeServerStream(serverPipeName,
             PipeDirection.InOut,
             serverInstances,
             PipeTransmissionMode.Message,
             PipeOptions.Asynchronous,
             1024,
             1024,
             ps);
     AsyncCallback myCallback = new AsyncCallback(AsyncPipeCallback);
     pipeServer.BeginWaitForConnection(myCallback, null);
 }
开发者ID:GabrieleCocco,项目名称:OpenCLMonitor,代码行数:20,代码来源:Server.cs


注:本文中的System.IO.Pipes.PipeSecurity.AddAccessRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。