I have an app that uploads files into a unc directory that everyone has permission to upload to.
The interface uses a proxy webservice that call another webservice. (this is done for security purposes and works fine in all otehr instances) he proxy webservice runs as a speciifc useraccoutn that gets verified on the end point webservice);
Once the file is their the application calls the proxy webservice(which calls the webservice that controls this upload direttory) and removes the inherited permissions and applies specific permission to the file so that it can no longer be accessed by a specific usergroup.
This second webservice also runs under a specific system acount that has full control to the directory in question.
The webservice webmethod uses impersonation initially to verify that the call is coming from the parent webservice but once that occurs it stops impersonating so that it can run as the service accoutn that controls the directory. (app pool is configured to run under this account)
But for some reason I can not figure out despite it being explicityly told to STOP impersonating (which defacto should cause it to run as its app pool account) UNless someone with local admin rights on the web server runs the command from the interface it returns the error
ception: Server was unable to process request. ---> System.UnauthorizedAccessE
xception: Attempted to perform an unauthorized operation.
urceType type, String name, SafeHandle handle, SecurityInfos securityInformation, SecurityIdentifier owner, SecurityIdentifier group, GenericAcl sacl, GenericAcl dacl)
st(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)
st(String name, AccessControlSections includeSections, Object exceptionContext)
st(String name, AccessControlSections includeSections)
ng path, FileSecurity fileSecurity)
Add the user to the local admin group and it works fine.
Remove the user from the local admin group and it gives the error...
BUt who the user is shouldnt matter at all by that time it has stopped impersonating the original caller TWO service gone and should be impersonating the username of the app pool. Even stranger...when it works because the original caller has admin rights and applies the permission correctly..the permissions applied are generated by the account that the method is running as..so I can see what account is actually setting the permission (since it set the permissions for itself) and it is the correct service account...so I have NO IDEA why it should matter at all whether the user on teh inetrface end has local admin rights or not on the web server running this third tier web service.
below is the code I use which you can see expliciltly says to stop impersonating...
WindowsImpersonationContext ctx = WindowsIdentity.Impersonate(IntPtr.Zero);
//get the username of the currently running acount
string ealmsAccount = omnibll.UserAuth. GetUsername ();
succ = true;