Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / WsatServiceAddress.cs / 1 / WsatServiceAddress.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.Tools.ServiceModel.WsatConfig { using System; using System.Globalization; using System.Runtime.InteropServices; class WsatServiceAddress { uint port; string wsatServiceAddress; const string wsatServiceAddressFormat = "https://+:{0}/WsatService/"; const string wsatSecurityDescriptor = "D:(A;;GA;;;NS)"; internal WsatServiceAddress(uint port) { this.port = port; wsatServiceAddress = String.Format(CultureInfo.InvariantCulture, wsatServiceAddressFormat, this.port); } internal void ReserveWsatServiceAddress() { if (Utilities.IsHttpApiLibAvailable) { ReserveURL(wsatServiceAddress, wsatSecurityDescriptor); } } internal void FreeWsatServiceAddress() { if (Utilities.IsHttpApiLibAvailable) { FreeURL(wsatServiceAddress, wsatSecurityDescriptor); } } static void ReserveURL(string networkURL, string securityDescriptor) { int retVal = SafeNativeMethods.NoError; try { retVal = SafeNativeMethods.HttpInitialize(HttpWrapper.HttpApiVersion1, SafeNativeMethods.HTTP_INITIALIZE_CONFIG, IntPtr.Zero); if (SafeNativeMethods.NoError == retVal) { HttpServiceConfigUrlAclKey keyDesc = new HttpServiceConfigUrlAclKey(networkURL); HttpServiceConfigUrlAclParam paramDesc = new HttpServiceConfigUrlAclParam(securityDescriptor); HttpServiceConfigUrlAclSet configInformation = new HttpServiceConfigUrlAclSet(); configInformation.KeyDesc = keyDesc; configInformation.ParamDesc = paramDesc; int configInformationLength = Marshal.SizeOf(configInformation); retVal = SafeNativeMethods.HttpSetServiceConfiguration_UrlAcl(IntPtr.Zero, HttpServiceConfigId.HttpServiceConfigUrlAclInfo, ref configInformation, configInformationLength, IntPtr.Zero); if (SafeNativeMethods.ErrorAlreadyExists == retVal) { retVal = SafeNativeMethods.HttpDeleteServiceConfiguration_UrlAcl(IntPtr.Zero, HttpServiceConfigId.HttpServiceConfigUrlAclInfo, ref configInformation, configInformationLength, IntPtr.Zero); if (SafeNativeMethods.NoError == retVal) { retVal = SafeNativeMethods.HttpSetServiceConfiguration_UrlAcl(IntPtr.Zero, HttpServiceConfigId.HttpServiceConfigUrlAclInfo, ref configInformation, configInformationLength, IntPtr.Zero); } } } } finally { SafeNativeMethods.HttpTerminate(SafeNativeMethods.HTTP_INITIALIZE_CONFIG, IntPtr.Zero); } if (SafeNativeMethods.NoError != retVal) { if (SafeNativeMethods.ErrorAlreadyExists == retVal) { throw new WsatAdminException(WsatAdminErrorCode.REGISTER_HTTPS_PORT_ALREADYEXISTS, SR.GetString(SR.ErrorRegisterHttpsPortAlreadyExists)); } else { throw new WsatAdminException(WsatAdminErrorCode.REGISTER_HTTPS_PORT, SR.GetString(SR.ErrorRegisterHttpsPort, retVal)); } } } static void FreeURL(string networkURL, string securityDescriptor) { int retVal = SafeNativeMethods.NoError; try { retVal = SafeNativeMethods.HttpInitialize(HttpWrapper.HttpApiVersion1, SafeNativeMethods.HTTP_INITIALIZE_CONFIG, IntPtr.Zero); if (SafeNativeMethods.NoError == retVal) { HttpServiceConfigUrlAclKey urlAclKey = new HttpServiceConfigUrlAclKey(networkURL); HttpServiceConfigUrlAclParam urlAclParam = new HttpServiceConfigUrlAclParam(securityDescriptor); HttpServiceConfigUrlAclSet configInformation = new HttpServiceConfigUrlAclSet(); configInformation.KeyDesc = urlAclKey; configInformation.ParamDesc = urlAclParam; int configInformationSize = Marshal.SizeOf(configInformation); retVal = SafeNativeMethods.HttpDeleteServiceConfiguration_UrlAcl(IntPtr.Zero, HttpServiceConfigId.HttpServiceConfigUrlAclInfo, ref configInformation, configInformationSize, IntPtr.Zero); } } finally { SafeNativeMethods.HttpTerminate(SafeNativeMethods.HTTP_INITIALIZE_CONFIG, IntPtr.Zero); } if (retVal != SafeNativeMethods.NoError && retVal != SafeNativeMethods.FileNotFound && retVal != SafeNativeMethods.ErrorInvalidParameter) { throw new WsatAdminException(WsatAdminErrorCode.UNREGISTER_HTTPS_PORT, SR.GetString(SR.ErrorUnregisterHttpsPort, retVal)); } } } } // 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
- StylusCaptureWithinProperty.cs
- FixedElement.cs
- LocalizableAttribute.cs
- DataRelationPropertyDescriptor.cs
- PageAsyncTask.cs
- SrgsRulesCollection.cs
- EraserBehavior.cs
- SoundPlayer.cs
- WebUtil.cs
- BitmapScalingModeValidation.cs
- _AutoWebProxyScriptWrapper.cs
- TextEditorSpelling.cs
- DataGridAddNewRow.cs
- PropertyToken.cs
- FolderBrowserDialog.cs
- ContentPosition.cs
- PenContexts.cs
- ArrayItemReference.cs
- ObjectMemberMapping.cs
- __ConsoleStream.cs
- SkinBuilder.cs
- BigInt.cs
- NavigatingCancelEventArgs.cs
- XsltContext.cs
- ProjectionQueryOptionExpression.cs
- PageSettings.cs
- Viewport2DVisual3D.cs
- NullReferenceException.cs
- VirtualPathUtility.cs
- NameValueConfigurationCollection.cs
- ReadOnlyDictionary.cs
- WindowsStartMenu.cs
- WorkerRequest.cs
- AnnotationStore.cs
- DocumentPageView.cs
- TypeUnloadedException.cs
- TimeoutValidationAttribute.cs
- CodeParameterDeclarationExpression.cs
- BamlStream.cs
- AvtEvent.cs
- PropertyCondition.cs
- MemberExpression.cs
- AssemblyFilter.cs
- ListBox.cs
- DataGridState.cs
- QilPatternVisitor.cs
- UInt16Converter.cs
- ExpressionDumper.cs
- NameValueSectionHandler.cs
- WebPartMovingEventArgs.cs
- newinstructionaction.cs
- ResourceAttributes.cs
- WindowsSolidBrush.cs
- Compiler.cs
- NotFiniteNumberException.cs
- HexParser.cs
- ContextMarshalException.cs
- ApplicationServicesHostFactory.cs
- XamlBrushSerializer.cs
- NetDataContractSerializer.cs
- UnknownWrapper.cs
- TextRunTypographyProperties.cs
- objectresult_tresulttype.cs
- ConditionalWeakTable.cs
- HtmlElementCollection.cs
- Shape.cs
- ElapsedEventArgs.cs
- URLBuilder.cs
- ResourceDisplayNameAttribute.cs
- PtsHelper.cs
- TemplateInstanceAttribute.cs
- EntityDesignPluralizationHandler.cs
- SmtpTransport.cs
- UInt32Storage.cs
- ScaleTransform3D.cs
- CornerRadius.cs
- ExpressionVisitorHelpers.cs
- DateRangeEvent.cs
- EncodingDataItem.cs
- NonBatchDirectoryCompiler.cs
- SecurityElement.cs
- XPathChildIterator.cs
- IisTraceWebEventProvider.cs
- JsonQueryStringConverter.cs
- DataGridViewCheckBoxCell.cs
- Control.cs
- LayoutEngine.cs
- DiscoveryDocumentReference.cs
- WebPartZone.cs
- CoreSwitches.cs
- ServiceInfo.cs
- ChangeInterceptorAttribute.cs
- InstallerTypeAttribute.cs
- __Error.cs
- NavigationFailedEventArgs.cs
- PointIndependentAnimationStorage.cs
- DomainUpDown.cs
- EmptyEnumerator.cs
- EncodingDataItem.cs
- FileCodeGroup.cs