HighTechTalks DotNet Forums  

GetFolderPath fails when impersonating

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss GetFolderPath fails when impersonating in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Matt Houser
 
Posts: n/a

Default GetFolderPath fails when impersonating - 11-11-2009 , 03:25 PM






I have a named pipe set up between 2 processes on my local computer. I am
using NamedPipeClientStream and NamedPipeServerStream. After getting the
connection, my server impersonates the client user using
NamedPipeServerStream.RunAsClient(). It then calls
Environment.GetFolderPath to get the impersonated user's Application Data
folder.

All seems to be working most of the time. However...

I have 2 domain user accounts, both of which have been logged into my
computer at one time or another. Let's call them Matt and Mary.

I am currently logged in as 'Matt'.
If I run the server as 'Mary' using "Run as different user", and I run the
client as 'Matt, then I get an exception in the call to GetFolderPath:
DllNotFoundException
Unable to load DLL 'shfolder.dll': Exception from HRESULT:
0x80070542

I am using Windows 7.

If I reverse who is running what, then it works ok. So if I impersonate
Mary in the process running as Matt, then it works.

Is "Run as different user" somehow flawed, or does this accurately depict
that there's an issue with what I am doing?

Thanks,
....Matt

Reply With Quote
  #2  
Old   
Phil Wilson
 
Posts: n/a

Default Re: GetFolderPath fails when impersonating - 11-15-2009 , 02:22 PM






I think some of this is might be because the user's application data folder
info is in that user's registry hive, and impersonation does not load it.
The docs for the LoadUserProfile API explain this. However the missing
shfolder Dll message is bogus because 0x80070542 errors seem to be related
to impersonation (maybe Mary doesn't have the right to impersonate).
--
Phil Wilson

"Matt Houser" <matt (AT) houser (DOT) ca> wrote

Quote:
I have a named pipe set up between 2 processes on my local computer. I am
using NamedPipeClientStream and NamedPipeServerStream. After getting the
connection, my server impersonates the client user using
NamedPipeServerStream.RunAsClient(). It then calls
Environment.GetFolderPath to get the impersonated user's Application Data
folder.

All seems to be working most of the time. However...

I have 2 domain user accounts, both of which have been logged into my
computer at one time or another. Let's call them Matt and Mary.

I am currently logged in as 'Matt'.
If I run the server as 'Mary' using "Run as different user", and I run the
client as 'Matt, then I get an exception in the call to GetFolderPath:
DllNotFoundException
Unable to load DLL 'shfolder.dll': Exception from HRESULT:
0x80070542

I am using Windows 7.

If I reverse who is running what, then it works ok. So if I impersonate
Mary in the process running as Matt, then it works.

Is "Run as different user" somehow flawed, or does this accurately depict
that there's an issue with what I am doing?

Thanks,
...Matt

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.