Showing posts with label similar. Show all posts
Showing posts with label similar. Show all posts

Wednesday, February 15, 2012

Error Accessing the Registry in Custom Code

I have created a custom code module that is attempting to read a registry key value using code similar to the following...

Dim regKey As Microsoft.Win32.RegistryKey
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\OurCompany\Group\ReportServers")

This consistently fails. I note in the event viewer a Failure Audit with the following...

Date: xx/xx/xxxx

Time: xx:xx:xx xx

Type: Failure Aud[it]

User: NT AUTHORITY\SYSTEM

Computer: RSComputerName

Source: Security

Category: Object Access

Event ID: 560

Description:

Object Open:

Object Server: Security

Object Type: Key

Object Name: \REGISTRY\USER\.DEFAULT

Handle ID: -

Operation ID: {0,66061313}

Process ID: 1164

Image File Name: C:\WINDOWS\system32\svchost.exe

Primary User Name: MyComputerName$

Primary Domain: MyDomain

Primary Logon ID: (0x0,0x3E7)

Client User Name: MyComputerName$

Client Domain: MyDomain

Client Logon ID: (0x0,0x3E7)

Accesses: MAX_ALLOWED

Privileges: -

Restricted Sid Count: 0

Access Mask: 0x2000000

I've tried granting a bunch of permissions to SYSTEM and Everyone to HKLM subkeys, to no avail. Any thoughts on what I can do to fix the problem?

Thanks in advance.

Keith Spitz

Wall Street On Demand, Inc.

This is because the VB code in report expressions is not trusted and accessing registry requires special code permissions. The standard way is to move the code that reads registry into a custom assembly, grant that assembly required code permissions (rssrvpolicy.config), assert those permissions inside the assembly and call that assembly from your report.

http://support.microsoft.com/default.aspx?scid=kb;en-us;842419

|||

Thanks -- that was the info I needed.

However, having never created a custom assembly before, it took a little work to get the job done. I found a good tutorial at http://www.c-sharpcorner.com/Code/2005/June/CustomAssemblyinRS.asp.

Keith Spitz, Wall Street On Demand, Inc.

Error Accessing Server Report from VS2005

I've tried 2,505,767 things to get this to work and still can't. I
imagine there are others having a similar issue.
Get the following unhandled IOE from Visual Studio using a ReportViewer
control on a Server Report:
Client found response content type of '', but expected 'text/xml', The
request failed with an empty response.
Doesn't matter if there are parameters to the report or not. If I nav
to the URL of the report it works fine.Apparently, there's a security issue with a server report deploying
anywhere other than the Home \\server\ReportServer folder... Microsoft
is looking into this.|||Do you have any MSDN or other Microsoft URL's about this issue? We're
experiencing the same thing, but moving the report to our home folder
didn't fix it for us. Thanks|||After discussion with Microsoft, apparently, the ReportView control
declaration needs to be specific. The reporting service project I had
contained multiple reports. Upon deploying one of them, a folder is
made for the project, and the report is placed in there. The following
corrected the problem.
Choose Report: <ServerReport>
Report Server URL: http://<servername>/ReportServer
Report Path: /<project>/<reportname>
The slashes and positioning of the paths is vital for this to work
correctly. Hope this helps!