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

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default "Requested registry access is not allowed" and Web Service call

    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.Imperson ate()), 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\Conf ig\machine.config
    line 74)
    BareMessage: Exception in configuration section handler
    Filename:
    c:\windows\microsoft.net\framework\v1.1.4322\Confi g\machine.config
    Line: 74
    TargetSite: System.Object
    EvaluateRecursive(System.Configuration.IConfigurat ionSectionHandler,
    System.Object, System.String[], Int32, System.Xml.XmlTextReader)
    HelpLink: NULL
    Source: System

    StackTrace Information
    *****
    at
    System.Configuration.ConfigurationRecord.EvaluateR ecursive(IConfigurationSectionHandler
    factory, Object config, String[] keys, Int32 iKey, XmlTextReader
    reader)
    at
    System.Configuration.ConfigurationRecord.EvaluateR ecursive(IConfigurationSectionHandler
    factory, Object config, String[] keys, Int32 iKey, XmlTextReader
    reader)
    at System.Configuration.ConfigurationRecord.Evaluate( String
    configKey)
    at System.Configuration.ConfigurationRecord.ResolveCo nfig(String
    configKey)
    at System.Configuration.ConfigurationRecord.GetConfig (String
    configKey)
    at System.Configuration.ConfigurationRecord.ResolveCo nfig(String
    configKey)
    at System.Configuration.ConfigurationRecord.GetConfig (String
    configKey)
    at
    System.Configuration.DefaultConfigurationSystem.Sy stem.Configuration.IConfigurationSystem.GetConfig( String
    configKey)
    at System.Configuration.ConfigurationSettings.GetConf ig(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.Ge tWebRequest(Uri
    uri)
    at
    System.Web.Services.Protocols.HttpWebClientProtoco l.GetWebRequest(Uri
    uri)
    at
    System.Web.Services.Protocols.SoapHttpClientProtoc ol.GetWebRequest(Uri
    uri)
    at
    System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
    methodName, Object[] parameters)
    at Journals.BAL.<svr>.FSConnect.PerformHandshake(Stri ng 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(Transfe rOkEventArgs 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(MouseEventAr gs 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(M essage& 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.Creat e(Object
    parent, Object configContext, XmlNode section)
    at
    System.Configuration.ConfigurationRecord.EvaluateR ecursive(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

    Clint Guest

  2. Similar Questions and Discussions

    1. "Can't call method "disconnect" on an undefined value..."
      Hey there anyone, I am new at this and I am trying to figure this out and I don't know too much, but I keep getting this error when trying to run...
    2. Web Service Error - Server was unable to process request. --> Requested registry
      I have created a web service that runs fine on my development computer but when I try running it on the server it will not function. I have...
    3. Illustrator CS won't open-- error "Cannot Complete Requested Operation"
      Weirdest thing, can't figure it out. I installed from our master license the onto to PC's running Windows XP the Adobe Creative Suite, and of all...
    4. "Access Denied" to ICatalogCollection from asp.net web service
      I am getting an Access Denied to COM+ catalog when attempting to save changes.... So I now use impersonation to impersonate an admin account on...
    5. 'Requested registry access is not allowed.' error
      Hi, i am trying to write to event log from my aspx application that is using windows authentication. All my users would be 'Domain Users'. I am...
  3. #2

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

    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\Int ernet
    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.googlegr oups.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.Imperson ate()), 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\Conf ig\machine.config
    > line 74)
    > BareMessage: Exception in configuration section handler
    > Filename:
    > c:\windows\microsoft.net\framework\v1.1.4322\Confi g\machine.config
    > Line: 74
    > TargetSite: System.Object
    > EvaluateRecursive(System.Configuration.IConfigurat ionSectionHandler,
    > System.Object, System.String[], Int32, System.Xml.XmlTextReader)
    > HelpLink: NULL
    > Source: System
    >
    > StackTrace Information
    > *****
    > at
    > System.Configuration.ConfigurationRecord.EvaluateR ecursive(IConfigurationSectionHandler
    > factory, Object config, String[] keys, Int32 iKey, XmlTextReader
    > reader)
    > at
    > System.Configuration.ConfigurationRecord.EvaluateR ecursive(IConfigurationSectionHandler
    > factory, Object config, String[] keys, Int32 iKey, XmlTextReader
    > reader)
    > at System.Configuration.ConfigurationRecord.Evaluate( String
    > configKey)
    > at System.Configuration.ConfigurationRecord.ResolveCo nfig(String
    > configKey)
    > at System.Configuration.ConfigurationRecord.GetConfig (String
    > configKey)
    > at System.Configuration.ConfigurationRecord.ResolveCo nfig(String
    > configKey)
    > at System.Configuration.ConfigurationRecord.GetConfig (String
    > configKey)
    > at
    > System.Configuration.DefaultConfigurationSystem.Sy stem.Configuration.IConfigurationSystem.GetConfig( String
    > configKey)
    > at System.Configuration.ConfigurationSettings.GetConf ig(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.Ge tWebRequest(Uri
    > uri)
    > at
    > System.Web.Services.Protocols.HttpWebClientProtoco l.GetWebRequest(Uri
    > uri)
    > at
    > System.Web.Services.Protocols.SoapHttpClientProtoc ol.GetWebRequest(Uri
    > uri)
    > at
    > System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
    > methodName, Object[] parameters)
    > at Journals.BAL.<svr>.FSConnect.PerformHandshake(Stri ng 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(Transfe rOkEventArgs 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(MouseEventAr gs 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(M essage& 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.Creat e(Object
    > parent, Object configContext, XmlNode section)
    > at
    > System.Configuration.ConfigurationRecord.EvaluateR ecursive(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
    >

    Nicole Calinoiu Guest

  4. #3

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

    Hi Nicole -

    That sounds exactly like whats going on. I added the following to my
    App.config file:

    <configuration>
    <system.net>
    <defaultProxy>
    <proxy
    usesystemdefault="false"
    proxyaddress="http://proxyserver:80"
    bypassonlocal="true"
    />
    </defaultProxy>
    </system.net>
    </configuration>

    And still managed to get the same error. Now, I know
    [url]http://proxyserver:80[/url] won't work as it doesn't exist, but I figured a
    separate message would've appeared. It almost seems as if the new
    settings aren't overriding those in Machine.config.
    Any ideas?
    Thanks!
    Clint

    Clint Guest

  5. #4

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

    Hi Nicole -

    That sounds exactly like whats going on. I added the following to my
    App.config file:

    <configuration>
    <system.net>
    <defaultProxy>
    <proxy
    usesystemdefault="false"
    proxyaddress="http://proxyserver:80"
    bypassonlocal="true"
    />
    </defaultProxy>
    </system.net>
    </configuration>

    And still managed to get the same error. Now, I know
    [url]http://proxyserver:80[/url] won't work as it doesn't exist, but I figured a
    separate message would've appeared. It almost seems as if the new
    settings aren't overriding those in Machine.config.
    Any ideas?
    Thanks!
    Clint

    Clint Guest

  6. #5

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

    If overriding via app.config isn't working, you might want to try "manually"
    setting the Proxy property of the HttpWebRequest that is used to call the
    web service. According to the docs, reading of the proxy settings from the
    config file will only occur for an HttpWebRequest that has not yet had its
    Proxy property set when submission of the request is first attempted.

    HTH,
    Nicole


    "Clint" <cjmueller@gmail.com> wrote in message
    news:1103058656.341373.176360@c13g2000cwb.googlegr oups.com...
    > Hi Nicole -
    >
    > That sounds exactly like whats going on. I added the following to my
    > App.config file:
    >
    > <configuration>
    > <system.net>
    > <defaultProxy>
    > <proxy
    > usesystemdefault="false"
    > proxyaddress="http://proxyserver:80"
    > bypassonlocal="true"
    > />
    > </defaultProxy>
    > </system.net>
    > </configuration>
    >
    > And still managed to get the same error. Now, I know
    > [url]http://proxyserver:80[/url] won't work as it doesn't exist, but I figured a
    > separate message would've appeared. It almost seems as if the new
    > settings aren't overriding those in Machine.config.
    > Any ideas?
    > Thanks!
    > Clint
    >

    Nicole Calinoiu Guest

  7. #6

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

    I think I'm doing something wrong in that I tried setting the Proxy
    right after creating a new instance of my service:

    ws = new HashTest.iisvm03.Service1();
    ws.Proxy = new System.Net.WebProxy("http://foo:80", true);
    ws.CookieContainer = new System.Net.CookieContainer();
    ws.Credentials = System.Net.CredentialCache.DefaultCredentials;

    With no success - still trying to read from the registry. I did find a
    work-around, though, in that I'm not always impersonating a user in the
    application, only on remote calls. So, when my calling class fires up,
    it isn't impersonating, and I can set a private proxy field in the
    constructor and use it as needed when I do my calls. That, oddly
    enough, seems to work.

    I have no problem going that route, I'm more curious now as to what I
    was doing wrong for future reference. Either way - thanks again for
    helping me out - this has been bugging me for a while!

    Clint

    Clint Guest

  8. #7

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

    That's the wrong Proxy property. The web service wrapper class generated
    for use in the client application inherits from
    System.Web.Services.Protocols.WebClientProtocol, even if not directly. You
    would need to override its virtual GetWebRequest method to set the value of
    the Proxy property for the HttpWebRequest used by the wrapper.
    Unfortunately, this change would be undone every time the auto-generated
    wrapper class is regenerated. If you have an acceptable workaround that
    doesn't compromise the security of your system, it would probably be best to
    use it.

    HTH,
    Nicole


    "Clint" <cjmueller@gmail.com> wrote in message
    news:1103122155.057204.269070@c13g2000cwb.googlegr oups.com...
    >I think I'm doing something wrong in that I tried setting the Proxy
    > right after creating a new instance of my service:
    >
    > ws = new HashTest.iisvm03.Service1();
    > ws.Proxy = new System.Net.WebProxy("http://foo:80", true);
    > ws.CookieContainer = new System.Net.CookieContainer();
    > ws.Credentials = System.Net.CredentialCache.DefaultCredentials;
    >
    > With no success - still trying to read from the registry. I did find a
    > work-around, though, in that I'm not always impersonating a user in the
    > application, only on remote calls. So, when my calling class fires up,
    > it isn't impersonating, and I can set a private proxy field in the
    > constructor and use it as needed when I do my calls. That, oddly
    > enough, seems to work.
    >
    > I have no problem going that route, I'm more curious now as to what I
    > was doing wrong for future reference. Either way - thanks again for
    > helping me out - this has been bugging me for a while!
    >
    > Clint
    >

    Nicole Calinoiu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139