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
- MethodBody.cs
- Behavior.cs
- PaintEvent.cs
- GPPOINT.cs
- VScrollProperties.cs
- RadioButtonFlatAdapter.cs
- TraceContextEventArgs.cs
- Panel.cs
- util.cs
- AssociativeAggregationOperator.cs
- ClonableStack.cs
- FillErrorEventArgs.cs
- ChangeProcessor.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- NetMsmqBindingElement.cs
- SHA384Cng.cs
- x509utils.cs
- ObjectDesignerDataSourceView.cs
- SingleStorage.cs
- SqlDataSourceCustomCommandPanel.cs
- InstanceLockedException.cs
- PolyQuadraticBezierSegment.cs
- GridItemCollection.cs
- WebServiceMethodData.cs
- NominalTypeEliminator.cs
- ConfigUtil.cs
- DbConnectionOptions.cs
- DetailsViewDeletedEventArgs.cs
- DbCommandDefinition.cs
- FontFamily.cs
- TransformerTypeCollection.cs
- MenuCommandService.cs
- MessageBodyMemberAttribute.cs
- AttachedAnnotationChangedEventArgs.cs
- Condition.cs
- ResourceProperty.cs
- TopClause.cs
- login.cs
- AssociationSetEnd.cs
- XPathSingletonIterator.cs
- ScriptingRoleServiceSection.cs
- AppearanceEditorPart.cs
- MethodSet.cs
- TagPrefixCollection.cs
- EntityProxyTypeInfo.cs
- Baml2006ReaderContext.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- NavigationWindow.cs
- RelationHandler.cs
- GeneralTransformGroup.cs
- EventSchemaTraceListener.cs
- Subset.cs
- ZipFileInfoCollection.cs
- DbSetClause.cs
- RecognizedWordUnit.cs
- ProviderCollection.cs
- IdleTimeoutMonitor.cs
- ProviderConnectionPoint.cs
- PinnedBufferMemoryStream.cs
- Invariant.cs
- DataGridColumn.cs
- SqlClientMetaDataCollectionNames.cs
- CodeEntryPointMethod.cs
- CodeDomConfigurationHandler.cs
- CngProvider.cs
- SynchronizedKeyedCollection.cs
- RemotingSurrogateSelector.cs
- ToolBarButtonClickEvent.cs
- SqlFormatter.cs
- EntityKeyElement.cs
- EventNotify.cs
- ToolboxComponentsCreatingEventArgs.cs
- UserControlFileEditor.cs
- EntityWithKeyStrategy.cs
- CodeTryCatchFinallyStatement.cs
- MSHTMLHostUtil.cs
- CertificateManager.cs
- BitmapDownload.cs
- DtrList.cs
- DelegateHelpers.cs
- MulticastDelegate.cs
- SctClaimDictionary.cs
- Setter.cs
- ResourceCategoryAttribute.cs
- EndpointDiscoveryMetadata.cs
- ZoneMembershipCondition.cs
- SetIterators.cs
- NonSerializedAttribute.cs
- InstanceHandleConflictException.cs
- FormViewPageEventArgs.cs
- Pen.cs
- DoubleAnimationClockResource.cs
- DynamicPropertyHolder.cs
- DescendantOverDescendantQuery.cs
- SetIterators.cs
- ToolStripMenuItem.cs
- PropertyStore.cs
- XmlTextWriter.cs
- KeyGesture.cs
- PkcsMisc.cs