Wednesday, March 7, 2012

Custom DLL #Error Issue -Really Critical - Need your Help to Sort out the Issue

Hi MSTR Mentors,
I am in need of your Help... I am having this issue for a very long
time...Hope I will get a solution from you guys...
We have a Custom .net dll, referred in the RDL, the dll has a function
which gets the encrypted Credit Card# and returns the Decrypted value to
the Report.
I have done all the steps listed below
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.
Ref: http://support.microsoft.com/?kbid=842419#XSLTH3133121123120121120120
Step 1: I have added the following code to Assert Permission.
SecurityPermission secPerm = new SecurityPermission
(PermissionState.Unrestricted);
secPerm.Assert(); - Is this Assert Permission Correct
Step 2: Copied the assembly to the following locations
C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\
bin
&
C:\Program Files\Microsoft SQL Server\80\Tools\Report Designer
Step 3: Reference the custom assembly in the report (thru Report Properties)
Step 4: Modify the code access security for the custom assembly by creating
new permission set and code groups.
Copy the code from the security.config(C:\WINNT\Microsoft.NET\Framework\
v1.1.4322\CONFIG\) and paste it in
C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\
rssrvpolicy.config
&
C:\Program Files\Microsoft SQL Server\80\Tools\Report Designer\
rspreviewpolicy.config
PERMISSION SET
<PermissionSet class="NamedPermissionSet"
version="1"
Name="ILNReportsPermissionSet">
<IPermission class="SecurityPermission"
version="1"
Flags="Assertion, Execution"/>
</PermissionSet>
CODE GROUP
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="TESTPS"
Name="TESTCG"
Description="">
<IMembershipCondition class="UrlMembershipCondition"
version="1"
Url="file://C:/Program
Files/Microsoft SQL Server/MSSQL/Reporting
Services/ReportServer/bin/CreditCardDecrypt.dll"/>
</CodeGroup>
Save and close the files
The tried to run the report in the DebugLocal Mode - Fails ?
Dll Code: I have attached the custom assembly code.
Note: To make sure the Dll works fine in Web, I have created a sample web
application and tested the dll by passing the values to the dll function It
works fine, but not working with the RDL.
Custom DLL Code
using System;
using System.Text;
using System.Net;
using System.IO;
using System.Collections.Specialized;
using System.Configuration;
using System.Security.Permissions;
using System.Security.Cryptography;
using FCLX509 = System.Security.Cryptography.X509Certificates;
using WSEX509 = Microsoft.Web.Services2.Security.X509;
using WSECRY = Microsoft.Web.Services2.Security.Cryptography;
[assembly:CLSCompliant(true)]
namespace CreditCardDecrypt
{
/// <summary>
/// Summary description for DecryptClass.
/// </summary>
///
public class DecryptClass
{
public DecryptClass()
{
//
// TODO: Add constructor logic here
//
}
public static string DecryptCardInfo(string cc,string subjectName,string
storeName)
{
string sCreditCard = "";
try
{
if(cc == "" || cc== null)
return sCreditCard = "NA";
SecurityPermission secPerm = new SecurityPermission
(PermissionState.Unrestricted);
secPerm.Assert();
WSEX509.X509CertificateStore.StoreLocation location = WSEX509.X509CertificateStore.StoreLocation.LocalMachine;
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);
}
}
if (store != null)
store.Close();
return sCreditCard;
//return cc;
}
catch(Exception ex)
{
return ex.ToString();
}
}
}
}
Thanks
Balaji
Note : This is my email id (bkkrishnan[AT]hotmail.com).
--
Message posted via http://www.sqlmonster.comCan any one please help on this.....
Still can't able to fix the issue
Thanks
Balaji
--
Message posted via http://www.sqlmonster.com

No comments:

Post a Comment