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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ResolveNameEventArgs.cs
- DbConnectionPool.cs
- UDPClient.cs
- MouseActionValueSerializer.cs
- SlipBehavior.cs
- versioninfo.cs
- Point3D.cs
- DbConnectionPoolCounters.cs
- XmlDataContract.cs
- ReadOnlyTernaryTree.cs
- BevelBitmapEffect.cs
- TextWriterEngine.cs
- DataRelation.cs
- IsolatedStoragePermission.cs
- LinkClickEvent.cs
- ClientScriptItemCollection.cs
- XmlTextWriter.cs
- StoreContentChangedEventArgs.cs
- ColorIndependentAnimationStorage.cs
- ModelTreeEnumerator.cs
- TabControlAutomationPeer.cs
- DataTableReaderListener.cs
- IgnoreFlushAndCloseStream.cs
- InputLanguageSource.cs
- TransformerConfigurationWizardBase.cs
- XmlWriterTraceListener.cs
- CellQuery.cs
- MissingMethodException.cs
- Region.cs
- TextPattern.cs
- CaseInsensitiveOrdinalStringComparer.cs
- RelationshipConverter.cs
- ConfigsHelper.cs
- XmlSchemaSearchPattern.cs
- ThreadStateException.cs
- FormsIdentity.cs
- COM2FontConverter.cs
- Color.cs
- CheckBoxBaseAdapter.cs
- ObjectTag.cs
- UnsafeNativeMethods.cs
- CompiledXpathExpr.cs
- ImageSource.cs
- TextEndOfParagraph.cs
- TransformCollection.cs
- PowerStatus.cs
- AlternateViewCollection.cs
- MimeMapping.cs
- RbTree.cs
- DataGridTable.cs
- AudioBase.cs
- ModelUtilities.cs
- AssemblyFilter.cs
- BamlRecordReader.cs
- CustomLineCap.cs
- path.cs
- XmlCharCheckingWriter.cs
- SmiRecordBuffer.cs
- PatternMatcher.cs
- CodeAttributeArgument.cs
- RequestQueryProcessor.cs
- ByteStack.cs
- XmlQueryType.cs
- TextContainerChangedEventArgs.cs
- Group.cs
- DataGridViewImageColumn.cs
- VectorCollectionValueSerializer.cs
- NameValueFileSectionHandler.cs
- PersonalizationAdministration.cs
- DrawingBrush.cs
- RootBuilder.cs
- ListenerSessionConnectionReader.cs
- SynchronizedDispatch.cs
- Utils.cs
- ClientTargetCollection.cs
- DrawingImage.cs
- FixedBufferAttribute.cs
- ConfigurationStrings.cs
- SafeWaitHandle.cs
- StringCollection.cs
- SystemIPGlobalStatistics.cs
- UiaCoreTypesApi.cs
- DocumentPageTextView.cs
- PagePropertiesChangingEventArgs.cs
- EmptyImpersonationContext.cs
- GridItem.cs
- DataGridItemEventArgs.cs
- StringCollection.cs
- TextServicesContext.cs
- UseManagedPresentationBindingElement.cs
- TextTrailingCharacterEllipsis.cs
- HttpProfileGroupBase.cs
- ClusterSafeNativeMethods.cs
- ScaleTransform.cs
- CompilerError.cs
- UserNameSecurityTokenProvider.cs
- VisualTarget.cs
- BaseResourcesBuildProvider.cs
- ParserContext.cs
- TextServicesCompartmentContext.cs