Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / xws_reg / System / ServiceModel / Install / InfoCardServiceInstallComponent.cs / 1 / InfoCardServiceInstallComponent.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Install { using Microsoft.Win32; using System.ServiceProcess; class InfoCardServiceInstallComponent : ServiceInstallComponent { public InfoCardServiceInstallComponent() : base(ServiceModelInstallStrings.InfoCardServiceName, ServiceModelInstallStrings.LegacyInfoCardServiceName, SR.GetString(SR.InfoCardServiceDisplayName), ServiceStartMode.Manual, ServiceModelInstallStrings.InfoCardServiceExeName, null, null, null, SR.GetString(SR.InfoCardServiceDescription), ServiceModelInstallStrings.InfoCardServiceSecurityDescriptor) { // empty } protected override void OnInstall(OutputLevel outputLevel) { base.OnInstall(outputLevel); this.SetExtendedProperties(); } protected override void OnReinstall(OutputLevel outputLevel) { base.OnReinstall(outputLevel); this.SetExtendedProperties(); } void SetExtendedProperties() { // Configure the infocard service on LH+ by stripping privileges and applying network rules if (OSEnvironmentHelper.IsVistaOrGreater) { // // We set the service name in the constructor, hence use this.ServiceName // ExecuteSC( "privs " + this.ServiceName + " SeTcbPrivilege/SeAssignPrimaryTokenPrivilege/SeTakeOwnershipPrivilege/SeBackupPrivilege/SeRestorePrivilege/SeImpersonatePrivilege" ); // Setup network rules to allow all outgoing over tcp only and disable all incoming. using (RegistryKey key = Registry.LocalMachine.OpenSubKey(ServiceModelInstallStrings.InfoCardNetworkRestrictionKey, true)) { key.SetValue(ServiceModelInstallStrings.InfoCardBlockInRegKeyName, ServiceModelInstallStrings.InfoCardBlockInRegKeyValue); key.SetValue(ServiceModelInstallStrings.InfoCardAllowTcpOutRegKeyName, ServiceModelInstallStrings.InfoCardAllowTcpOutRegKeyValue); key.SetValue(ServiceModelInstallStrings.InfoCardBlockOtherOutRegKeyName, ServiceModelInstallStrings.InfoCardBlockOtherOutRegKeyValue); } } } protected override void OnUninstall(OutputLevel outputLevel) { base.OnUninstall(outputLevel); // Remove the infocard network restrictions if appropriate. if (OSEnvironmentHelper.IsVistaOrGreater) { InfoCardServiceInstallComponent .TryDeleteRegistryKeyValue(ServiceModelInstallStrings.InfoCardNetworkRestrictionKey, ServiceModelInstallStrings.InfoCardAllowTcpOutRegKeyName); InfoCardServiceInstallComponent .TryDeleteRegistryKeyValue(ServiceModelInstallStrings.InfoCardNetworkRestrictionKey, ServiceModelInstallStrings.InfoCardBlockInRegKeyName); InfoCardServiceInstallComponent .TryDeleteRegistryKeyValue(ServiceModelInstallStrings.InfoCardNetworkRestrictionKey, ServiceModelInstallStrings.InfoCardBlockOtherOutRegKeyName); } } static void TryDeleteRegistryKeyValue(string subKey, string valueName) { RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(subKey, true); if (null != registryKey) { using (registryKey) { try { registryKey.DeleteValue(valueName); } catch (ArgumentException) { // ignore the exception if the value cannot be found } } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebConfigurationHost.cs
- SafeNativeMethodsCLR.cs
- ToolboxBitmapAttribute.cs
- OleDbConnectionFactory.cs
- DefaultShape.cs
- Queue.cs
- HMACRIPEMD160.cs
- ObjectAnimationBase.cs
- HttpListenerPrefixCollection.cs
- Section.cs
- CreateUserWizardDesigner.cs
- CodeMemberProperty.cs
- ColumnWidthChangedEvent.cs
- ManifestResourceInfo.cs
- FontStretches.cs
- loginstatus.cs
- InitializingNewItemEventArgs.cs
- PseudoWebRequest.cs
- XmlIncludeAttribute.cs
- UserNameSecurityToken.cs
- WorkflowView.cs
- SectionRecord.cs
- XmlDocumentType.cs
- ServiceDescriptionReflector.cs
- Stylesheet.cs
- fixedPageContentExtractor.cs
- WriterOutput.cs
- SqlTriggerAttribute.cs
- TypeNameHelper.cs
- ToolStripMenuItemCodeDomSerializer.cs
- TabItem.cs
- AttributeQuery.cs
- TextFindEngine.cs
- ConnectionManagementElementCollection.cs
- TextEndOfLine.cs
- ControlHelper.cs
- ErrorInfoXmlDocument.cs
- XmlSchemaAnnotation.cs
- XmlCountingReader.cs
- ZipIOModeEnforcingStream.cs
- FeatureAttribute.cs
- PersistencePipeline.cs
- EntityDataSourceMemberPath.cs
- Lock.cs
- ContainerFilterService.cs
- WindowsListViewGroup.cs
- ObjectStateManager.cs
- XsdDataContractImporter.cs
- AsyncCodeActivityContext.cs
- CqlIdentifiers.cs
- PenLineCapValidation.cs
- AccessDataSourceView.cs
- GlobalAllocSafeHandle.cs
- DataTableMapping.cs
- TextEditor.cs
- XmlSchemaAppInfo.cs
- SourceFileBuildProvider.cs
- PublishLicense.cs
- WebPermission.cs
- XPathPatternParser.cs
- MultiDataTrigger.cs
- PackageDigitalSignatureManager.cs
- BitConverter.cs
- AssociationSet.cs
- XmlWriterTraceListener.cs
- ToolStripDropDownButton.cs
- MessageOperationFormatter.cs
- RequestSecurityTokenForRemoteTokenFactory.cs
- TrackingSection.cs
- IsolatedStorage.cs
- BaseDataListPage.cs
- Assembly.cs
- HttpModuleAction.cs
- Span.cs
- EndSelectCardRequest.cs
- RtfControlWordInfo.cs
- GridViewEditEventArgs.cs
- DataGridColumnFloatingHeader.cs
- HostedTransportConfigurationManager.cs
- CompModHelpers.cs
- MessageSmuggler.cs
- ToolStripContentPanel.cs
- Gdiplus.cs
- UnauthorizedAccessException.cs
- SqlDelegatedTransaction.cs
- DataGridCommandEventArgs.cs
- UICuesEvent.cs
- UnsafeNativeMethodsPenimc.cs
- SystemFonts.cs
- SafeBitVector32.cs
- SqlDependencyUtils.cs
- WindowsHyperlink.cs
- NamedPipeTransportBindingElement.cs
- SiteMapPath.cs
- DbDataReader.cs
- WebPartCancelEventArgs.cs
- DoubleAnimationBase.cs
- KeyEventArgs.cs
- RawKeyboardInputReport.cs
- SqlConnectionString.cs