Esempio n. 1
0
 public NamedPipeIpcServer(
     String pipename,
     IIpcCallback callback,
     int instances
     )
 {
     Debug.Assert(!m_running);
     m_running = true;
     // Save parameters for next new pipe
     m_pipename = pipename;
     m_callback = callback;
     // Provide full access to the current user so more pipe instances can be created
     m_ps = new PipeSecurity();
     m_ps.AddAccessRule(
         new PipeAccessRule(WindowsIdentity.GetCurrent().User, PipeAccessRights.FullControl, AccessControlType.Allow)
         );
     m_ps.AddAccessRule(
         new PipeAccessRule(
             new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow
             )
         );
     // Start accepting connections
     for (int i = 0; i < instances; ++i)
     {
         IpcServerPipeCreate();
     }
 }
Esempio n. 2
0
        public IpcService(
            String pipename,
            IIpcCallback iipcCallback,
            int instances
            )
        {
            Debug.Assert(!_running);
            _running = true;

            // Save parameters for next new pipe
            _pipeName     = pipename;
            _iipcCallback = iipcCallback;

            // Provide full access to the current user so more pipe instances can be created
            _pipeSecurity = new PipeSecurity();
            _pipeSecurity.AddAccessRule(
                new PipeAccessRule(WindowsIdentity.GetCurrent().User, PipeAccessRights.FullControl, AccessControlType.Allow)
                );

            // To give access to all authenticated users (NOT SECURE!)

            /*
             * _pipeSecurity.AddAccessRule(
             *  new PipeAccessRule(
             *      new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow
             *  )
             * );
             */

            // Give access to builtin Administrators only
            _pipeSecurity.AddAccessRule(
                new PipeAccessRule(
                    new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow
                    )
                );

            // Start accepting connections
            for (int i = 0; i < instances; ++i)
            {
                IpcServerPipeCreate();
            }
        }