11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9: Using Code Access <strong>Security</strong> with ASP.NET 251 To create a custom policy to allow registry access1. Copy the <strong>Web</strong>_mediumtrust.config file, which is in the following directory, to afile called <strong>Web</strong>_mediumtrust_Registry.config, which is located in the samedirectory.%windir%\Microsoft.NET\Framework\{version}\CONFIGBy making a copy <strong>and</strong> creating a custom policy file, you avoid making changesdirectly to the <strong>Web</strong>_mediumtrust.config file. Making changes directly to thedefault medium trust file affects every application on the machine that isconfigured for medium trust.2. Locate the element <strong>and</strong> add the following to register theRegistryPermission class:3. Locate the ASP.NET permission set <strong>and</strong> add the unrestricted RegistryPermissionto the permission set as follows:4. Save the file.5. Update Machine.config to create a new trust level that is mapped to the newpolicy file.6. Update your application’s <strong>Web</strong>.config to configure the application’s level.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!