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
- AppSettingsExpressionBuilder.cs
- SchemaElementLookUpTable.cs
- RuleSetCollection.cs
- DesignerCategoryAttribute.cs
- StorageConditionPropertyMapping.cs
- UserControlDocumentDesigner.cs
- ColorConverter.cs
- SemanticResultKey.cs
- SymbolPair.cs
- Convert.cs
- HttpListenerRequest.cs
- ZipFileInfoCollection.cs
- ProfileInfo.cs
- ActivityXRefConverter.cs
- TemplateXamlTreeBuilder.cs
- CopyNodeSetAction.cs
- CommandField.cs
- EncodingNLS.cs
- TreeNodeConverter.cs
- SafeNativeMethods.cs
- LinqDataSourceContextEventArgs.cs
- HtmlControl.cs
- TextParagraphProperties.cs
- SingleBodyParameterMessageFormatter.cs
- MetadataCache.cs
- NumberFormatInfo.cs
- TextReturnReader.cs
- ProfileParameter.cs
- BitmapFrameDecode.cs
- SqlUserDefinedTypeAttribute.cs
- UriGenerator.cs
- SmiEventStream.cs
- AppDomainFactory.cs
- UpdatePanelControlTrigger.cs
- CodeTypeMemberCollection.cs
- DataServiceHostWrapper.cs
- RevocationPoint.cs
- PriorityQueue.cs
- Equal.cs
- LogExtentCollection.cs
- RequestTimeoutManager.cs
- DynamicResourceExtension.cs
- AddressUtility.cs
- BooleanSwitch.cs
- filewebresponse.cs
- XmlNodeReader.cs
- WebPartDeleteVerb.cs
- AuthorizationRuleCollection.cs
- Scheduler.cs
- FileFormatException.cs
- SatelliteContractVersionAttribute.cs
- TextTreeInsertElementUndoUnit.cs
- DataBoundLiteralControl.cs
- DictationGrammar.cs
- DbConnectionOptions.cs
- SqlEnums.cs
- control.ime.cs
- PathTooLongException.cs
- CompositeScriptReferenceEventArgs.cs
- WebPartTransformerAttribute.cs
- Application.cs
- GeometryCombineModeValidation.cs
- storepermissionattribute.cs
- TypeElementCollection.cs
- InstancePersistence.cs
- WindowInteractionStateTracker.cs
- TcpChannelFactory.cs
- PKCS1MaskGenerationMethod.cs
- TypeSystemProvider.cs
- CreateUserErrorEventArgs.cs
- GACMembershipCondition.cs
- DBSchemaRow.cs
- DependencyPropertyKind.cs
- SettingsAttributeDictionary.cs
- ModelItemImpl.cs
- HuffmanTree.cs
- CodeParameterDeclarationExpressionCollection.cs
- RelationshipConstraintValidator.cs
- IPipelineRuntime.cs
- SHA512Managed.cs
- AssemblyBuilderData.cs
- LayoutEngine.cs
- PathStreamGeometryContext.cs
- SqlExpander.cs
- ZipPackage.cs
- PagedDataSource.cs
- HelpFileFileNameEditor.cs
- RectangleF.cs
- ToolStripStatusLabel.cs
- TableItemProviderWrapper.cs
- QueryRewriter.cs
- CodeGeneratorAttribute.cs
- Block.cs
- HtmlSelect.cs
- DelegatingConfigHost.cs
- ToolStripStatusLabel.cs
- SQLBytes.cs
- WorkflowOperationBehavior.cs
- FigureParaClient.cs
- OptionUsage.cs