Re: "Requested registry access is not allowed" and Web Service call

From: Nicole Calinoiu (calinoiu)
Date: 12/14/04


Date: Tue, 14 Dec 2004 13:48:23 -0500

Clint,

Take a look at the following key in your machine.config file:
configuration\system.net\defaultProxy\proxy. It is most likely set to use
the system default proxy. If this is the case, the proxy settings will be
read out of the following registry key:
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet
Settings\Connections.

When you impersonate, the HKCU hive will not be populated with the data for
the impersonated user. Instead, the hive remains as previously populated
for the logged on user. In your case, the impersonated user would appear
not to have permissions to read the necessary subkey from HKCU.

You should not need to modify your machine.config file in order to work
around the problem. Instead, you should be able to override the
defaultProxy setting via your application's config file.

HTH,
Nicole

"Clint" <cjmueller@gmail.com> wrote in message
news:1102953917.270017.245280@c13g2000cwb.googlegroups.com...
> Hey all -
>
> I'm having a really confusing problem concerning a web service. Right
> now, I have an application that needs to call a web service that does
> nothing but return "true" (this will obviously change once the
> program's fully built to actually do something, but for testing, it
> works).
>
> The only code I added to the service is below:
> [WebMethod (EnableSession=true)]
> public bool PerformHandshake(string hashedValue)
> {
> return true;
> }
>
> Whenever this method is called from my desktop app (running as me, a
> local admin), it works fine. When I call the web service as a
> restricted account (by impersonating using
> System.Security.Principal.WindowsIdentity.Impersonate()), I get the
> following large exception:
>
> General Information
> *****
> Additional Info:
> ExceptionManager.MachineName: <<My machine name>>
> ExceptionManager.TimeStamp: 12/13/2004 9:44:23 AM
> ExceptionManager.FullName:
> Microsoft.ApplicationBlocks.ExceptionManagement,
> Version=1.0.1760.29811, Culture=neutral, PublicKeyToken=null
> ExceptionManager.AppDomainName: Journals.exe
> ExceptionManager.ThreadIdentity:
> ExceptionManager.WindowsIdentity: <<correct domain\correct user
> account>>
>
> 1) Exception Information
> *****
> Exception Type: System.Configuration.ConfigurationException
> Message: Exception in configuration section handler
> (c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config
> line 74)
> BareMessage: Exception in configuration section handler
> Filename:
> c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config
> Line: 74
> TargetSite: System.Object
> EvaluateRecursive(System.Configuration.IConfigurationSectionHandler,
> System.Object, System.String[], Int32, System.Xml.XmlTextReader)
> HelpLink: NULL
> Source: System
>
> StackTrace Information
> *****
> at
> System.Configuration.ConfigurationRecord.EvaluateRecursive(IConfigurationSectionHandler
> factory, Object config, String[] keys, Int32 iKey, XmlTextReader
> reader)
> at
> System.Configuration.ConfigurationRecord.EvaluateRecursive(IConfigurationSectionHandler
> factory, Object config, String[] keys, Int32 iKey, XmlTextReader
> reader)
> at System.Configuration.ConfigurationRecord.Evaluate(String
> configKey)
> at System.Configuration.ConfigurationRecord.ResolveConfig(String
> configKey)
> at System.Configuration.ConfigurationRecord.GetConfig(String
> configKey)
> at System.Configuration.ConfigurationRecord.ResolveConfig(String
> configKey)
> at System.Configuration.ConfigurationRecord.GetConfig(String
> configKey)
> at
> System.Configuration.DefaultConfigurationSystem.System.Configuration.IConfigurationSystem.GetConfig(String
> configKey)
> at System.Configuration.ConfigurationSettings.GetConfig(String
> sectionName)
> at System.Net.GlobalProxySelection.get_SelectInternal()
> at System.Net.HttpWebRequest..ctor(Uri uri)
> at System.Net.HttpRequestCreator.Create(Uri Uri)
> at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
> at System.Net.WebRequest.Create(Uri requestUri)
> at System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri
> uri)
> at
> System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri
> uri)
> at
> System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri
> uri)
> at
> System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
> methodName, Object[] parameters)
> at Journals.BAL.<svr>.FSConnect.PerformHandshake(String hashedValue)
> in C:\Visual Studio Projects\C# Projects\Journal Automation
> System\Journals.BAL\Web References\<svr>\Reference.cs:line 38
> at Journals.BAL.Posting.PostJournalSet(Int32 JournalSet_ID, String
> NewOwnerUserName, String Comment) in c:\visual studio projects\c#
> projects\journal automation system\journals.bal2\posting.cs:line 298
> at Journals.Common.Posting.transfer_TransferOk(Object sender,
> TransferOkEventArgs e) in c:\visual studio projects\c# projects\journal
> automation system\journals\common\posting.cs:line 174
> at Journals.frmTransferOwnership.OnTransferOk(TransferOkEventArgs e)
> in c:\visual studio projects\c# projects\journal automation
> system\journals\forms\frmtransferownership.cs:line 46
> at Journals.frmTransferOwnership.btnSend_Click(Object sender,
> EventArgs e) in c:\visual studio projects\c# projects\journal
> automation system\journals\forms\frmtransferownership.cs:line 276
> at System.Windows.Forms.Control.OnClick(EventArgs e)
> at System.Windows.Forms.Button.OnClick(EventArgs e)
> at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> button, Int32 clicks)
> at System.Windows.Forms.Control.WndProc(Message& m)
> at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> at System.Windows.Forms.Button.WndProc(Message& m)
> at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
> at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
> at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
> msg, IntPtr wparam, IntPtr lparam)
>
> 2) Exception Information
> *****
> Exception Type: System.Security.SecurityException
> PermissionType: NULL
> PermissionState: NULL
> GrantedSet: NULL
> RefusedSet: NULL
> Message: Requested registry access is not allowed.
> TargetSite: Microsoft.Win32.RegistryKey OpenSubKey(System.String,
> Boolean)
> HelpLink: NULL
> Source: mscorlib
>
> StackTrace Information
> *****
> at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean
> writable)
> at Microsoft.Win32.RegistryKey.OpenSubKey(String name)
> at System.Net.ProxyRegBlob.ReadRegSettings()
> at System.Net.ProxyRegBlob.ReadRegSettings()
> at System.Net.ProxyRegBlob.GetIEProxy()
> at System.Net.Configuration.DefaultProxyHandler.Create(Object
> parent, Object configContext, XmlNode section)
> at
> System.Configuration.ConfigurationRecord.EvaluateRecursive(IConfigurationSectionHandler
> factory, Object config, String[] keys, Int32 iKey, XmlTextReader
> reader)
>
> **************************************************************
>
> Now, the exception that stands out is the Registry exception ... but
> nowhere in my application am I accessing the registry.
>
> Does anyone have any ideas as to what might be happening, and how to
> resolve it?
>
> Thanks!
> Clint
>


Loading