473,756 Members | 8,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading keys from HKEY_CURRENT_US ER from an impersonated Web Service

Hi,

I am using Impersonation and turned off anon access for my web service. I am
using the administator to authenticate the request using ICredentials. I am
simply trying to read a key in HKEY_CURRENT_US ER from my Web Service method
call which I am unable to. When I try and open it it returns null. Even
iterating all keys under HKEY_CURRENT_US ER only returns a handful of keys.

I can happily read any key under HKEY_LOCAL_MACH INE. I have checked the
identity of the user and it is definately running under the local
administrator.

Any ideas what to check would be great.
Regards
Simon Hart.
Mar 15 '06 #1
12 6384
Simon,

What account is your web service running under?

I have come across this issue before and the way i resolved it was to change
the app pool of the web service to a user who had permission to the actual
registry values you are attempting to read.

I must admit i have not come across the issue where iterating through the
keys only returns a hand full, because if the user is logged on as an
administrator, they should have full access to the registry, especially
there own area of the registry, i.e. HKEY_CURRENT_US ER

Hope this helps.
Regards
Scott Blood
C# Developer
"Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
news:ep******** ******@TK2MSFTN GP14.phx.gbl...
Hi,

I am using Impersonation and turned off anon access for my web service. I
am
using the administator to authenticate the request using ICredentials. I
am
simply trying to read a key in HKEY_CURRENT_US ER from my Web Service
method
call which I am unable to. When I try and open it it returns null. Even
iterating all keys under HKEY_CURRENT_US ER only returns a handful of keys.

I can happily read any key under HKEY_LOCAL_MACH INE. I have checked the
identity of the user and it is definately running under the local
administrator.

Any ideas what to check would be great.
Regards
Simon Hart.

Mar 15 '06 #2
Hi,

IIRC CURRENT_USER refer to the user currently logged in the computer , your
service does not has this info associated
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
news:ep******** ******@TK2MSFTN GP14.phx.gbl...
Hi,

I am using Impersonation and turned off anon access for my web service. I
am
using the administator to authenticate the request using ICredentials. I
am
simply trying to read a key in HKEY_CURRENT_US ER from my Web Service
method
call which I am unable to. When I try and open it it returns null. Even
iterating all keys under HKEY_CURRENT_US ER only returns a handful of keys.

I can happily read any key under HKEY_LOCAL_MACH INE. I have checked the
identity of the user and it is definately running under the local
administrator.

Any ideas what to check would be great.
Regards
Simon Hart.

Mar 15 '06 #3
Hi,

I thought this *might* be the case. When I check the user identity using
WindowsIdentity class, the user is the local Administrator account. The key
was installed via an install set which was installed under the local
Administrator account.

How do I do a real impersonate then, is it not possible to read a
*non-windows* key in HKEY_CURRENT_US ER via a Web service?

I know this works if running under a Serviced Component. What I might have
to do as a work around, is hand off control to the Serviced Component to do
the work, reading registry etc.

Florida - what a fine place btw - I learned to skydive there in 2004 at
DeLand.

Cheers
Simon.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:uQ******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

IIRC CURRENT_USER refer to the user currently logged in the computer ,
your service does not has this info associated
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
news:ep******** ******@TK2MSFTN GP14.phx.gbl...
Hi,

I am using Impersonation and turned off anon access for my web service. I
am
using the administator to authenticate the request using ICredentials. I
am
simply trying to read a key in HKEY_CURRENT_US ER from my Web Service
method
call which I am unable to. When I try and open it it returns null. Even
iterating all keys under HKEY_CURRENT_US ER only returns a handful of
keys.

I can happily read any key under HKEY_LOCAL_MACH INE. I have checked the
identity of the user and it is definately running under the local
administrator.

Any ideas what to check would be great.
Regards
Simon Hart.


Mar 15 '06 #4
Hi Scott,

The local administrator. I checked and verified this by using
WindowsIdentity class.

Cheers
Simon.

"scott blood" <sc*********@ho tmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Simon,

What account is your web service running under?

I have come across this issue before and the way i resolved it was to
change the app pool of the web service to a user who had permission to the
actual registry values you are attempting to read.

I must admit i have not come across the issue where iterating through the
keys only returns a hand full, because if the user is logged on as an
administrator, they should have full access to the registry, especially
there own area of the registry, i.e. HKEY_CURRENT_US ER

Hope this helps.
Regards
Scott Blood
C# Developer
"Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
news:ep******** ******@TK2MSFTN GP14.phx.gbl...
Hi,

I am using Impersonation and turned off anon access for my web service. I
am
using the administator to authenticate the request using ICredentials. I
am
simply trying to read a key in HKEY_CURRENT_US ER from my Web Service
method
call which I am unable to. When I try and open it it returns null. Even
iterating all keys under HKEY_CURRENT_US ER only returns a handful of
keys.

I can happily read any key under HKEY_LOCAL_MACH INE. I have checked the
identity of the user and it is definately running under the local
administrator.

Any ideas what to check would be great.
Regards
Simon Hart.


Mar 15 '06 #5
Hi,

How do I do a real impersonate then, is it not possible to read a
*non-windows* key in HKEY_CURRENT_US ER via a Web service?

I don;t even think if that is possible, you should check who component, or
at what moment the CURRENT_USER branch is generated, IMO it's at logon time
by either the shell or the login component.
If any of these is the case then I don't think you can get around it.

why you store your data under current_user? why not use local_machine
instead?
Mar 15 '06 #6
Hi,

Thanks for your input.

This is going to be a problem then. I would have put it under LOCAL_MACHINE
myself but I am integrating to a third party system from a Pocket PC
application. The PPC app connects to the Web Service using NTLM
authentication which does a sync with SQL Mobile on the device against the
MS Access database on the desktop. I need to read a key under
HKEY_CURRENT_US ER in order to get the install path for a INI file which I
read.

Cheers
Simon.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:el******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

How do I do a real impersonate then, is it not possible to read a
*non-windows* key in HKEY_CURRENT_US ER via a Web service?

I don;t even think if that is possible, you should check who component, or
at what moment the CURRENT_USER branch is generated, IMO it's at logon
time by either the shell or the login component.
If any of these is the case then I don't think you can get around it.

why you store your data under current_user? why not use local_machine
instead?

Mar 15 '06 #7
Ignacio is right, web services or web applications do load a profile, the
HKCU is pointing to the default profile of the IIS user ('localsystem' for
IIS5.x or 'network user' for IIS6). That means that HKCU is mapped to
HKU\.default on XP/W2K or HKU\S-1-5-19 on W2K3.

Willy.
"Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
news:ul******** ********@TK2MSF TNGP09.phx.gbl. ..
| Hi,
|
| I thought this *might* be the case. When I check the user identity using
| WindowsIdentity class, the user is the local Administrator account. The
key
| was installed via an install set which was installed under the local
| Administrator account.
|
| How do I do a real impersonate then, is it not possible to read a
| *non-windows* key in HKEY_CURRENT_US ER via a Web service?
|
| I know this works if running under a Serviced Component. What I might have
| to do as a work around, is hand off control to the Serviced Component to
do
| the work, reading registry etc.
|
| Florida - what a fine place btw - I learned to skydive there in 2004 at
| DeLand.
|
| Cheers
| Simon.
|
| "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
wrote
| in message news:uQ******** ******@TK2MSFTN GP09.phx.gbl...
| > Hi,
| >
| > IIRC CURRENT_USER refer to the user currently logged in the computer ,
| > your service does not has this info associated
| >
| >
| > --
| > Ignacio Machin,
| > ignacio.machin AT dot.state.fl.us
| > Florida Department Of Transportation
| >
| > "Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
| > news:ep******** ******@TK2MSFTN GP14.phx.gbl...
| >> Hi,
| >>
| >> I am using Impersonation and turned off anon access for my web service.
I
| >> am
| >> using the administator to authenticate the request using ICredentials.
I
| >> am
| >> simply trying to read a key in HKEY_CURRENT_US ER from my Web Service
| >> method
| >> call which I am unable to. When I try and open it it returns null. Even
| >> iterating all keys under HKEY_CURRENT_US ER only returns a handful of
| >> keys.
| >>
| >> I can happily read any key under HKEY_LOCAL_MACH INE. I have checked the
| >> identity of the user and it is definately running under the local
| >> administrator.
| >>
| >> Any ideas what to check would be great.
| >> Regards
| >> Simon Hart.
| >>
| >>
| >
| >
|
|
Mar 15 '06 #8
Hi Willy,

Is this true even though impersonation is used? and the user is
authenticated correctly?

