/// <summary> /// Deletes the current <see cref="HttpUrlReservation"/>. /// </summary> /// <exception cref="HttpUrlReservationNotFoundException">If the current <see cref="HttpUrlReservation"/> does not still exist.</exception> /// <exception cref="HttpServerException">If an internal error has been occured (use the <see cref="Win32Exception.NativeErrorCode"/> for more information).</exception> public void Delete() { HttpServer.Initialize(); try { var configInformation = new HttpServerApi.HTTP_SERVICE_CONFIG_URLACL_SET(this.url, null); var result = HttpServerApi.HttpDeleteServiceConfiguration(IntPtr.Zero, HttpServerApi.HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo, configInformation, Marshal.SizeOf(configInformation), IntPtr.Zero); if (result == Win32Error.ERROR_FILE_NOT_FOUND) { throw new HttpUrlReservationNotFoundException(result, string.Format(CultureInfo.CurrentUICulture, HttpServerResources.UrlReservationToDeleteNotFound, this.url)); } if (result != Win32Error.NO_ERROR) { throw new HttpServerException(result); } } finally { HttpServer.Terminate(); } }
/// <summary> /// Update the <see cref="HttpUrlReservationAccessRule"/> of the current <see cref="HttpUrlReservation"/>. /// </summary> /// <exception cref="HttpUrlReservationNotFoundException">If the current <see cref="HttpUrlReservation"/> does not still exist.</exception> /// <exception cref="HttpServerException">If an internal error has been occured (use the <see cref="Win32Exception.NativeErrorCode"/> for more information).</exception> private void Update() { HttpServer.Initialize(); try { var ssdl = this.GetSecurityDescriptorSddlForm(AccessControlSections.Access); var configInformation = new HttpServerApi.HTTP_SERVICE_CONFIG_URLACL_SET(this.url, ssdl); // Delete the URL reservation record var result = HttpServerApi.HttpDeleteServiceConfiguration(IntPtr.Zero, HttpServerApi.HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo, configInformation, Marshal.SizeOf(configInformation), IntPtr.Zero); if (result == Win32Error.ERROR_FILE_NOT_FOUND) { throw new HttpUrlReservationNotFoundException(result, string.Format(CultureInfo.CurrentUICulture, HttpServerResources.UrlReservationToUpdateNotFound, this.url)); } // Add the URL reservation record with the new SDDL. result = HttpServerApi.HttpSetServiceConfiguration(IntPtr.Zero, HttpServerApi.HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo, configInformation, Marshal.SizeOf(configInformation), IntPtr.Zero); if (result != Win32Error.NO_ERROR) { throw new HttpServerException(result); } } finally { HttpServer.Terminate(); } }