473,473 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Security Context of Background Thread

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
1 1853
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ChrisB | last post by:
Hello: I am a member of a team creating a .NET application, and we seem to have run into an issue when trying to implement role based security. Our application makes use of a fairly common...
116
by: Mike MacSween | last post by:
S**t for brains strikes again! Why did I do that? When I met the clients and at some point they vaguely asked whether eventually would it be possible to have some people who could read the data...
24
by: Bob Alston | last post by:
Could develop web pages that would interact with the access/jet database - like DAP but without the security flaw??? One of Access' competitors (Filemaker Pro as I recall) touts its EASY way to...
1
by: Jerry Negrelli | last post by:
I'm running an ASP.NET application which uses impersonation & Windows authentication to set the current Principal. One of my methods was taking an awful long time to run, so I decided to launch...
0
by: John Bowman | last post by:
Hi, I've got an app that implements a VSA scripting host engine and runs the VB ..NET script in a separate thread. However, since this is being called from external VB .NET scripts and runs in...
4
by: hazz | last post by:
If I successfully run a VS.NET app which includes the following; ************************** APP 1 **************************** m_iIdnt = new...
2
by: Sparky | last post by:
Hi I have an vb.net winforms application that needs to launch a thread, and within that thread change the security context of the current user to a new one using impersonation. For clarity, the...
5
by: David Thielen | last post by:
Hi; I am creating png files in my ASP .NET app. When I am running under Windows 2003/IIS 6, the file is not given the security permissions it should have. It does not have any permission for...
0
by: Gregory Gadow | last post by:
Still working on this project. What I have working: I have a service that uses FileSystemWatcher on an "in box" folder. When a text file appears in the in-box, it copies the file to a work...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.