Added identity impersonation logic to all background operations (ThreadPool).
This commit is contained in:
parent
ec69ace193
commit
180e45d90c
3 changed files with 50 additions and 42 deletions
|
@ -16,5 +16,5 @@ using System.Reflection;
|
||||||
//
|
//
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("3.0.4.575")]
|
[assembly: AssemblyVersion("3.0.4.576")]
|
||||||
[assembly: AssemblyFileVersion("3.0.4.575")]
|
[assembly: AssemblyFileVersion("3.0.4.576")]
|
|
@ -3,12 +3,13 @@ using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
|
using System.Security.Principal;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Security;
|
using System.Web.Security;
|
||||||
using System.Web.UI;
|
using System.Web.UI;
|
||||||
|
using System.Web.UI.HtmlControls;
|
||||||
using System.Web.UI.WebControls;
|
using System.Web.UI.WebControls;
|
||||||
using System.Web.UI.WebControls.WebParts;
|
using System.Web.UI.WebControls.WebParts;
|
||||||
using System.Web.UI.HtmlControls;
|
|
||||||
using ScrewTurn.Wiki.PluginFramework;
|
using ScrewTurn.Wiki.PluginFramework;
|
||||||
|
|
||||||
namespace ScrewTurn.Wiki {
|
namespace ScrewTurn.Wiki {
|
||||||
|
@ -28,10 +29,12 @@ namespace ScrewTurn.Wiki {
|
||||||
/// <param name="html"><c>true</c> if the body is HTML.</param>
|
/// <param name="html"><c>true</c> if the body is HTML.</param>
|
||||||
public static void AsyncSendEmail(string recipient, string sender, string subject, string body, bool html) {
|
public static void AsyncSendEmail(string recipient, string sender, string subject, string body, bool html) {
|
||||||
System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state) {
|
System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state) {
|
||||||
|
using(((WindowsIdentity)state).Impersonate()) {
|
||||||
MailMessage message = new MailMessage(sender, recipient, subject, body);
|
MailMessage message = new MailMessage(sender, recipient, subject, body);
|
||||||
message.IsBodyHtml = html;
|
message.IsBodyHtml = html;
|
||||||
TrySendMessage(message);
|
TrySendMessage(message);
|
||||||
});
|
}
|
||||||
|
}, WindowsIdentity.GetCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -94,6 +97,7 @@ namespace ScrewTurn.Wiki {
|
||||||
if(recipients.Length == 0) return;
|
if(recipients.Length == 0) return;
|
||||||
|
|
||||||
System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state) {
|
System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state) {
|
||||||
|
using(((WindowsIdentity)state).Impersonate()) {
|
||||||
MailMessage message = new MailMessage(new MailAddress(sender), new MailAddress(sender));
|
MailMessage message = new MailMessage(new MailAddress(sender), new MailAddress(sender));
|
||||||
message.Subject = subject;
|
message.Subject = subject;
|
||||||
message.Body = body;
|
message.Body = body;
|
||||||
|
@ -102,7 +106,8 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
message.IsBodyHtml = html;
|
message.IsBodyHtml = html;
|
||||||
TrySendMessage(message);
|
TrySendMessage(message);
|
||||||
});
|
}
|
||||||
|
}, WindowsIdentity.GetCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Resources;
|
using System.Resources;
|
||||||
|
using System.Security.Principal;
|
||||||
using System.Web.Configuration;
|
using System.Web.Configuration;
|
||||||
using ScrewTurn.Wiki.PluginFramework;
|
using ScrewTurn.Wiki.PluginFramework;
|
||||||
|
|
||||||
|
@ -192,7 +193,8 @@ namespace ScrewTurn.Wiki {
|
||||||
|
|
||||||
Log.LogEntry("ScrewTurn Wiki is ready", EntryType.General, Log.SystemUsername);
|
Log.LogEntry("ScrewTurn Wiki is ready", EntryType.General, Log.SystemUsername);
|
||||||
|
|
||||||
System.Threading.ThreadPool.QueueUserWorkItem(ignored => {
|
System.Threading.ThreadPool.QueueUserWorkItem(state => {
|
||||||
|
using(((WindowsIdentity)state).Impersonate()) {
|
||||||
if((DateTime.Now - Settings.LastPageIndexing).TotalDays > 7) {
|
if((DateTime.Now - Settings.LastPageIndexing).TotalDays > 7) {
|
||||||
Settings.LastPageIndexing = DateTime.Now;
|
Settings.LastPageIndexing = DateTime.Now;
|
||||||
System.Threading.Thread.Sleep(10000);
|
System.Threading.Thread.Sleep(10000);
|
||||||
|
@ -209,7 +211,8 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}, WindowsIdentity.GetCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue