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
- IdnMapping.cs
- SqlUDTStorage.cs
- FixedStringLookup.cs
- XmlAttributeCollection.cs
- Lease.cs
- DocumentDesigner.cs
- CheckedPointers.cs
- PropertyBuilder.cs
- ListItemCollection.cs
- SmtpNetworkElement.cs
- UnsafeNativeMethodsTablet.cs
- SkinBuilder.cs
- Main.cs
- mansign.cs
- XmlValidatingReaderImpl.cs
- ValidationErrorEventArgs.cs
- PeekCompletedEventArgs.cs
- DigitalSignature.cs
- TypographyProperties.cs
- ActiveXHelper.cs
- ContentFilePart.cs
- ConfigurationValidatorBase.cs
- SqlExpander.cs
- BrowserCapabilitiesCompiler.cs
- TrackBar.cs
- SoapInteropTypes.cs
- MetaModel.cs
- TransactionFilter.cs
- BulletChrome.cs
- DataBoundLiteralControl.cs
- PresentationSource.cs
- PageCatalogPart.cs
- DataContext.cs
- httpapplicationstate.cs
- Journal.cs
- Visual.cs
- __Filters.cs
- WindowsScrollBarBits.cs
- RuleProcessor.cs
- PathParser.cs
- CommentEmitter.cs
- XmlArrayItemAttributes.cs
- ActivationArguments.cs
- DisposableCollectionWrapper.cs
- IndexOutOfRangeException.cs
- XmlDataSourceNodeDescriptor.cs
- DesignSurfaceCollection.cs
- ZoomPercentageConverter.cs
- _ConnectOverlappedAsyncResult.cs
- XPathMultyIterator.cs
- DetailsViewAutoFormat.cs
- PropertyDescriptorCollection.cs
- DateTimeFormat.cs
- ImageInfo.cs
- DataTableMappingCollection.cs
- XmlWhitespace.cs
- FacetChecker.cs
- UpdateExpressionVisitor.cs
- RootBrowserWindow.cs
- CipherData.cs
- XmlSchemaProviderAttribute.cs
- MailHeaderInfo.cs
- WindowsToolbar.cs
- TrackingProfileSerializer.cs
- DataComponentMethodGenerator.cs
- WindowsSspiNegotiation.cs
- HwndMouseInputProvider.cs
- Policy.cs
- TraceHandlerErrorFormatter.cs
- TextTreePropertyUndoUnit.cs
- LinkConverter.cs
- HotSpot.cs
- ReservationCollection.cs
- ToolStripHighContrastRenderer.cs
- ColorComboBox.cs
- XmlSchemaProviderAttribute.cs
- SqlUnionizer.cs
- TableLayoutPanel.cs
- StorageConditionPropertyMapping.cs
- DrawTreeNodeEventArgs.cs
- UserMapPath.cs
- SolidColorBrush.cs
- SqlFactory.cs
- PerformanceCounterLib.cs
- TransactionManagerProxy.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- AmbiguousMatchException.cs
- WebConfigurationHost.cs
- Parallel.cs
- TCEAdapterGenerator.cs
- DbCommandDefinition.cs
- SemaphoreFullException.cs
- GroupBox.cs
- SchemaTableColumn.cs
- UnaryNode.cs
- webproxy.cs
- Vector3DAnimationUsingKeyFrames.cs
- BasicKeyConstraint.cs
- WindowsGraphicsWrapper.cs
- DropShadowEffect.cs