GetFolderPath fails when impersonating - 11-11-2009 , 04: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
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:
Unable to load DLL 'shfolder.dll': Exception from HRESULT:
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?
Re: GetFolderPath fails when impersonating - 11-15-2009 , 03: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).
"Matt Houser" <matt (AT) houser (DOT) ca> wrote
|Thread Tools||Search this Thread|