Showing posts with label shared. Show all posts
Showing posts with label shared. Show all posts

Monday, March 26, 2012

Permissions to run vb code

In one of my reports I’m using vb code that copies one file from a local disk to a server.

Like this:

Public Shared Function CopyFile(ByVal infile As String, ByVal outfile As String)

Dim fi As System.IO.FileInfo = New System.IO.FileInfo(infile)

fi.CopyTo(outfile, True)

End function

The report is executed using report services directly in a browser.

In the Visual Studio environment it works ok. In the browser I get an error. I’m sure it is a permissions problem.

Any pointers to set op permission for this rdl-file ?

/NHS

There is no way to elevate code permissions for a particular RDL.

Better way is to move this code into a separate assembly, grant permissions to that assembly and call it from the report.

Permissions to run vb code

In one of my reports I’m using vb code that copies one file from a local disk to a server.

Like this:

Public Shared Function CopyFile(ByVal infile As String, ByVal outfile As String)

Dim fi As System.IO.FileInfo = New System.IO.FileInfo(infile)

fi.CopyTo(outfile, True)

End function

The report is executed using report services directly in a browser.

In the Visual Studio environment it works ok. In the browser I get an error. I’m sure it is a permissions problem.

Any pointers to set op permission for this rdl-file ?

/NHS

There is no way to elevate code permissions for a particular RDL.

Better way is to move this code into a separate assembly, grant permissions to that assembly and call it from the report.

Wednesday, March 7, 2012

Permission problems: Need help with CLR credentials

Hi everyone....

I have made a CLR stored procedure which goes to a shared folder on a remote computer. I am having permission problems when executing the stored procedure. (In case anyone is wondering, I am using the .NET SYSTEM.IO class)

I have done the following:

CREATE CREDENTIAL myuser
WITH IDENTITY = 'mydomain\myuser', SECRET = 'some56*Z';

CREATE LOGIN sam WITH PASSWORD = 'meowPw!a3';

ALTER LOGIN sam WITH CREDENTIAL = myuser;

...(other SQL so that SAM can execute the SP)

Now, I login to SQL Server using the new login, and when I try to execute the CLR stored procedure, I get "unknown username or bad password.".

I know 100% for sure that the account in the "MYUSER" credential has access. Is there something else I need to do?

You need to use Impersonation so that your CLR stored proc accesses external resources as your Windows user account, rather than the account that SQL Server is running under.

You can see an example of how to do this here: http://msdn2.microsoft.com/en-us/library/ms131068.aspx

If you are already doing this and it doesn't work, post the relevant clr code you're using.

Steven