By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,423 Members | 1,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,423 IT Pros & Developers. It's quick & easy.

Security Context of Background Thread

P: n/a
I've written a class that allows me to add documents to a SharePoint
Document Library from another web application. The web app runs under
a domain account that has permissions to SharePoint. However, when I
try to do this from a background thread it fails with Access Denied.
I've tested the WindowsIdentity from the background thread and it is
the same. Are background threads not running in the same security
context under ASP.NET 2.0? Following is my code, Button1 works,
Button2 does not.

protected void Button1_Click(object sender, EventArgs e) {
SPDocLibDataAccess da = new SPDocLibDataAccess("http://
staff.mcrcsip.org", "");
da.AddDocument("D:\\Temp\\LicensedVehiclesDetailRe port.pdf", "Shared
Documents");
this.lblMessage.Text = "Done!";
}
protected void Button2_Click(object sender, EventArgs e) {
ThreadStart ts = new ThreadStart(this.UploadFile);
Thread t = new Thread(ts);
t.Start();
this.lblMessage.Text = "Started thread.";
}

private void UploadFile() {
SPDocLibDataAccess da = new SPDocLibDataAccess("http://
staff.mcrcsip.org", "");
da.AddDocument("D:\\Temp\\LicensedVehiclesDetailRe port.pdf", "Shared
Documents");
}

Mar 17 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I had impersonation enable without realizing it. The foreground
thread was executing under the logged in user's account which had
permissions on the SharePoint site. The background thread was
executing under the identity of the Application Pool, which didn't
have permissions on the SharePoint site.

Mar 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.