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
- WebSysDefaultValueAttribute.cs
- SecurityContextCookieSerializer.cs
- CircleHotSpot.cs
- PropertyPath.cs
- TCPListener.cs
- TreeSet.cs
- UInt64Storage.cs
- TextModifierScope.cs
- WinFormsComponentEditor.cs
- UserNameSecurityTokenProvider.cs
- SafeMILHandleMemoryPressure.cs
- WindowsToolbarAsMenu.cs
- XamlPathDataSerializer.cs
- HelloOperationAsyncResult.cs
- Image.cs
- ListParagraph.cs
- HandleRef.cs
- ToolTip.cs
- SpecularMaterial.cs
- EdmSchemaError.cs
- _NTAuthentication.cs
- XmlBinaryWriterSession.cs
- assertwrapper.cs
- TdsEnums.cs
- OperationAbortedException.cs
- InspectionWorker.cs
- SimpleHandlerFactory.cs
- PropertyTabChangedEvent.cs
- PrintDocument.cs
- DrawingServices.cs
- SmiContext.cs
- TemplateLookupAction.cs
- SoapHttpTransportImporter.cs
- GenericWebPart.cs
- XmlAggregates.cs
- EntityDataSourceDesignerHelper.cs
- GeneralTransformGroup.cs
- PropertyGridEditorPart.cs
- ItemAutomationPeer.cs
- PtsContext.cs
- MultiSelector.cs
- CompilerLocalReference.cs
- GregorianCalendar.cs
- Registry.cs
- DateTimeOffsetConverter.cs
- ButtonBaseAdapter.cs
- SHA256Managed.cs
- FunctionDefinition.cs
- DBSqlParserTable.cs
- ActivityCodeDomSerializationManager.cs
- TreeIterators.cs
- ObjectNavigationPropertyMapping.cs
- TypeConvertions.cs
- MonitoringDescriptionAttribute.cs
- ResourceDisplayNameAttribute.cs
- InsufficientMemoryException.cs
- DelimitedListTraceListener.cs
- UnitySerializationHolder.cs
- Condition.cs
- MsdtcWrapper.cs
- Odbc32.cs
- Keywords.cs
- ControlOperationInvoker.cs
- SchemaMapping.cs
- PropertyValidationContext.cs
- AuthorizationContext.cs
- ZipIOCentralDirectoryFileHeader.cs
- SafeUserTokenHandle.cs
- LongValidatorAttribute.cs
- EndCreateSecurityTokenRequest.cs
- InputReferenceExpression.cs
- CustomAttributeFormatException.cs
- PersistenceException.cs
- EntityDesignerBuildProvider.cs
- Int32Collection.cs
- WebConfigurationHostFileChange.cs
- SimpleApplicationHost.cs
- CodeLabeledStatement.cs
- StreamSecurityUpgradeProvider.cs
- ProfileInfo.cs
- DisplayClaim.cs
- StylusPlugInCollection.cs
- EventLogInformation.cs
- Expression.cs
- SplayTreeNode.cs
- AuthorizationRuleCollection.cs
- OpacityConverter.cs
- LongValidatorAttribute.cs
- WCFModelStrings.Designer.cs
- WindowsRichEditRange.cs
- ExpressionWriter.cs
- ServiceControllerDesigner.cs
- DataFormats.cs
- RestHandler.cs
- CompatibleIComparer.cs
- EventSource.cs
- CategoryAttribute.cs
- CTreeGenerator.cs
- ScalarConstant.cs
- Completion.cs