473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2155

"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
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
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
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
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
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
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
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
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
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
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.