c# - Delete folder programmatically as admin -


i'm trying delete user profile folder suing c# , asp.net, when through windows ui uac prompt fine.

i wish programmatically using asp.net & c# . objective admin users launch webform , remotely on workstation i'm getting permission errors. (im running visual studio admin in debugging environment delete local users)

{"access path 'c:\users\nzsp2013admin\appdata\local\microsoft\windows\application ..... denied."}

code:

var dir = new directoryinfo("c:\users\nzsp2013admin");

dir.attributes = dir.attributes & ~fileattributes.readonly;
dir.delete(true); // true => recursive delete

this has permissions configured in iis.

every asp.net application run in iis run using identity can managed in application pools section in iis manager.

by default, each application pool created (including default one) have permissions within limited scope.

if i'm honest, phrase application pool makes things sound more complicated are. application pool identity 1 use sign on pc, , in case identity normal user permissions attempting perform action requires set of higher permissions.

to resolve this, open iis.

  1. click on application pools
  2. select application pool web application running under
  3. click on advanced settings
  4. click on identity , select custom identity
  5. enter credentials of account has administrative privileges.

steps configure permissions

enter image description here

however, have warn you opening wide range of security concerns , there alternatives such adding explicit permissions specific directories include identity asp.net application running from.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -