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
- Crypto.cs
- ListBox.cs
- DesignSurfaceManager.cs
- DecimalConstantAttribute.cs
- Style.cs
- XmlChildNodes.cs
- ConnectionInterfaceCollection.cs
- WmiPutTraceRecord.cs
- ListenerSingletonConnectionReader.cs
- UserControl.cs
- IdentitySection.cs
- RegularExpressionValidator.cs
- JapaneseLunisolarCalendar.cs
- ClientOperation.cs
- Graph.cs
- BitmapEffectState.cs
- PublisherMembershipCondition.cs
- XmlWhitespace.cs
- TemplateField.cs
- _ScatterGatherBuffers.cs
- GB18030Encoding.cs
- RawStylusInputReport.cs
- ToolStripLocationCancelEventArgs.cs
- ListItemCollection.cs
- JapaneseLunisolarCalendar.cs
- DataGridViewCellPaintingEventArgs.cs
- DocumentAutomationPeer.cs
- SQLDecimalStorage.cs
- ConfigurationStrings.cs
- XmlSchemaImporter.cs
- Funcletizer.cs
- RegistryDataKey.cs
- WindowsStreamSecurityElement.cs
- BuildProvider.cs
- SimpleType.cs
- CharAnimationBase.cs
- CultureTableRecord.cs
- BmpBitmapDecoder.cs
- SspiSecurityTokenParameters.cs
- DeviceContext2.cs
- keycontainerpermission.cs
- EntityViewGenerationAttribute.cs
- Bold.cs
- ActiveXContainer.cs
- BaseHashHelper.cs
- ItemCheckedEvent.cs
- Rules.cs
- SqlConnectionPoolProviderInfo.cs
- SignerInfo.cs
- InplaceBitmapMetadataWriter.cs
- SetterBase.cs
- MarkupObject.cs
- HwndAppCommandInputProvider.cs
- Registry.cs
- BatchWriter.cs
- SiteMapNode.cs
- KeyValueConfigurationElement.cs
- AbandonedMutexException.cs
- WebPartTracker.cs
- XamlPoint3DCollectionSerializer.cs
- EndpointDiscoveryMetadata11.cs
- HTMLTextWriter.cs
- PropertyMetadata.cs
- DynamicVirtualDiscoSearcher.cs
- DocumentEventArgs.cs
- Button.cs
- QilPatternVisitor.cs
- ScriptComponentDescriptor.cs
- __ConsoleStream.cs
- PropertyState.cs
- StylusPointPropertyUnit.cs
- FormViewRow.cs
- SqlBulkCopyColumnMappingCollection.cs
- PointHitTestResult.cs
- X509CertificateEndpointIdentity.cs
- PolicyStatement.cs
- RijndaelCryptoServiceProvider.cs
- DecoderNLS.cs
- Style.cs
- SaveWorkflowAsyncResult.cs
- DBAsyncResult.cs
- Control.cs
- SqlComparer.cs
- ToolStripRenderEventArgs.cs
- DefaultWorkflowLoaderService.cs
- SolidBrush.cs
- GridItemCollection.cs
- SqlError.cs
- ObjectItemCollection.cs
- CardSpaceShim.cs
- SynchronizationLockException.cs
- StdValidatorsAndConverters.cs
- ColumnTypeConverter.cs
- CanExecuteRoutedEventArgs.cs
- OneOfElement.cs
- XmlAtomicValue.cs
- CodeSnippetTypeMember.cs
- ValidationRule.cs
- SqlDataSourceEnumerator.cs
- ContentValidator.cs