473,499 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with Thread Impersonation

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
windows-user account. That account does not have too much rights (just
access to the application directory and the windows\Microsoft.Net
directory). In Web.config I have also set
<identity impersonate="true" userName=<myUser> password=<myPWD>/>

Everything works fine exept for this:
In my application, I start a thread. I know that impersonation is not
taken over by the thread so I copy the current impersonation by

System.IntPtr windowsIdentityToken;
System.IntPtr newToken = System.IntPtr.Zero;
WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
DuplicateToken(currentIdentity.Token, 2, ref newToken);
this.windowsIdentityToken = newToken;

and inside the thread I re-impersonate with:

WindowsImpersonationContext impersonatedUser =
WindowsIdentity.Impersonate(this.windowsIdentityTo ken);

After that, acces to files inside the thread is working, but two things
don't work:

- Sending Mails: I get this error:
System.Web.HttpException: Could not create 'CDO.Message' object.
on Command:
System.Web.Mail.SmtpMail.Send(msg);

- I also use encryption inside the thread. Command
SymmetricAlgorithm symm = new TripleDESCryptoServiceProvider();
leads to Exception:
System.Security.Cryptography.CryptographicExceptio n: Cryptographic
service provider (CSP) could not be found for this algorithm.

If I don't impersonate the thread by commenting out
//WindowsImpersonationContext impersonatedUser =
WindowsIdentity.Impersonate(this.windowsIdentityTo ken);
both commands work, but the thread can't access some files I need.

does anyone have an idea?

Thanks,
matthias

Feb 22 '06 #1
0 1038

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

Similar topics

2
1961
by: C | last post by:
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,...
2
1476
by: Sharon | last post by:
Hi to all. I have two Impersonation problems: 1. When using my app. from a remote computer, the aspx page is unable to get information from Active Directory. I am using Impersonation, and the...
26
870
by: andrew_webby at hotmail | last post by:
Hi Am having a problem with an app I wrote to test patch delivery. I contact a remote PC, and get it to run a patch which is installed on a server. It works fine if I use psexec for example and...
1
8100
by: Duffman | last post by:
Hi, I have what seems to be a common problem, but the solutions I've found don't seem to work. I would like to use a web service to create a file at a UNC location in a shared file. Currently...
2
5220
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
1218
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
948
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...
0
1506
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...
5
5728
by: Brian | last post by:
I have an file based asp.net application the creates a thread to do some background printing. It works fine but when the application is deployed on a web server, the following error occurs in the...
4
2312
by: =?iso-8859-1?q?Eir=EDkur_Fannar_Torfason?= | last post by:
I'm wrestling with a problem that I'm hoping someone can help me with. I have a web application written in VS.2003 and running on version 1.1 of the .NET Framework on XP pro and Windows server...
0
7134
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
7014
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
7180
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
7229
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
4609
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
3108
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
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.