Using custom code on report services to check if directory does exist or not (need help)
I am trying to check if a directory does exist.
I have used the vb.net to create a very small function and embedded into the "Custom code:" section of Report Properties.
It’s output is a return of Y or N (string) or 1 or 0 (Integer) if directory exist or not.
Here is the code which returns a String
Function ifDirExist(ByVal mypath As String) As String
Dim flag As String
If Not System.IO.Directory.Exists(mypath) Then
flag = "N"
Else
flag = "Y"
End If
Return flag
End Function
I have used this code =Code.ifDirExist("C:/temp") under Expression of the field.
The code does work but the result is always "N" or 0 (false).
Thank you very much for any info and input.
-IA
p.s. I have also tried to use custom assembly and it also does return 0 or false at all the time. I just want to check to see if a directory exist or
not, is there something that I can do to fix this.
October 4th, 2010 8:54pm
Hi,
Reporting Services leverages the Code Access Security (CAS) infrastructure to prevent malicious code from performing unauthorized actions. The custom code doesn’t work because
the permission of custom code is insufficient. To elevate the permission of custom code, please refer to the steps below:
1.
Back up and open the Report Server security configuration file
rssrvpolicy.config. You can find it at
<InstallDrive>:\Program Files\Microsoft SQL Server\MSRS10.<InstanceName>\Reporting Services\ReportServer
2.
Navigate to the node <CodeGroup> which
class attribute is “UnionCodeGroup”. Then replace the
PermissionSetName attribute from “Execute” to “FullTrust”.
3.
Navigate to the next <CodeGroup> node which class attribute is “FirstMatchCodeGroup”. Also replace the
PermissionSetName attribute from “Execute” to “FullTrust”.
4.
Save the configure file.
To preview the custom code in Business Intelligence Studio, you also need make the same changes in the Report Designer security configuration file. This file is stored at
<InstallDrive>:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies
For more information about Development Security in Reporting Services, please see:
http://msdn.microsoft.com/en-us/library/bb522723(v=SQL.100).aspx
Thanks,
Tony ChainTony Chain
Free Windows Admin Tool Kit Click here and download it now
October 6th, 2010 12:25pm
Thank you so very much for your info.
October 6th, 2010 9:25pm