Hi Shawn !
Thanks for your reply. The version of my clr is 1.1.4322.573.
If I use Demand instead of RequestMinimum, my code compiles. But if I add
assembly:, there is no way to compile.
Now, with that attribute, I can access the registry key only with my domain
user. I used regedt32 to give access rights to a local user of the machine
(it's a user that I created to use with impersonation from my web app). But
even if I give full control access to the registry key, my request is
refused. Do you have any ideas how I could do this ?
Thanks for your reply
Marc
""Shawn Farkas"" <shawnfa@online.microsoft.com> a écrit dans le message de
news:MicfNkwhEHA.304@cpmsftngxa10.phx.gbl...
[quoted text, click to view] > Hi Marc,
>
> The problem seems to be that you're emitting assembly-level declarative
security onto a method. RequestMinimum can only be done on
> a per-assembly basis, so if you add an assembly: qualifier to your
attribute, then you should be able to compile the code. As an aside -- what
> version of the CLR are you seeing this behavior on?
>
> -Shawn
>
http://blogs.msdn.com/shawnfa >
> --
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
> originated.
> --------------------
> >From: "Marc Wuergler" <marc_wurgler@hotmail.com>
> >Subject: Access to remote registry (RegistryPermissionAttribute)
> >Date: Fri, 20 Aug 2004 15:20:32 +0200
> >Lines: 38
> >X-Priority: 3
> >X-MSMail-Priority: Normal
> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
> >Message-ID: <OqKV7hrhEHA.712@tk2msftngp13.phx.gbl>
> >Newsgroups: microsoft.public.dotnet.security
> >NNTP-Posting-Host: mail.infoteam.ch 193.192.226.200
> >Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
..phx.gbl
[quoted text, click to view] > >Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.security:7185
> >X-Tomcat-NG: microsoft.public.dotnet.security
> >
> >Hi !
> >
> >I'm trying to access a registry key on a remote computer.
> >
> >Here is my code :
> >
> >[RegistryPermissionAttribute(SecurityAction.RequestMinimum, Read =
> >@"HKEY_LOCAL_MACHINE\SOFTWARE\MyKey")]
> >public static string ReadRegistryKey(string PsMachineName)
> >{
> > try
> > {
> > RegistryKey LoKey =
> >RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, PsMachineName);
> > RegistryKey LoSubKey = LoKey.OpenSubKey(@"SOFTWARE\MyKey");
> > string LsValue = LoSubKey.GetValue("InstallFolder").ToString();
> >
> > return LsValue;
> > }
> > catch(Exception e)
> > {
> > return e.Message;
> > }
> >}
> >
> >This code does not compile !!!
> >
> >Error : Error emitting
> >'System.Security.Permissions.RegistryPermissionAttribute' attribute --
> >'Common Language Runtime Internal error: 0x8013143e'
> >
> >
> >Could anyone tell me what I'm doing wrong or how I can fix this !? Thanks
a
> >lot.
> >
> >Marc
> >
> >
> >
>
>