473,500 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SecurityException

I'm trying to run a modified version of the example in this Microsoft
article:
http://msdn.microsoft.com/library/de...sekeytopic.asp

The only changes I've made to the code is that instead of using
"HKEY_CURRENT_USER\Environment" as my registry path I'm using
"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Wi ndows" and setting
OpenRemoteBaseKey to open RegistryHive.LocalMachine instead of the
CurrentUser.

The problem is that I keep getting a SecurityException. I've tried inserting
the code below inside the try block but with no apparent effect

// ****************************

SecurityPermission sp =

new SecurityPermission(SecurityPermissionFlag.Unmanage dCode);

sp.Demand();

// ****************************

Anybody got a clue what's wrong and what I can do to fix it?
Sep 21 '06 #1
2 2160

"Chuck B" <ch****@shc1.comwrote in message
news:e$**************@TK2MSFTNGP02.phx.gbl...
| I'm trying to run a modified version of the example in this Microsoft
| article:
|
http://msdn.microsoft.com/library/de...sekeytopic.asp
|
| The only changes I've made to the code is that instead of using
| "HKEY_CURRENT_USER\Environment" as my registry path I'm using
| "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Wi ndows" and setting
| OpenRemoteBaseKey to open RegistryHive.LocalMachine instead of the
| CurrentUser.
|
| The problem is that I keep getting a SecurityException. I've tried
inserting
| the code below inside the try block but with no apparent effect
|
| // ****************************
|
| SecurityPermission sp =
|
| new SecurityPermission(SecurityPermissionFlag.Unmanage dCode);
|
| sp.Demand();
|
| // ****************************
|
| Anybody got a clue what's wrong and what I can do to fix it?
|
|

Your problem is windows security related not CAS rlated.
You must run your code while impersonating a "remote system" administrator,
only administrators can access HKLM.

Willy.

Sep 21 '06 #2

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uc**************@TK2MSFTNGP05.phx.gbl...
>
"Chuck B" <ch****@shc1.comwrote in message
news:e$**************@TK2MSFTNGP02.phx.gbl...
| I'm trying to run a modified version of the example in this Microsoft
| article:
|
http://msdn.microsoft.com/library/de...sekeytopic.asp
|
| The only changes I've made to the code is that instead of using
| "HKEY_CURRENT_USER\Environment" as my registry path I'm using
| "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Wi ndows" and setting
| OpenRemoteBaseKey to open RegistryHive.LocalMachine instead of the
| CurrentUser.
|
| The problem is that I keep getting a SecurityException. I've tried
inserting
| the code below inside the try block but with no apparent effect
|
| // ****************************
|
| SecurityPermission sp =
|
| new SecurityPermission(SecurityPermissionFlag.Unmanage dCode);
|
| sp.Demand();
|
| // ****************************
|
| Anybody got a clue what's wrong and what I can do to fix it?
|
|

Your problem is windows security related not CAS rlated.
You must run your code while impersonating a "remote system"
administrator,
only administrators can access HKLM.

Willy.
Ok thanks. Does it make any difference that I set myself as a user with
control permissions on every key in the path that I'm trying to access?
Sep 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6467
by: Mark Rodrigues | last post by:
Hi everyone, Today we hit a problem when we rolled a new web-site are were presented with a error on our page that looked like: Security Exception Description: The application attempted to...
0
1420
by: | last post by:
I have been learning really hard to understand this .NET security thing, but I still get overwhelmed with the abstractness. The hardest part is to understand *when* you get an SecurityException and...
1
6758
by: Sam | last post by:
I have a desktop VB.Net application I developed locally. I uploaded it to a file server we have and the .Net Framework is installed on the file server. When I try to run the executable from the...
0
3327
by: James B | last post by:
OMA (Outlook Mobile Access) under Exchange is giving me a System.Security.SecurityException error. From what I gather this is a problem with the security level under which the OMA application is...
0
1529
by: Brian A | last post by:
I have code that calls some Win32 code. My library is accessed via remoting from a client. In version 1.0 of the framework I had no problems. With 1.1 I consitently get the securityException: ...
2
3140
by: MFRASER | last post by:
I am getting a System.Security.SecurityException when I try and laod a dataset from an xml file any ideas on what would cause this? System.Security.SecurityException' occurred in mscorlib.dll ...
2
4199
by: jwgoerlich | last post by:
I wrote a simple VB.Net console application. It accepts command line parameters and creates a folder structure. It works on the local file system without a problem If I run the console app from...
0
822
by: Mythran | last post by:
Class1: <PrincipalPermission(SecurityAction.Demand, Role := "MyRole")> _ Public Function Fetch() As DataTable End Function Class2: Public Function Fetch() As DataTable Dim cls1 As Class1 =...
0
961
by: Michael | last post by:
Re: system.security.securityexception The program I have written requires "Full Trust" to run and will throw a security exception if a user tries to load it while working in the Intranet...
4
9062
by: stephen | last post by:
Hi, I am getting an error while trying to create an excel file. "Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.