Regards
Simon.
"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:OP******** *****@TK2MSFTNG P09.phx.gbl...
Ignacio is right, web services or web applications do load a profile, the
HKCU is pointing to the default profile of the IIS user ('localsystem' for
IIS5.x or 'network user' for IIS6). That means that HKCU is mapped to
HKU\.default on XP/W2K or HKU\S-1-5-19 on W2K3.

Willy.
"Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
news:ul******** ********@TK2MSF TNGP09.phx.gbl. ..
| Hi,
|
| I thought this *might* be the case. When I check the user identity using
| WindowsIdentity class, the user is the local Administrator account. The
key
| was installed via an install set which was installed under the local
| Administrator account.
|
| How do I do a real impersonate then, is it not possible to read a
| *non-windows* key in HKEY_CURRENT_US ER via a Web service?
|
| I know this works if running under a Serviced Component. What I might
have
| to do as a work around, is hand off control to the Serviced Component to
do
| the work, reading registry etc.
|
| Florida - what a fine place btw - I learned to skydive there in 2004 at
| DeLand.
|
| Cheers
| Simon.
|
| "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
wrote
| in message news:uQ******** ******@TK2MSFTN GP09.phx.gbl...
| > Hi,
| >
| > IIRC CURRENT_USER refer to the user currently logged in the computer ,
| > your service does not has this info associated
| >
| >
| > --
| > Ignacio Machin,
| > ignacio.machin AT dot.state.fl.us
| > Florida Department Of Transportation
| >
| > "Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
| > news:ep******** ******@TK2MSFTN GP14.phx.gbl...
| >> Hi,
| >>
| >> I am using Impersonation and turned off anon access for my web
service.
I
| >> am
| >> using the administator to authenticate the request using
ICredentials.
I
| >> am
| >> simply trying to read a key in HKEY_CURRENT_US ER from my Web Service
| >> method
| >> call which I am unable to. When I try and open it it returns null.
Even
| >> iterating all keys under HKEY_CURRENT_US ER only returns a handful of
| >> keys.
| >>
| >> I can happily read any key under HKEY_LOCAL_MACH INE. I have checked
the
| >> identity of the user and it is definately running under the local
| >> administrator.
| >>
| >> Any ideas what to check would be great.
| >> Regards
| >> Simon Hart.
| >>
| >>
| >
| >
|
|

Mar 15 '06 #9
Yes, impersonating does not load the profile of the impersonated user. Only
"accounts" that are logged in interactively (called an interactive session)
have their profiles loaded by the Winlogon process. If you need to load a
profile for a specific user, you'll have to load it yourself by calling
LoadUserProfile Win32 API via PInvoke, but this can become extremely
expensive (in terms of speed and space) in Web services where you need to
impersonate different users, and it's extremely unsafe to load a users
profile in the context of a webservice, user profiles can hold private
secured info of a user that is supposed to run in an interactive session
only!
Really, services (all kind) should not rely on the presence of a specific
user profiles.
Willy.


"Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
news:uJ******** ******@TK2MSFTN GP12.phx.gbl...
| Hi Willy,
|
| Is this true even though impersonation is used? and the user is
| authenticated correctly?
|
| Regards
| Simon.
| "Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
| news:OP******** *****@TK2MSFTNG P09.phx.gbl...
| > Ignacio is right, web services or web applications do load a profile,
the
| > HKCU is pointing to the default profile of the IIS user ('localsystem'
for
| > IIS5.x or 'network user' for IIS6). That means that HKCU is mapped to
| > HKU\.default on XP/W2K or HKU\S-1-5-19 on W2K3.
| >
| > Willy.
| >
| >
| > "Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
| > news:ul******** ********@TK2MSF TNGP09.phx.gbl. ..
| > | Hi,
| > |
| > | I thought this *might* be the case. When I check the user identity
using
| > | WindowsIdentity class, the user is the local Administrator account.
The
| > key
| > | was installed via an install set which was installed under the local
| > | Administrator account.
| > |
| > | How do I do a real impersonate then, is it not possible to read a
| > | *non-windows* key in HKEY_CURRENT_US ER via a Web service?
| > |
| > | I know this works if running under a Serviced Component. What I might
| > have
| > | to do as a work around, is hand off control to the Serviced Component
to
| > do
| > | the work, reading registry etc.
| > |
| > | Florida - what a fine place btw - I learned to skydive there in 2004
at
| > | DeLand.
| > |
| > | Cheers
| > | Simon.
| > |
| > | "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
| > wrote
| > | in message news:uQ******** ******@TK2MSFTN GP09.phx.gbl...
| > | > Hi,
| > | >
| > | > IIRC CURRENT_USER refer to the user currently logged in the computer
,
| > | > your service does not has this info associated
| > | >
| > | >
| > | > --
| > | > Ignacio Machin,
| > | > ignacio.machin AT dot.state.fl.us
| > | > Florida Department Of Transportation
| > | >
| > | > "Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
| > | > news:ep******** ******@TK2MSFTN GP14.phx.gbl...
| > | >> Hi,
| > | >>
| > | >> I am using Impersonation and turned off anon access for my web
| > service.
| > I
| > | >> am
| > | >> using the administator to authenticate the request using
| > ICredentials.
| > I
| > | >> am
| > | >> simply trying to read a key in HKEY_CURRENT_US ER from my Web
Service
| > | >> method
| > | >> call which I am unable to. When I try and open it it returns null.
| > Even
| > | >> iterating all keys under HKEY_CURRENT_US ER only returns a handful
of
| > | >> keys.
| > | >>
| > | >> I can happily read any key under HKEY_LOCAL_MACH INE. I have checked
| > the
| > | >> identity of the user and it is definately running under the local
| > | >> administrator.
| > | >>
| > | >> Any ideas what to check would be great.
| > | >> Regards
| > | >> Simon Hart.
| > | >>
| > | >>
| > | >
| > | >
| > |
| > |
| >
| >
|
|
Mar 15 '06 #10

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

