tentavarious
asked on
Getting permissions error when using a embedded window user control in web page
I created a windows usercontrol that works fine when i use it with windows application, but when I try to embed it within a web page i get this error: Request for the permission of type 'System.Data.OracleClient. OraclePerm ission, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral,. All the controls show up fine but when i click the button to bind the dataset to the datagrid the error happens
private void button1_Click(object sender, System.EventArgs e)
{
this.textBox1.Text = "test";
DataSet ds = new DataSet();
System.Data.OracleClient.OracleConnection oracle_conn;
System.Data.OracleClient.OracleDataAdapter orad;
string ssql = null;
try
{
oracle_conn = new OracleConnection("Data Source=databasename; User ID=xxx; Password=xxxxx;");
ssql = "select * from emp_test_number";
orad = new OracleDataAdapter(ssql, oracle_conn);
orad.Fill(ds);
this.dataGrid1.DataSource = ds;
}
catch (Exception ex)
{
textBox1.Text = ex.Message;
}
finally
{
//Request for the permission of type 'System.Data.OracleClient.OraclePermission, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral,
}
}
When a Windows application runs on a local machine, the default is to run the Local zone with Full Trust. Web applications run in a partially trusted environment. What line are you getting that exception on? Do you have the full stack trace for the exception?
ASKER
How do i get the full stack trace? The code I showed you above, gets executed within a windows user control via my web page. The only error I display comes from the exception message. How do I show the full stack trace?
I changed this line of code textBox1.Text = ex.Message;
to this textBox1.Text = ex.ToString();
System.Security.SecurityEx ception: Request for the permission of type 'System.Data.OracleClient. OraclePerm ission, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193 4e089' failed.
at System.Security.CodeAccess SecurityEn gine.Check (Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
I changed this line of code textBox1.Text = ex.Message;
to this textBox1.Text = ex.ToString();
System.Security.SecurityEx
at System.Security.CodeAccess
i think that you are using oracle 8 or higher as your database and when you connect to the database using the windows application you are permitted to do that because the application runs under the credientials of the logged in user but for a web site the permissions are hightly restrictive
while serarching on the net i stumbled wpon the fhe following it might be helpful to you
System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
Problem
When usign System.Data.OracleClient with Oracle9i client, i got the following message while connecting to the Oracle database from and ASP.NET application.
System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
Cause
Security permissions were not properly set when the Oracle 9i Release 2 client was installed on Windows with NTFS. The result of this is that content of the ORACLE_HOME directory is not visible to Authenticated Users on the machine; this again causes an error while the System.Data.OracleClient is communicating with the Oracle Connectivity software from an ASP.NET using Authenticated User privileges.
Solution
To fix the problem you have to give the Authenticated Users group privilege to the Oracle Home directory.
while serarching on the net i stumbled wpon the fhe following it might be helpful to you
System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
Problem
When usign System.Data.OracleClient with Oracle9i client, i got the following message while connecting to the Oracle database from and ASP.NET application.
System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
Cause
Security permissions were not properly set when the Oracle 9i Release 2 client was installed on Windows with NTFS. The result of this is that content of the ORACLE_HOME directory is not visible to Authenticated Users on the machine; this again causes an error while the System.Data.OracleClient is communicating with the Oracle Connectivity software from an ASP.NET using Authenticated User privileges.
Solution
To fix the problem you have to give the Authenticated Users group privilege to the Oracle Home directory.
- Log on to Windwos as a user with Administrator privileges.
- Start Window Explorer and navigate to the ORACLE_HOME folder.
- Choose properties on the ORACLE_HOME folder.
- Click the Security tab of the Properties window.
- Click on Authenticated Users item in the Name list.
- Uncheck the Read and Execute box in the Permissions list under the Allow column.
- Re-check the Read and Execute box under the Allow column
- Click the Advanced button and in the Permission Entries verify that Authenticated Users are listed with permission = Read & Execute, and Apply To = This folder, subfolders and files. If not, edit that line and make sure that Apply To drop-down box is set to This folder, subfolders and files. This should already be set properly but it is important that you verify it.
- Click the Ok button until you close out all of the security properties windows. The cursor may present the hour glass for a few seconds as it applies the permissions you just changed to all subfolders and files.
- Reboot, to assure that the changes have taken effect.
ASKER
Ok, I did everything you listed and still doesnt work. I added a Everyone group and get the same responsibilities and no go on that.
The weird thing is, when I embed the user control within another windows form it works, but when I try to embed it, within a web page that is running on my computer the error shows up. The folder should be open to everyone now, so i am not sure what is going on.
The weird thing is, when I embed the user control within another windows form it works, but when I try to embed it, within a web page that is running on my computer the error shows up. The folder should be open to everyone now, so i am not sure what is going on.
there might be something which i might have missed out and if you google for the same problem on google you might find some more answers
What is the implication for the possibility of using Windows authentication with your web site?
ASKER
I thought i was using Windows Authentication
Web.config
<authentication mode="Windows" />
Is there a setting I am missing in IIS?
Another thing, what I am trying to do will work if I remove the ActiveX control and use a web datagrid, I don't get any permission issues when I do it that way on my web page. I am testing the capabilities of using Active X controls on my webpage, I dont see why it should be any different then just binding a the same data to an asp.net datagrid.
Web.config
<authentication mode="Windows" />
Is there a setting I am missing in IIS?
Another thing, what I am trying to do will work if I remove the ActiveX control and use a web datagrid, I don't get any permission issues when I do it that way on my web page. I am testing the capabilities of using Active X controls on my webpage, I dont see why it should be any different then just binding a the same data to an asp.net datagrid.
IIS Authentication Methods dialog:
Uncheck "Allow Anonymous"
Check "Integrated Windows authentication"
IIS-Authentication-Methods.png
Uncheck "Allow Anonymous"
Check "Integrated Windows authentication"
IIS-Authentication-Methods.png
ASKER
Yeah, i tried that same error
Is this an Intranet or Internet web site? If you have internal users, then you might be able to adjust the Zone security for the Intranet zone to Full Trust.
ASKER
This is intranet, for now I am still in debug testing within my localhost.
ASKER
Here is the full error
System.Security.SecurityEx ception: Request for the permission of type 'System.Data.OracleClient. OraclePerm ission, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193 4e089' failed.
at System.Security.CodeAccess SecurityEn gine.Check (Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.Permission Set.Demand ()
at System.Data.Common.DbConne ctionOptio ns.DemandP ermission( )
at System.Data.OracleClient.O racleConne ction.Perm issionDema nd()
at System.Data.OracleClient.O racleConne ctionFacto ry.Permiss ionDemand( DbConnecti on outerConnection)
at System.Data.ProviderBase.D bConnectio nClosed.Op enConnecti on(DbConne ction outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OracleClient.O racleConne ction.Open ()
at System.Data.Common.DbDataA dapter.Qui etOpen(IDb Connection connection, ConnectionState& originalState)
at System.Data.Common.DbDataA dapter.Fil lInternal( DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataA dapter.Fil l(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataA dapter.Fil l(DataSet dataSet)
at WinControls.WinTreeview.bu tton1_Clic k(Object sender, EventArgs e)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.OracleClient.O raclePermi ssion
The Zone of the assembly that failed was:
Intranet
System.Security.SecurityEx
at System.Security.CodeAccess
at System.Security.Permission
at System.Data.Common.DbConne
at System.Data.OracleClient.O
at System.Data.OracleClient.O
at System.Data.ProviderBase.D
at System.Data.OracleClient.O
at System.Data.Common.DbDataA
at System.Data.Common.DbDataA
at System.Data.Common.DbDataA
at System.Data.Common.DbDataA
at WinControls.WinTreeview.bu
The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.OracleClient.O
The Zone of the assembly that failed was:
Intranet
is this link of any help
http://www.windows-tech.info/15/c4c5fd72744ba332.php
http://www.windows-tech.info/15/c4c5fd72744ba332.php
ASKER
I believe that is something similiar to what i tried, I found this link http://support.microsoft.com/default.aspx?scid=kb;en-us;315682
Which explains how to generate a snk key and add the dll to the GAC. I went through the page and everything went through. I check c:\windows\assembly and my dll was there, but now when i open my page the control doesnt show up, just a blank page with a icon.
webpage.gif
Which explains how to generate a snk key and add the dll to the GAC. I went through the page and everything went through. I check c:\windows\assembly and my dll was there, but now when i open my page the control doesnt show up, just a blank page with a icon.
webpage.gif
ASKER
If i remove the key from the assembly and unistall the control shows up, but i get the same error
ASKER
ragi007, those links seem to pertain to sql does oracle have the same Cas policy?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried using oledb instead of oracle and got a simliar error dealing with Oledb instead of oracle, so I think its something on my machine and doesnt have anything to do with the database.
ASKER
Oh man, thank you so much, that did it. Been beating my head up against a wall for a couple days now, go figure it should be that simple.