473,417 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,417 software developers and data experts.

Passing Impersonation to new Thread

C
All,

I am trying to run my BO in a separate thread, so that I can give the
user a visual of the status of my process in a asp.net page/site. All
works fine, IF the ASPNET user has admin rights, (in order to do the
tasks in the BO). Now, I impersonate the admin user in the web.config
after removing his admin rights from my machine, then I ran the code
below, in a page_load. The Name of the security principal is the
administrator I have specified in the web.config. However, this
impersonation does not get carried over to new threads, as I have
found out when I am getting the WindowsIdentity in my BO.

(Explained here as well)
http://www.asp.net/whitepaper/aspnet_hosting_public.doc

So, my question is, how do I instantiate a new thread, and assign the
same security context to it, as I have in my AppDomain?

I have tried doing it in my BO, but then again, we need a lot of other
permissions set for the ASPNET user and or change the machine.config,
etc, etc..

Is there any way to cary over my user rights to the new thread t?

Other articles:
http://www.dotnetspider.com/Technology/KBPages/403.aspx
http://support.microsoft.com/default...;en-us;Q306158
http://www.bluevisionsoftware.com/We...=AspNetAccount
http://groups.google.co.uk/groups?hl...TNGP10.phx.gbl

CODE SAMPLE FROM PAGE_LOAD:
//admin user
Response.Write (System.Security.Principal.WindowsIdentity
..GetCurrent().Name );

//SOME CODE...
#region SITE OBJECT & THREAD CREATION
if(Session["o_site"]==null)//CREATES NEW OBJECTS FOR SESSION
{
o_site = new Site ();
o_site.Load_Customer_Data (s_valid_site);

t = new Thread (new ThreadStart (o_site.CreateSite ));
//the user in o_site.CreateSite is 'ASPNET' user, when it
executes!
t.Start ();
while(!t.IsAlive );

Session["o_site"] = o_site;
Session["o_t"] = t;
}
else//REUSE
{
t = (Thread)Session["o_t"];
o_site = (Site)Session["o_site"];
}
#endregion

Thanks Dudes.
Nov 19 '05 #1
2 1960
Why not make a custom login right

chanmm

"C" <co*******@gmail.com> wrote in message
news:b5**************************@posting.google.c om...
All,

I am trying to run my BO in a separate thread, so that I can give the
user a visual of the status of my process in a asp.net page/site. All
works fine, IF the ASPNET user has admin rights, (in order to do the
tasks in the BO). Now, I impersonate the admin user in the web.config
after removing his admin rights from my machine, then I ran the code
below, in a page_load. The Name of the security principal is the
administrator I have specified in the web.config. However, this
impersonation does not get carried over to new threads, as I have
found out when I am getting the WindowsIdentity in my BO.

(Explained here as well)
http://www.asp.net/whitepaper/aspnet_hosting_public.doc

So, my question is, how do I instantiate a new thread, and assign the
same security context to it, as I have in my AppDomain?

I have tried doing it in my BO, but then again, we need a lot of other
permissions set for the ASPNET user and or change the machine.config,
etc, etc..

Is there any way to cary over my user rights to the new thread t?

Other articles:
http://www.dotnetspider.com/Technology/KBPages/403.aspx
http://support.microsoft.com/default...;en-us;Q306158
http://www.bluevisionsoftware.com/We...=AspNetAccount
http://groups.google.co.uk/groups?hl...TNGP10.phx.gbl

CODE SAMPLE FROM PAGE_LOAD:
//admin user
Response.Write (System.Security.Principal.WindowsIdentity
.GetCurrent().Name );

//SOME CODE...
#region SITE OBJECT & THREAD CREATION
if(Session["o_site"]==null)//CREATES NEW OBJECTS FOR SESSION
{
o_site = new Site ();
o_site.Load_Customer_Data (s_valid_site);

t = new Thread (new ThreadStart (o_site.CreateSite ));
//the user in o_site.CreateSite is 'ASPNET' user, when it
executes!
t.Start ();
while(!t.IsAlive );

Session["o_site"] = o_site;
Session["o_t"] = t;
}
else//REUSE
{
t = (Thread)Session["o_t"];
o_site = (Site)Session["o_site"];
}
#endregion

Thanks Dudes.

Nov 19 '05 #2
when nt (and .net) starts a thread, it get the security token of the
process, not the thread it created. to impersonate the creating thread you
will need to add some code. to do this you will need, to add the
impersonation permission to the asp.net account (off by default), then look
at the win32 calls:

