Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / WsatServiceAddress.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BooleanExpr.cs
- TransformedBitmap.cs
- KnownBoxes.cs
- AttachedPropertyBrowsableAttribute.cs
- ValidatorAttribute.cs
- COM2PropertyPageUITypeConverter.cs
- MenuCommandService.cs
- CounterSetInstance.cs
- thaishape.cs
- RepeaterItemEventArgs.cs
- HttpHandlerAction.cs
- EnvironmentPermission.cs
- AutoGeneratedField.cs
- NeedSkipTokenVisitor.cs
- DataListItem.cs
- LayoutEvent.cs
- FigureParaClient.cs
- MetaModel.cs
- PassportPrincipal.cs
- ButtonField.cs
- RotateTransform3D.cs
- ManipulationBoundaryFeedbackEventArgs.cs
- InkPresenter.cs
- formatstringdialog.cs
- ElementNotEnabledException.cs
- GroupItem.cs
- MiniAssembly.cs
- COM2PropertyBuilderUITypeEditor.cs
- __FastResourceComparer.cs
- ListenerConstants.cs
- JournalNavigationScope.cs
- WebMessageEncodingElement.cs
- HttpBrowserCapabilitiesWrapper.cs
- SafeUserTokenHandle.cs
- ColorDialog.cs
- Matrix.cs
- XmlDocumentFragment.cs
- LoadedOrUnloadedOperation.cs
- SecurityTokenReferenceStyle.cs
- ClientType.cs
- SchemaElementLookUpTableEnumerator.cs
- _Connection.cs
- BitArray.cs
- XmlWrappingReader.cs
- GZipDecoder.cs
- MaskedTextBoxTextEditorDropDown.cs
- WpfPayload.cs
- SignatureToken.cs
- ScriptComponentDescriptor.cs
- PerCallInstanceContextProvider.cs
- DefaultMergeHelper.cs
- RangeValueProviderWrapper.cs
- CallbackException.cs
- Publisher.cs
- GeometryValueSerializer.cs
- OutputCacheProfile.cs
- ErrorFormatter.cs
- NamespaceQuery.cs
- Constants.cs
- PresentationUIStyleResources.cs
- DefaultTextStoreTextComposition.cs
- DataBindingExpressionBuilder.cs
- MailFileEditor.cs
- SqlIdentifier.cs
- TogglePatternIdentifiers.cs
- CapabilitiesUse.cs
- XmlDictionary.cs
- XPathChildIterator.cs
- DomNameTable.cs
- UnsafeNativeMethods.cs
- HyperLinkField.cs
- BamlLocalizableResourceKey.cs
- ExpressionBuilder.cs
- Run.cs
- OdbcErrorCollection.cs
- DynamicValidator.cs
- MessageQueueAccessControlEntry.cs
- SourceItem.cs
- ComboBoxItem.cs
- ComponentDispatcherThread.cs
- FormViewCommandEventArgs.cs
- TextRangeEdit.cs
- OdbcConnectionOpen.cs
- WebControl.cs
- TogglePattern.cs
- OracleFactory.cs
- ipaddressinformationcollection.cs
- UrlAuthorizationModule.cs
- LoadedOrUnloadedOperation.cs
- SchemaTypeEmitter.cs
- OrderedHashRepartitionStream.cs
- ServerValidateEventArgs.cs
- UInt32Storage.cs
- CharacterShapingProperties.cs
- bindurihelper.cs
- ALinqExpressionVisitor.cs
- BitmapImage.cs
- EmissiveMaterial.cs
- ASCIIEncoding.cs
- ViewBase.cs