File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1- using NLog ;
1+ using NLog ;
22using NLog . Config ;
33using NLog . Layouts ;
44using NLog . Targets ;
88using System ;
99using System . Diagnostics ;
1010using System . IO ;
11- using System . Threading . Tasks ;
11+ using System . Security . Principal ;
1212using System . Text . RegularExpressions ;
1313using System . Threading ;
14+ using System . Threading . Tasks ;
1415
1516namespace Snaffler
1617{
@@ -201,7 +202,14 @@ public void Run(string[] args)
201202
202203 var tokenSource = new CancellationTokenSource ( ) ;
203204 var token = tokenSource . Token ;
204- Task thing = Task . Factory . StartNew ( ( ) => { controller . Execute ( ) ; } , token ) ;
205+
206+ WindowsIdentity impersonatedUser = WindowsIdentity . GetCurrent ( ) ;
207+ Task thing = Task . Factory . StartNew ( ( ) => {
208+ using ( WindowsImpersonationContext ctx = impersonatedUser . Impersonate ( ) )
209+ {
210+ controller . Execute ( ) ;
211+ }
212+ } , token ) ;
205213 bool exit = false ;
206214
207215 while ( exit == false )
You can’t perform that action at this time.
0 commit comments