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");