I’m having a problem that has me going out of my mind.
Here’s what’s happening:I’m
invoking a web service (WS) from an aspx page. Then that WS calls a SAP WS that is in a different machine. The first WS is published in a virtual directory in the default web site of IIS (Windows Server 2003) with Integrated Windows Authentication. The request
gets threw to the first WS successfully and when I run debug I see that I’m authenticated when I get there. The problem is when, in the first WS, I request a new set of credentials to access the SAP WS. It gives me the following exception:
Request for the permission of type ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed
More specifically, it gives me the following exceptions in this line of code:
bapiVendorGetDetailService.Credentials =
New System.Net.NetworkCredential(username, password)
Domain - Request for the permission of type ‘System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
Password - Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
Username - Request for the permission of type ‘System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The code I use to call the first WS is this:
Dim sapWS
AsNew WSSAP.Service1 sapWS.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
Dim vendorName
AsString = sapWS.GetVendorName("0000100002")
The funny thing is that when I access the WS threw the asmx page, everything works just fine.
I don't know if what I said was confusing. I hope not because I can really use the help
By default, the "security" permission set that is applied to the internet zone does not allow calls to unmanaged code, So you need to adjust trust level of your app (and any .dlls you made with it) using .NET Framework Configuration Tool.
Try to config .Net framework permission set to "Full Access" on the Runtime Security Policy --> Machine --> Code Groups -->All_Code --> Right-click the appropriate code group and select Properties.-> Click the Permission Set tab. -> Associate FullTrust permission
set to code group from the drop-down list and click OK.</div>
Hope it helps
Best Regards
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
It didn't work. I tried to set full trust at all code groups and it also didn't work.
Something I forgot to mention was that I've already tried to run this while the caspol security was off (with the command caspol -s off) and it also didn't work.
Any more ideas? Is it possible that this is not a security problem? I find this very odd due to the nature of the exceptions.
goncalomarco...
0 Points
6 Posts
‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e...
May 09, 2008 03:53 PM|LINK
Hi,
I’m having a problem that has me going out of my mind.Here’s what’s happening: I’m invoking a web service (WS) from an aspx page. Then that WS calls a SAP WS that is in a different machine. The first WS is published in a virtual directory in the default web site of IIS (Windows Server 2003) with Integrated Windows Authentication. The request gets threw to the first WS successfully and when I run debug I see that I’m authenticated when I get there. The problem is when, in the first WS, I request a new set of credentials to access the SAP WS. It gives me the following exception:
Request for the permission of type ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
More specifically, it gives me the following exceptions in this line of code:
bapiVendorGetDetailService.Credentials = New System.Net.NetworkCredential(username, password)
Domain - Request for the permission of type ‘System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Password - Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Username - Request for the permission of type ‘System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.The code I use to call the first WS is this:
Dim sapWS As New WSSAP.Service1
sapWS.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
Dim vendorName As String = sapWS.GetVendorName("0000100002")
The funny thing is that when I access the WS threw the asmx page, everything works just fine.
I don't know if what I said was confusing. I hope not because I can really use the help
Thanks in advance
XiaoYong Dai...
All-Star
38310 Points
4229 Posts
Re: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561...
May 13, 2008 07:07 AM|LINK
Hi
<div>By default, the "security" permission set that is applied to the internet zone does not allow calls to unmanaged code, So you need to adjust trust level of your app (and any .dlls you made with it) using .NET Framework Configuration Tool.
Try to config .Net framework permission set to "Full Access" on the Runtime Security Policy --> Machine --> Code Groups -->All_Code --> Right-click the appropriate code group and select Properties.-> Click the Permission Set tab. -> Associate FullTrust permission set to code group from the drop-down list and click OK.</div>Hope it helps
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
goncalomarco...
0 Points
6 Posts
Re: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561...
May 13, 2008 09:55 AM|LINK
It didn't work. I tried to set full trust at all code groups and it also didn't work.
Something I forgot to mention was that I've already tried to run this while the caspol security was off (with the command caspol -s off) and it also didn't work.
Any more ideas? Is it possible that this is not a security problem? I find this very odd due to the nature of the exceptions.
goncalomarco...
0 Points
6 Posts
Re: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561...
May 14, 2008 03:50 PM|LINK
Got it!
I just added these lines to my web.config file and it worked.
<location allowOverride="false"> system.web> trust level="Full" originUrl="" /></
system.web></
location>tieppn
Member
2 Points
1 Post
Re: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561...
May 20, 2008 05:07 PM|LINK
Hi guys,
Everything done, but for the security is not sure.
Visit Article:
http://store.bamboosolutions.com/kb/article.aspx?id=10405firojshaikh
Member
6 Points
3 Posts
Re: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561...
Dec 24, 2009 01:26 AM|LINK
In WPF browser application follow given steps to give full trust permission
1. Select project
2. Right click and select properties.
3. Select security tab from left panel.
4. Now select/ check the radio button that says " This is full trust application"
5. Save and run application.
This will solve ur problem of permission on System.Net.WebPermission.
Microsoft Certified Application Developer (MCAD)