Similar topics

6
6005
by: SivaSiva | last post by:
Hi, I'm getting the following error when I try convert a word document using asp.net. Application Event Log : Detection of product '{90110409-6000-11D3-8CFE-0150048383C9}', feature 'WordUserData', component '{8ADD2C93-C8B7-11D1-9C67-0000F81F1B38}' failed. The resource 'HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Word\UserData' does not exist.
3
5076
by: Ahmad Jalil Qarshi | last post by:
Hi! I am developing an application in C# as a windows NT Service. This application needs to check for eventlog using EventLog.Exists("System") But unfortunately it generates exception "Requested registry access is not allowed."
4
1753
by: Rik Hemsley | last post by:
Hi, Our web application impersonates a domain user when it runs. Usually, the printers visible to the application are the same as those visible to the domain user. At one installation, the list of printers is reduced to only the 'document image writer' - unless the impersonated user is logged on to the machine, in which case the full list is visible.
4
1548
by: srikanthv | last post by:
I have below Sample text. I need find in the text specfic "Key name" its Value "HKEY_CURRENT_USER\Control Panel\International", If I find this I need to go inside of this and read Value 0 (Name: Its value and Data: Its value),Value 1 (Name: Its value and Data: Its value)....Value N (Name: Its value and Data: Its value). Please provide me same code for this. Sample -------
7
2182
by: fniles | last post by:
In my case, I have registry entries with multiple Key values, like the following I would like to loop thru MyApp\MySection\Data to get to entries A,B and C, instead of doing the following for each Key entry:
2
1352
by: shumaker | last post by:
I am putting a key for my application to run at startup in SOFTWARE\Microsoft\Windows\CurrentVersion\Run My goal is to allow individual users to toggle this on and off, so I was placing the key under CurrentUser. However, I want the program to default to starting up for the user the first time any user logs in after it is installed. In the past we had installed the key under local machine, but this means that removing the key as per...
0
4004
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain, but my department has a couple of web servers of our own that are part of my organization's domain. I am trying to read LDAP information on my organization's domain controller from a web application on one of my department's servers. I have been...
5
6976
by: Sin Jeong-hun | last post by:
I need to read some registry keys of a remote computer. The key will be any key users provide. (For example : HKEY_CURRENT_USER\SOFTWARE \MyGame) I found that there was a handy method called RegistryKey.OpenRemoteBaseKey(); I tried But everytime I execute it, an UnauthorizedAccessException occurred at the OpenRemoteBaseKey method. Both computer (the one that ran the C# application, and the remote computer) are Windows XP Professional,...
0
4641
by: Gary | last post by:
I'm having trouble entering Additional Registry Keys into my Package Solution that will deploy the Access 2007 runtime. (Client machine is running XP with Office 2007 Standard.) The Package Solution Wizard, on about page 3, has a section for entering Additional Registry Keys. I want to include a locations key that will identify my install directory as a Trusted Location, thereby turning off the Security Alert when users open the ACCDR. ...
0
9873
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
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 we have to send another system
3
2666
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.