Impersonation ???
-
Hi all, Appologies in advance if this question has already been answered...I looked...really! Apparently I don't know jack about impersonation in ASP.NET. I need to have ASP.NET look at a network share and tell me if it finds a file. My code looks like:
//impersonate int i; bool b=LogonUser("someuser","RESTEKCORP","thepassword",3,0,out i ); WindowsIdentity wi = new WindowsIdentity (new System.IntPtr (i)); WindowsImpersonationContext wic = wi.Impersonate (); FileInfo FI = new FileInfo (@"\\10.238.218.XXX/some_share/TheFile.ext");
Now my confussion: I know "someuser" has access to the share, since I use my own login (at least for now) and I can list the directory and edit files through windows. The login seems to succeed, as b is true. But FI.Exists comes back as false, even though I know the file exists. So I look at FI in the debugger and notice that I am getting a message saying that aSystem.UnauthorizedAccessException
occured. Which suggests to me that the impersonation is not working... What am I missing? Bill