RevertToSelf
DuplicateToken

and the .net call

(new WindowsIdentity(token)).Impersonate()

basically you want to pass the security token of the starting thread to the
started thread. it must be a primary token, use DuplicateToken for this.

-- bruce (sqlwork.com)

"C" <co*******@gmail.com> wrote in message
news:b5**************************@posting.google.c om...
| All,
|
| I am trying to run my BO in a separate thread, so that I can give the
| user a visual of the status of my process in a asp.net page/site. All
| works fine, IF the ASPNET user has admin rights, (in order to do the
| tasks in the BO). Now, I impersonate the admin user in the web.config
| after removing his admin rights from my machine, then I ran the code
| below, in a page_load. The Name of the security principal is the
| administrator I have specified in the web.config. However, this
| impersonation does not get carried over to new threads, as I have
| found out when I am getting the WindowsIdentity in my BO.
|
| (Explained here as well)
| http://www.asp.net/whitepaper/aspnet_hosting_public.doc
|
| So, my question is, how do I instantiate a new thread, and assign the
| same security context to it, as I have in my AppDomain?
|
| I have tried doing it in my BO, but then again, we need a lot of other
| permissions set for the ASPNET user and or change the machine.config,
| etc, etc..
|
| Is there any way to cary over my user rights to the new thread t?
|
| Other articles:
| http://www.dotnetspider.com/Technology/KBPages/403.aspx
| http://support.microsoft.com/default...;en-us;Q306158
|
http://www.bluevisionsoftware.com/We...=AspNetAccount
|
http://groups.google.co.uk/groups?hl...TNGP10.phx.gbl
|
| CODE SAMPLE FROM PAGE_LOAD:
| //admin user
| Response.Write (System.Security.Principal.WindowsIdentity
| .GetCurrent().Name );
|
| //SOME CODE...
| #region SITE OBJECT & THREAD CREATION
| if(Session["o_site"]==null)//CREATES NEW OBJECTS FOR SESSION
| {
| o_site = new Site ();
| o_site.Load_Customer_Data (s_valid_site);
|
| t = new Thread (new ThreadStart (o_site.CreateSite ));
| //the user in o_site.CreateSite is 'ASPNET' user, when it
| executes!
| t.Start ();
| while(!t.IsAlive );
|
| Session["o_site"] = o_site;
| Session["o_t"] = t;
| }
| else//REUSE
| {
| t = (Thread)Session["o_t"];
| o_site = (Site)Session["o_site"];
| }
| #endregion
|
| Thanks Dudes.
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Anil Krishnamurthy | last post by:
We have an ASP.NET application that uses COM objects through Interop. The web application requires access to network and database resources and hence, needs to impersonate a domain account. The...
1
by: techfuzz | last post by:
I'm posting my problem experience and solution I found here for other ASP.NET developers. I have a web application that uses Forms Authentication with Active Directory to control access. In...
27
by: vipleo | last post by:
I am having some issues, when I try to launch another process using Process.Start(ProcessStartInfo psi) on win xp sp2 box (Other versions of xp have no issue). Here is the detail. Main app...
1
by: Patrick | last post by:
I have an ASP.NET web service whose Web.Config is set to use impersonation <authentication mode="Windows" /> <identity impersonate="true" /> Within a Web Method, I want to use...
1
by: Matthias Wohlmann | last post by:
Hi, I've got an ASP.NET Web-Application written in C#. In IIS 6.0 (Windows Server 2003) I have set the application to allow anonymous access, but instead of the default user I use an own...
0
by: Matthias Wohlmann | last post by:
Hi, I already posted to this newsgroup, but didn't get an answer. So I try again: I've got an ASP.NET Web-Application written in C#. In IIS 6.0 (Windows Server 2003) I have set the application...
4
by: David Cablalero | last post by:
I have a windows service which every night checks a SQL Server database for some data and business rules. The application can access different DBs with the same structure, to tell the service which...
8
by: Marco Mechelli | last post by:
Hello, i'm facing with the following problem while using the Job API during an impersonation. I have a main process that needs to do the following: 1. Creates a new Job Object that will be...
0
by: Daniel Knöpfel | last post by:
Hello On our asp.net 2.0 website we impersonate every request to the identity of the user logged in. This works this way: 1. user logs in, providing username, password 2. user is authenticated...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...

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.