0
爲什麼我的log4net沒有登錄後Impersonate
,開始登錄後Undo
?log4net未登錄後模擬
testDebug 6
不是日誌。
我該怎麼辦呢?
logger.Debug("testDebug 5");
// The token that is passed to the following constructor must
// be a primary token in order to use it for impersonation.
WindowsIdentity newId = new WindowsIdentity(dupeTokenHandle);
WindowsImpersonationContext impersonatedUser = newId.Impersonate();
logger.Debug("testDebug 6");
// Check the identity.
// Console.WriteLine("After impersonation: "
// + WindowsIdentity.GetCurrent().Name);
if (Config.DebugMode().Trim().ToUpper() == "ON")
logger.Debug("After impersonation: " + WindowsIdentity.GetCurrent().Name);
//////// Put your code here ////////
ReceiveEmail();
///////////////////////////////////
// Stop impersonating the user.
impersonatedUser.Undo();
logger.Debug("testDebug 7");