• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Pipes.PipeSecurity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PipeSecurity类属于System.IO.Pipes命名空间,在下文中一共展示了PipeSecurity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Run

        public void Run()
        {
            while (true)
            {
                var security = new PipeSecurity();
                security.SetAccessRule(new PipeAccessRule("Administrators", PipeAccessRights.FullControl, AccessControlType.Allow));

                using (pipeServer = new NamedPipeServerStream(
                    Config.PipeName,
                    PipeDirection.InOut,
                    NamedPipeServerStream.MaxAllowedServerInstances,
                    PipeTransmissionMode.Message,
                    PipeOptions.None,
                    Config.BufferSize, Config.BufferSize,
                    security,
                    HandleInheritability.None
                    ))
                {
                    try
                    {
                        Console.Write("Waiting...");
                        pipeServer.WaitForConnection();
                        Console.WriteLine("...Connected!");

                        if (THROTTLE_TIMER)
                        {
                            timer = new Timer
                            {
                                Interval = THROTTLE_DELAY,
                            };
                            timer.Elapsed += (sender, args) => SendMessage();
                            timer.Start();

                            while(pipeServer.IsConnected)Thread.Sleep(1);
                            timer.Stop();
                        }
                        else
                        {
                            while (true) SendMessage();
                        }
                    }
                    catch(Exception ex)
                    {
                        Console.WriteLine("Error: " + ex.Message);
                    }
                    finally
                    {
                        if (pipeServer != null)
                        {
                            Console.WriteLine("Cleaning up pipe server...");
                            pipeServer.Disconnect();
                            pipeServer.Close();
                            pipeServer = null;
                        }
                    }

                }

            }
        }
开发者ID:nathanchere,项目名称:Spikes_JukeSaver,代码行数:60,代码来源:Server.cs


示例3: 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


示例4: 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


示例5: 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


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: AnonymousPipeServerStream

		public AnonymousPipeServerStream (PipeDirection direction, HandleInheritability inheritability, int bufferSize, PipeSecurity pipeSecurity)
			: base (direction, bufferSize)
		{
			if (direction == PipeDirection.InOut)
				throw new NotSupportedException ("Anonymous pipe direction can only be either in or out.");

			if (IsWindows)
				impl = new Win32AnonymousPipeServer (this, direction, inheritability, bufferSize, pipeSecurity);
			else
				impl = new UnixAnonymousPipeServer (this, direction, inheritability, bufferSize);

			InitializeHandle (impl.Handle, false, false);
			IsConnected = true;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:AnonymousPipeServerStream.cs


示例13: NamedPipeServerStream

		public NamedPipeServerStream (string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize, PipeSecurity pipeSecurity, HandleInheritability inheritability, PipeAccessRights additionalAccessRights)
			: base (direction, transmissionMode, outBufferSize)
		{
			if (pipeSecurity != null)
				throw ThrowACLException ();
			var rights = ToAccessRights (direction) | additionalAccessRights;
			// FIXME: reject some rights declarations (for ACL).

			if (IsWindows)
				impl = new Win32NamedPipeServer (this, pipeName, maxNumberOfServerInstances, transmissionMode, rights, options, inBufferSize, outBufferSize, inheritability);
			else
				impl = new UnixNamedPipeServer (this, pipeName, maxNumberOfServerInstances, transmissionMode, rights, options, inBufferSize, outBufferSize, inheritability);

			InitializeHandle (impl.Handle, false, (options & PipeOptions.Asynchronous) != PipeOptions.None);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:15,代码来源:NamedPipeServerStream.cs


示例14: Server

        public Server()
        {
            var security = new PipeSecurity();
            security.SetAccessRule(new PipeAccessRule("Administrators", PipeAccessRights.FullControl, AccessControlType.Allow)); // TODO: other options?

            pipeServer = new NamedPipeServerStream(
                Config.PipeName,
                PipeDirection.InOut, // TODO: single direction, benefits?
                NamedPipeServerStream.MaxAllowedServerInstances,
                PipeTransmissionMode.Message, // TODO: investigate other options
                PipeOptions.None, // TODO: Async and writethrough, benefits?
                Config.BufferSize, Config.BufferSize,
                security,
                HandleInheritability.None
            );
        }
开发者ID:nathanchere,项目名称:Spikes_JukeSaver,代码行数:16,代码来源:Server.cs


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: SetAccessControl

        public static void SetAccessControl(this PipeStream stream, PipeSecurity pipeSecurity)
        {
            // PipeState can not be Closed and the Handle can not be null or closed
            if (pipeSecurity == null)
            {
                throw new ArgumentNullException(nameof(pipeSecurity));
            }

            var handle = stream.SafePipeHandle; // A non-null, open handle implies a non-closed PipeState.

            // NamedPipeClientStream: PipeState can not be WaitingToConnect or Broken. WaitingToConnect is covered by the SafePipeHandle check.
            if (stream is NamedPipeClientStream && !stream.IsConnected) // Pipe could also be WaitingToConnect, Broken, Disconnected, or Closed.
            {
                throw new InvalidOperationException(SR.InvalidOperation_PipeNotYetConnected);
            }

            pipeSecurity.Persist(handle);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:18,代码来源:PipesAclExtensions.cs


示例20: Start

        internal void Start()
        {
            // setting up pipeServer
            PipeSecurity pipeSec = new PipeSecurity();
            pipeSec.SetAccessRule(new PipeAccessRule("Everyone", PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow));
            pipeServer = new NamedPipeServerStream(
                "HKHRATP2\\" + System.Diagnostics.Process.GetCurrentProcess().ProcessName + System.Diagnostics.Process.GetCurrentProcess().Id,
                PipeDirection.InOut,
                1,
                PipeTransmissionMode.Message,
                PipeOptions.Asynchronous,
                4096,
                4096,
                pipeSec,
                System.IO.HandleInheritability.None
            );

            StartListening();
        }
开发者ID:hkgsherlock,项目名称:hkhr-atp2,代码行数:19,代码来源:AsyncPipeServer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ports.SerialDataReceivedEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Pipes.NamedPipeServerStream类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap