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
- SqlWebEventProvider.cs
- ParameterEditorUserControl.cs
- InternalCache.cs
- NamespaceMapping.cs
- KeyedCollection.cs
- WebResourceAttribute.cs
- Point3D.cs
- ReferentialConstraintRoleElement.cs
- TransportManager.cs
- WebPartVerb.cs
- PermissionSetTriple.cs
- CodeArgumentReferenceExpression.cs
- _BufferOffsetSize.cs
- FormViewInsertEventArgs.cs
- CompositionAdorner.cs
- ImportCatalogPart.cs
- ValueTable.cs
- BevelBitmapEffect.cs
- GetFileNameResult.cs
- FontNameEditor.cs
- PolicyException.cs
- XmlElementCollection.cs
- ResourceDefaultValueAttribute.cs
- WsatProxy.cs
- BamlLocalizabilityResolver.cs
- PresentationSource.cs
- Animatable.cs
- Monitor.cs
- EntityClientCacheKey.cs
- InstallerTypeAttribute.cs
- WebPartUserCapability.cs
- XamlTreeBuilderBamlRecordWriter.cs
- HyperLinkDesigner.cs
- ByteStream.cs
- ListBoxDesigner.cs
- ItemCheckedEvent.cs
- EventLogEntryCollection.cs
- DataColumnChangeEvent.cs
- LabelAutomationPeer.cs
- EventLogPermission.cs
- NumericExpr.cs
- SystemWebCachingSectionGroup.cs
- HostUtils.cs
- RawStylusActions.cs
- AstTree.cs
- InvalidCommandTreeException.cs
- InternalDuplexChannelFactory.cs
- InternalConfigSettingsFactory.cs
- LicenseContext.cs
- WorkItem.cs
- precedingquery.cs
- GZipDecoder.cs
- DeviceContext2.cs
- TimersDescriptionAttribute.cs
- SystemWebSectionGroup.cs
- AccessibleObject.cs
- KeyConstraint.cs
- BevelBitmapEffect.cs
- _BufferOffsetSize.cs
- TextDecorationCollection.cs
- ImageButton.cs
- TrackingCondition.cs
- AtomPub10ServiceDocumentFormatter.cs
- ByteBufferPool.cs
- SaveFileDialog.cs
- SecurityChannelListener.cs
- DefaultTextStore.cs
- HGlobalSafeHandle.cs
- CodeRegionDirective.cs
- MediaElementAutomationPeer.cs
- Convert.cs
- Vector.cs
- Geometry3D.cs
- CorrelationKey.cs
- StyleBamlTreeBuilder.cs
- TreePrinter.cs
- FrameworkContentElement.cs
- ComponentResourceKey.cs
- TrackingRecord.cs
- HtmlImage.cs
- FontStyle.cs
- Overlapped.cs
- ServiceNameElementCollection.cs
- DataGridViewCheckBoxColumn.cs
- MiniMapControl.xaml.cs
- Configuration.cs
- ObjectHandle.cs
- DetailsViewRow.cs
- ReaderWriterLockWrapper.cs
- FormView.cs
- WsatConfiguration.cs
- AggregateNode.cs
- PnrpPermission.cs
- EUCJPEncoding.cs
- StyleBamlRecordReader.cs
- NativeMethodsOther.cs
- GlobalizationSection.cs
- CalendarDay.cs
- SimpleMailWebEventProvider.cs
- MailAddress.cs