Apologies if I've posted this in the wrong forum but I didn't know where else to post...
Ok, here's the scenario:
I have an application with two buttons, one of which I want to log the user off. The problem is that this runs as a startup program and runs off a network share. The app works fine on my local machine but whenever I try to run it from a network share, I
get security privilege errors:
Application attempted to perform an operation not allowed by the security policy... Request for the permission of type "System.Security.Permission, mscorlib, Version 2.0.0.0, Culture=neutral, PublicKey Token=b77a5c561934e089
Then I can continue or quit. How can I stop this error message box coming up?
If I go to the command line of the machine that I'm trying to run the app on and go to the .NET directory and run CasPol.exe -s off, it will then work. How can I get it to work everytime? I have tried:
Shell("CasPol -s off")
The other problem is that the machines I'm running the app on may have different .NET versions installed and in different places...
Here's my code:
Private Sub btDisagree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDisagree.Click
'Shell("CasPol -s off")
Shell("shutdown -l")
End Sub
End Class
The strange thing is that I have another app with the identical call (Shell("shutdown -l")) and it runs perfectly. There must be something I'm missing. if anyone can help me I'd be very grateful!!!
Failing this, can anyone tell me how to log off a user through a windows form without incurring security issues?
The problem is that this runs as a startup program and runs off a network share. The app works fine on my local machine but whenever I try to run it from a network share, I get security privilege errors:
Application attempted to perform an operation not allowed by the security policy... Request for the permission of type "System.Security.Permission, mscorlib, Version 2.0.0.0, Culture=neutral, PublicKey Token=b77a5c561934e089
Hi
What happens in your code is the application attempted to perform an operation (execute external programme) not allowed by the security policy. For testing purposes you can try to add this line in your web.config if host admin doesn't lock the trust level
section.
If it's a share host, you probably need to discuss with your hosting provider and get some restrictions on what you can and cannot do. For security reasons, Most share host will restrict execute extrnol programme.
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.
I have a related post at http://forums.asp.net/t/1207364.aspx. It's extremely strange that in testing the application, one entry would be accepted and others would not.
freelandera
Member
34 Points
56 Posts
Application attempted to perform an operation not allowed by the security policy
Dec 10, 2007 04:47 PM|LINK
Apologies if I've posted this in the wrong forum but I didn't know where else to post...
Ok, here's the scenario:
I have an application with two buttons, one of which I want to log the user off. The problem is that this runs as a startup program and runs off a network share. The app works fine on my local machine but whenever I try to run it from a network share, I get security privilege errors:
Application attempted to perform an operation not allowed by the security policy... Request for the permission of type "System.Security.Permission, mscorlib, Version 2.0.0.0, Culture=neutral, PublicKey Token=b77a5c561934e089
Then I can continue or quit. How can I stop this error message box coming up?
If I go to the command line of the machine that I'm trying to run the app on and go to the .NET directory and run CasPol.exe -s off, it will then work. How can I get it to work everytime? I have tried:
Shell("CasPol -s off")
The other problem is that the machines I'm running the app on may have different .NET versions installed and in different places...
Here's my code:
Private Sub btDisagree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDisagree.Click 'Shell("CasPol -s off") Shell("shutdown -l")End Sub End ClassThe strange thing is that I have another app with the identical call (Shell("shutdown -l")) and it runs perfectly. There must be something I'm missing. if anyone can help me I'd be very grateful!!!
Failing this, can anyone tell me how to log off a user through a windows form without incurring security issues?
Thanks in advance,
security shutdown network share log off policy
freelandera
Member
34 Points
56 Posts
Re: Application attempted to perform an operation not allowed by the security policy
Dec 11, 2007 07:35 AM|LINK
Does anyone have any ideas?
XiaoYong Dai...
All-Star
38310 Points
4229 Posts
Re: Application attempted to perform an operation not allowed by the security policy
Dec 12, 2007 09:40 AM|LINK
Hi
What happens in your code is the application attempted to perform an operation (execute external programme) not allowed by the security policy. For testing purposes you can try to add this line in your web.config if host admin doesn't lock the trust level section.
<system.web>
<trust level="Full" originUrl="" />
</system.web>
A more prosaic approach is looking into the call stack and using the custom permission set for security policy.
Here you can get more information
http://msdn2.microsoft.com/en-us/library/tkscy493(VS.80).aspx
If it's a share host, you probably need to discuss with your hosting provider and get some restrictions on what you can and cannot do. For security reasons, Most share host will restrict execute extrnol programme.
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.
muybn
Participant
853 Points
1290 Posts
Re: Application attempted to perform an operation not allowed by the security policy
Jan 19, 2008 06:32 AM|LINK
I have a related post at http://forums.asp.net/t/1207364.aspx. It's extremely strange that in testing the application, one entry would be accepted and others would not.
muybn
Participant
853 Points
1290 Posts
Re: Application attempted to perform an operation not allowed by the security policy
Jan 20, 2008 05:52 AM|LINK
I seemed to have resolved it by changing the Trust Level to "Full" in web.config:
<
trust level="Full"/>It still puzzles me as to why the application would accept one set of input and not another.