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
- SmtpAuthenticationManager.cs
- InputMethodStateChangeEventArgs.cs
- XamlRtfConverter.cs
- Style.cs
- ApplicationInfo.cs
- Gdiplus.cs
- DataControlLinkButton.cs
- RegexRunner.cs
- ObjectNotFoundException.cs
- SerializationInfoEnumerator.cs
- SqlCachedBuffer.cs
- DetailsViewRowCollection.cs
- Point.cs
- ConnectionInterfaceCollection.cs
- WindowsTreeView.cs
- XPathItem.cs
- SpellerInterop.cs
- Matrix3D.cs
- DynamicDocumentPaginator.cs
- odbcmetadatacollectionnames.cs
- Range.cs
- DbProviderFactoriesConfigurationHandler.cs
- ErrorEventArgs.cs
- MetadataProperty.cs
- SqlCachedBuffer.cs
- GetChildSubtree.cs
- DataTableMappingCollection.cs
- XmlnsPrefixAttribute.cs
- BindingExpressionUncommonField.cs
- PropertyContainer.cs
- XmlSchemaSimpleContent.cs
- ActiveXSite.cs
- WebConfigurationHost.cs
- ProcessRequestArgs.cs
- CatalogPartChrome.cs
- RouteParametersHelper.cs
- WeakReferenceKey.cs
- DiscoveryClientRequestChannel.cs
- VirtualizingPanel.cs
- LingerOption.cs
- RuntimeHelpers.cs
- ObjectContext.cs
- SupportedAddressingMode.cs
- DbDataReader.cs
- SiteMapNodeCollection.cs
- MetadataSource.cs
- CatalogZone.cs
- InputQueueChannel.cs
- ApplicationServiceHelper.cs
- OracleFactory.cs
- NavigationExpr.cs
- CachedCompositeFamily.cs
- HwndProxyElementProvider.cs
- NativeMethodsOther.cs
- ErrorFormatter.cs
- ImageMapEventArgs.cs
- TextElementCollectionHelper.cs
- SeparatorAutomationPeer.cs
- PrintingPermissionAttribute.cs
- SwitchElementsCollection.cs
- ListBox.cs
- XmlWrappingReader.cs
- PowerModeChangedEventArgs.cs
- StatusStrip.cs
- wgx_exports.cs
- SqlUtils.cs
- NativeMethods.cs
- TypeDescriptionProvider.cs
- SqlMethodCallConverter.cs
- PageThemeBuildProvider.cs
- CompModSwitches.cs
- PlaceHolder.cs
- ControlCachePolicy.cs
- Contracts.cs
- Classification.cs
- MembershipValidatePasswordEventArgs.cs
- MemberHolder.cs
- DispatcherBuilder.cs
- FileDetails.cs
- CodeAttributeDeclarationCollection.cs
- ListBoxItem.cs
- CodeDelegateCreateExpression.cs
- CountAggregationOperator.cs
- bidPrivateBase.cs
- ImageCodecInfo.cs
- SqlDataSourceSummaryPanel.cs
- DataContext.cs
- ReaderWriterLock.cs
- ListenerHandler.cs
- newitemfactory.cs
- Thread.cs
- UpDownEvent.cs
- IPEndPoint.cs
- SQLBytes.cs
- MachineKeySection.cs
- PropertyInfoSet.cs
- Point.cs
- ChangePasswordDesigner.cs
- TextEffect.cs
- AttributeInfo.cs