Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / xws_reg / System / ServiceModel / Install / ListenerServiceInstallComponent.cs / 1 / ListenerServiceInstallComponent.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Install { using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Security.AccessControl; using System.Security.Principal; using System.ServiceProcess; class ListenerServiceInstallComponent : ServiceInstallComponent { static SecurityIdentifier adminSid; ListenerServiceInstallComponent(string serviceName, string legacyServiceName, string displayName, string serviceArguments, string[] dependsOn, string accountName, string description) : base(serviceName, legacyServiceName, displayName, ServiceStartMode.Disabled, ServiceModelInstallStrings.ListenerServiceExeName, serviceArguments, dependsOn, accountName, description, ServiceModelInstallStrings.ListenerServiceSecurityDescriptor) { // empty } static SecurityIdentifier AdminSid { get { if (adminSid == null) { adminSid = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null); } return adminSid; } } public static ServiceModelInstallComponent CreateTcpPortSharingServiceInstallComponent() { return new ListenerServiceInstallComponent( ServiceModelInstallStrings.TcpPortSharingServiceName, ServiceModelInstallStrings.LegacyTcpPortSharingServiceName, SR.GetString(SR.TcpPortSharingServiceDisplayName), null, ServiceModelInstallStrings.TcpPortSharingServiceDependencies, ServiceModelInstallStrings.LocalServiceAccountName, SR.GetString(SR.TcpPortSharingServiceDescription)); } public static ServiceModelInstallComponent CreateTcpActivationServiceInstallComponent() { return new ListenerServiceInstallComponent( ServiceModelInstallStrings.TcpActivationServiceName, ServiceModelInstallStrings.LegacyTcpActivationServiceName, SR.GetString(SR.TcpActivationServiceDisplayName), null, ServiceModelInstallStrings.TcpActivationServiceDependencies, ServiceModelInstallStrings.LocalServiceAccountName, SR.GetString(SR.TcpActivationServiceDescription)); } public static ServiceModelInstallComponent CreateNamedPipeActivationServiceInstallComponent() { return new ListenerServiceInstallComponent( ServiceModelInstallStrings.NamedPipeActivationServiceName, ServiceModelInstallStrings.LegacyNamedPipeActivationServiceName, SR.GetString(SR.NamedPipeActivationServiceDisplayName), null, ServiceModelInstallStrings.NamedPipeActivationServiceDependencies, ServiceModelInstallStrings.LocalServiceAccountName, SR.GetString(SR.NamedPipeActivationServiceDescription)); } public static ServiceModelInstallComponent CreateMsmqActivationServiceInstallComponent() { return new ListenerServiceInstallComponent( ServiceModelInstallStrings.MsmqActivationServiceName, ServiceModelInstallStrings.LegacyMsmqActivationServiceName, SR.GetString(SR.MsmqActivationServiceDisplayName), "-" + ServiceModelInstallStrings.MsmqActivationServiceName, ServiceModelInstallStrings.MsmqActivationServiceDependencies, ServiceModelInstallStrings.NetworkServiceAccountName, SR.GetString(SR.MsmqActivationServiceDescription)); } protected override void OnInstall(OutputLevel outputLevel) { base.OnInstall(outputLevel); this.SetConfigSecurity(outputLevel); this.SetExtendedProperties(); } protected override void OnReinstall(OutputLevel outputLevel) { base.OnReinstall(outputLevel); this.SetConfigSecurity(outputLevel); this.SetExtendedProperties(); } void SetConfigSecurity(OutputLevel outputLevel) { string listenerConfigFile = Path.Combine(InstallHelper.GetWcfRuntimeInstallPath(), ServiceModelInstallStrings.ListenerServiceExeName + ".config"); FileSecurity fileSecurity = null; try { fileSecurity = File.GetAccessControl(listenerConfigFile); } catch (FileNotFoundException) { // acceptable } if (fileSecurity != null) { fileSecurity.AddAccessRule(new FileSystemAccessRule(AdminSid, FileSystemRights.FullControl, AccessControlType.Allow)); fileSecurity.AddAccessRule(new FileSystemAccessRule(ServiceModelInstallStrings.LocalServiceAccountName, FileSystemRights.Read, AccessControlType.Allow)); fileSecurity.AddAccessRule(new FileSystemAccessRule(ServiceModelInstallStrings.NetworkServiceAccountName, FileSystemRights.Read, AccessControlType.Allow)); try { File.SetAccessControl(listenerConfigFile, fileSecurity); } catch (FileNotFoundException) { // acceptable } } } void SetExtendedProperties() { if (OSEnvironmentHelper.IsVistaOrGreater) { ExecuteSC("sidtype " + this.ServiceName + " restricted"); ExecuteSC("privs " + this.ServiceName + " SeCreateGlobalPrivilege"); } } } } // 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
- FixedPage.cs
- OrthographicCamera.cs
- ObjectReferenceStack.cs
- DataPagerField.cs
- PageContent.cs
- PanelDesigner.cs
- X509ChainPolicy.cs
- ExpressionBuilderContext.cs
- AmbientProperties.cs
- PropertyGeneratedEventArgs.cs
- ServicePointManager.cs
- MouseOverProperty.cs
- WindowsRichEditRange.cs
- SimpleWebHandlerParser.cs
- ClientTarget.cs
- EntityStoreSchemaFilterEntry.cs
- HttpStreamXmlDictionaryWriter.cs
- DbCommandTree.cs
- VirtualizedItemProviderWrapper.cs
- RightsManagementPermission.cs
- DataGridViewTopRowAccessibleObject.cs
- ChangeDirector.cs
- TransformPatternIdentifiers.cs
- SqlRowUpdatedEvent.cs
- CompositionAdorner.cs
- KeyEvent.cs
- MobileComponentEditorPage.cs
- OleDbStruct.cs
- WriteableOnDemandPackagePart.cs
- Table.cs
- ArrayList.cs
- GridViewSortEventArgs.cs
- LinearGradientBrush.cs
- Calendar.cs
- SourceItem.cs
- BrowserCapabilitiesCompiler.cs
- RequestDescription.cs
- SeparatorAutomationPeer.cs
- CalendarDesigner.cs
- ZoomComboBox.cs
- x509store.cs
- InstalledFontCollection.cs
- LongValidator.cs
- MemberInfoSerializationHolder.cs
- Stylesheet.cs
- ObjectDisposedException.cs
- UriWriter.cs
- CurrentChangedEventManager.cs
- IntSecurity.cs
- PrivacyNoticeBindingElementImporter.cs
- DataSourceUtil.cs
- BookmarkTable.cs
- DoubleStorage.cs
- RuntimeConfig.cs
- ItemsPresenter.cs
- EditModeSwitchButton.cs
- XmlILTrace.cs
- XmlAttributeCache.cs
- LineServicesCallbacks.cs
- OleDbCommand.cs
- XmlValidatingReaderImpl.cs
- SecurityTokenContainer.cs
- RotateTransform.cs
- UserControlFileEditor.cs
- CodeComment.cs
- DuplicateWaitObjectException.cs
- CustomErrorsSection.cs
- Configuration.cs
- SiteMapDataSource.cs
- CategoriesDocument.cs
- LinearKeyFrames.cs
- CapiHashAlgorithm.cs
- ZipIOExtraField.cs
- KoreanLunisolarCalendar.cs
- EntityTypeBase.cs
- TimeSpanFormat.cs
- TaiwanCalendar.cs
- DataKeyCollection.cs
- DesignerVerbCollection.cs
- SmtpReplyReaderFactory.cs
- OdbcEnvironment.cs
- HelloMessageApril2005.cs
- UInt16Converter.cs
- MediaElement.cs
- ItemList.cs
- AxisAngleRotation3D.cs
- GenerateScriptTypeAttribute.cs
- LaxModeSecurityHeaderElementInferenceEngine.cs
- HttpException.cs
- ApplicationInfo.cs
- CellPartitioner.cs
- ProtocolsConfigurationEntry.cs
- ViewStateModeByIdAttribute.cs
- BackStopAuthenticationModule.cs
- Thumb.cs
- ColorMatrix.cs
- SqlErrorCollection.cs
- PenThreadWorker.cs
- ElementHostAutomationPeer.cs
- PropertyChangingEventArgs.cs