c# - Access mapped drive when running as user -


i have program runs elevated. program launch other executables.

now default process create run elevated. so, programs runs, want them run if not elevated, standard user who's logged in.

the main elevated program running under user account of logged in user.

so tried

var psi = new processstartinfo(exe.getexepath()); psi.useshellexecute = false; psi.redirectstandarderror = false; psi.redirectstandardinput = false; psi.redirectstandardoutput = false; psi.workingdirectory = exe.version.getinstallpath(); if(exe.elevated == false) {     psi.username = global.username;     var pass = new securestring();     global.password.tochararray().tolist().foreach(p => pass.appendchar(p));     psi.password = pass; } process = process.start(psi); 

that works, in started program not elevated. however, @ point loses access mapped network drives odd reason.

i tried doing impersonating windows user within application launches, , doesn't work.

so guess i'm wondering, how can gain access these mapped drives (all applications running under correct user).

by default uac behaviour, elevated process runs on different security context, should not able access of mapped drives, , same goes processes spawn process. can test running elevated command prompt in windows; default have no access mapped drives of non-elevated session.

see these superuser questions more details on behaviour , possible workarounds (changing mapped drive setup, global registry changes etc).

if changing uac defaults or mapping creation not option, possible (though complicated) workaround launch application without elevation, wait code needs elevation launch second, elevated process, , call original process (the 1 running in security context mapped drives) actual launching of new applications, using ipc method of choice (for example wcf named pipes.)


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -