Showing posts with label refered. Show all posts
Showing posts with label refered. Show all posts

Sunday, February 19, 2012

custom assmebly permissions (I really need help)

I try to deploy a custom assembly which access a oracle database.
I' read all post in this news group about it and also the policies refered.
I'm very confused now, becouse it is a huge amount of information and I
wonder how unspecific it is.
I need exactly to know which file I must change how and where exactly in the
file. I tried many combinations, but I have a deadline on the project an I'm
really in troubles.
In the KB Articles are CodeGroups described and also PermissionSets 3 files
to modify described too, but which file must be how modified is not described.
Please help me somebody with detailled information. It really drives me to
despair.The assembly by it self works if I remove the code for access the oracle
database.
In a article is mentoined that the code inside the assembly must be modified
too. But I don't know how to transfer this to my VB Assmebly. But this is
possibly not the only wrong thing in my project.
The purpose of the assembly is localization. And in the database still
exists a table with translations used by the application used to maintain the
data. Therefore I must access the database with the assemly.
And btw. I can not understand why the samples are for file access
permissions. How many people will store f.e. currency information in a xml
file on the server? How does the data uses by RS come usual into the
database? Posibly with existing other applications? Or does RS support data
maintainance?
"Dev Main" wrote:
> I try to deploy a custom assembly which access a oracle database.
> I' read all post in this news group about it and also the policies refered.
> I'm very confused now, becouse it is a huge amount of information and I
> wonder how unspecific it is.
> I need exactly to know which file I must change how and where exactly in the
> file. I tried many combinations, but I have a deadline on the project an I'm
> really in troubles.
> In the KB Articles are CodeGroups described and also PermissionSets 3 files
> to modify described too, but which file must be how modified is not described.
> Please help me somebody with detailled information. It really drives me to
> despair.

Friday, February 17, 2012

Custom Assembly in RDL - Need Solution - Very Urgent

Hi All,
I have a Custom .net dll, refered in the RDL, the dll has a function which
gets the encrypted CreditCard# and returns the Decrypted value to the
Report.
I have attached the code @. the end.
I have given created the permission set and code group and copied the dll
in the following location
C:\Program Files\Microsoft SQL Server\80\Tools\Report Designer\
C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\
bin\
Now when I run the report I am getting the Credit Card# decrypted shown in
the Preview window of Report Designer.....
But when I deploy the report in my report server I am getting #Error in the
CC# field.
I followed the step in the (http://support.microsoft.com/?
kbid=842419#XSLTH3133121123120121120120) to-grant permissions to a custom
assembly that is referenced in a report in Reporting Services
But there are four steps
1. Assert permissions in your custom assembly.
2. Make the custom assembly available to Report Designer and to Report
Server.
3. Reference the custom assembly in your report.
4. Modify the code access security settings for your custom assembly.
I am not sure with the STEP -1 WHAT ASSET PERMISSION IN CUSTOM ASSEMBLY TO
ADD FOR THE CRPTOGRAPY...because in the link I can see for the textfile and
SQLClinet...
I need your help on this...
Thanks in advance
Balaji.
using System;
using System.Text;
using System.IO;
using System.Collections.Specialized;
using System.Configuration;
using System.Security.Cryptography;
using FCLX509 = System.Security.Cryptography.X509Certificates;
using WSEX509 = Microsoft.Web.Services2.Security.X509;
using WSECRY = Microsoft.Web.Services2.Security.Cryptography;
namespace RDLCustomCode
{
/// <summary>
/// This class is responsible for the data decryption of the
/// user credit card information
/// </summary>
public class DataDecryptionClass
{
public DataDecryptionClass()
{
}
public static string DecryptCardInfo(string cc,string subjectName,string
storeName)
{
string sCreditCard = "";
try
{
FileStream file = new FileStream("C:\\path.txt", FileMode.OpenOrCreate,
FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
WSEX509.X509CertificateStore.StoreLocation location = WSEX509.X509CertificateStore.StoreLocation.CurrentUser;
WSEX509.X509CertificateStore.StoreProvider provider = WSEX509.X509CertificateStore.StoreProvider.System;
WSEX509.X509CertificateStore store = new WSEX509.X509CertificateStore
(provider, location, storeName);
bool fopen = store.OpenRead();
if(fopen)
{
WSEX509.X509CertificateCollection certs = store.FindCertificateBySubjectString(subjectName);
if (certs.Count > 0)
{
WSEX509.X509Certificate cer = certs[0];
WSECRY.RSACryptoServiceProvider rsaCsp = (WSECRY.RSACryptoServiceProvider)cer.Key;
byte[] cipherData = Convert.FromBase64String(cc);
byte[] plainData = rsaCsp.Decrypt(cipherData, false);
sCreditCard = Encoding.UTF8.GetString(plainData);
sw.Write(sCreditCard);
}
}
sw.Close();
file.Close();
if (store != null)
store.Close();
return sCreditCard;
//return cc;
}
catch
{
return "ErrorHandling";
}
}
--
Message posted via http://www.sqlmonster.comDid you get an error ? WHat is the error ? Did you see a .NET stack trace ?
Did you try to put the Assembly in the GAC ? There you check wheter if it is
a permission problem.
HTH, Jens Suessmeyer.
--
http://www.sqlserver2005.de
--
"BALAJI KRISHNAN via SQLMonster.com" <forum@.nospam.SQLMonster.com> schrieb
im Newsbeitrag news:22c746269e61489188230bc4b59e35df@.SQLMonster.com...
> Hi All,
> I have a Custom .net dll, refered in the RDL, the dll has a function which
> gets the encrypted CreditCard# and returns the Decrypted value to the
> Report.
> I have attached the code @. the end.
> I have given created the permission set and code group and copied the dll
> in the following location
> C:\Program Files\Microsoft SQL Server\80\Tools\Report Designer\
> C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
> Services\ReportServer\
> bin\
> Now when I run the report I am getting the Credit Card# decrypted shown in
> the Preview window of Report Designer.....
> But when I deploy the report in my report server I am getting #Error in
> the
> CC# field.
> I followed the step in the (http://support.microsoft.com/?
> kbid=842419#XSLTH3133121123120121120120) to-grant permissions to a custom
> assembly that is referenced in a report in Reporting Services
> But there are four steps
> 1. Assert permissions in your custom assembly.
> 2. Make the custom assembly available to Report Designer and to Report
> Server.
> 3. Reference the custom assembly in your report.
> 4. Modify the code access security settings for your custom assembly.
>
> I am not sure with the STEP -1 WHAT ASSET PERMISSION IN CUSTOM ASSEMBLY TO
> ADD FOR THE CRPTOGRAPY...because in the link I can see for the textfile
> and
> SQLClinet...
> I need your help on this...
> Thanks in advance
> Balaji.
>
> using System;
> using System.Text;
> using System.IO;
> using System.Collections.Specialized;
> using System.Configuration;
> using System.Security.Cryptography;
> using FCLX509 = System.Security.Cryptography.X509Certificates;
> using WSEX509 = Microsoft.Web.Services2.Security.X509;
> using WSECRY = Microsoft.Web.Services2.Security.Cryptography;
> namespace RDLCustomCode
> {
> /// <summary>
> /// This class is responsible for the data decryption of the
> /// user credit card information
> /// </summary>
> public class DataDecryptionClass
> {
> public DataDecryptionClass()
> {
> }
> public static string DecryptCardInfo(string cc,string subjectName,string
> storeName)
> {
> string sCreditCard = "";
> try
> {
> FileStream file = new FileStream("C:\\path.txt", FileMode.OpenOrCreate,
> FileAccess.Write);
> StreamWriter sw = new StreamWriter(file);
>
> WSEX509.X509CertificateStore.StoreLocation location => WSEX509.X509CertificateStore.StoreLocation.CurrentUser;
> WSEX509.X509CertificateStore.StoreProvider provider => WSEX509.X509CertificateStore.StoreProvider.System;
> WSEX509.X509CertificateStore store = new WSEX509.X509CertificateStore
> (provider, location, storeName);
> bool fopen = store.OpenRead();
> if(fopen)
> {
> WSEX509.X509CertificateCollection certs => store.FindCertificateBySubjectString(subjectName);
> if (certs.Count > 0)
> {
> WSEX509.X509Certificate cer = certs[0];
> WSECRY.RSACryptoServiceProvider rsaCsp => (WSECRY.RSACryptoServiceProvider)cer.Key;
> byte[] cipherData = Convert.FromBase64String(cc);
> byte[] plainData = rsaCsp.Decrypt(cipherData, false);
> sCreditCard = Encoding.UTF8.GetString(plainData);
> sw.Write(sCreditCard);
>
> }
> }
> sw.Close();
> file.Close();
> if (store != null)
> store.Close();
> return sCreditCard;
> //return cc;
> }
> catch
> {
> return "ErrorHandling";
> }
>
> }
> --
> Message posted via http://www.sqlmonster.com|||I ve solved similar problem a day before. See this...
Problem is: You dont ve File Permission for your assembly (dll).
Solution:
Step1: Change rrsvpolicy.config with following snippet added-
<PermissionSet
class="NamedPermissionSet"
version="1"
Name="HelloFilePermissionSet"
Description="A special permission set that grants read access to my
hello file.">
<IPermission
class="FileIOPermission"
version="1"
PathDiscovery="C:\inetpub\mailroot"
/>
<IPermission
class="SecurityPermission"
version="1"
Flags="Execution, Assertion"
/>
</PermissionSet>
Step 2: Change Dll with the following code added on class-
[FileIOPermissionAttribute(SecurityAction.Assert,
PathDiscovery="c:\\inetpub\\mailroot\\")]
public class MailSystem
{
public MailSystem()
{
}
............//rest of class.
Step 3: Change Dll with the following code added in Assemblyinfo.cs-
[assembly:AllowPartiallyTrustedCallers]
Note: Please add appropriate namespaces.
:o) It works for sure. and if this doesnt work.. mail
me(suneetmohan@.gmail.com). i'll mail ya complete code.