コード例 #1
0
        static Binding CreateRegisterBinding(TransportType transportType)
        {
            NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);

            binding.MaxReceivedMessageSize = ListenerConstants.RegistrationMaxReceivedMessageSize;
            CustomBinding customBinding = new CustomBinding(binding);
            NamedPipeTransportBindingElement namedPipeBindingElement = customBinding.Elements.Find <NamedPipeTransportBindingElement>();

            namedPipeBindingElement.ExposeConnectionProperty = true;
            namedPipeBindingElement.AllowedUsers             = ListenerConfig.GetAllowAccounts(transportType);
            customBinding.ReceiveTimeout = TimeSpan.MaxValue;
            return(customBinding);
        }
コード例 #2
0
        void GrantPermissionToAllowedAccounts()
        {
            // SECURITY
            // we need to do this to allow services to lookup our LogonSid and ProcessToken User
            lock (ThisLock)
            {
                Utility.AddRightGrantedToAccounts(ListenerConfig.GetAllowAccounts(this.transportType),
                                                  ListenerUnsafeNativeMethods.PROCESS_QUERY_INFORMATION, true);

                Utility.AddRightGrantedToAccounts(ListenerConfig.GetAllowAccounts(this.transportType),
                                                  ListenerUnsafeNativeMethods.TOKEN_QUERY, false);
            }
        }
コード例 #3
0
        void CreateSharedMemory()
        {
            try
            {
                sharedMemory = SharedMemory.Create(ListenerConstants.GlobalPrefix + sharedMemoryName, controlServiceGuid,
                                                   ListenerConfig.GetAllowAccounts(this.transportType));

                Debug.Print("SharedMemory.Create() sharedMemoryName: " + sharedMemoryName);
            }
            catch (Win32Exception exception)
            {
                Debug.Print("SharedMemory.Create() exception: " + exception);
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)EventLogCategory.SharingService,
                                                    (uint)EventLogEventId.StartErrorPublish,
                                                    exception.ToString());

                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR.GetString(SR.ServiceStartErrorPublish, this.serviceName),
                                                        exception));
            }
        }