473,404 Members | 2,213 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,404 software developers and data experts.

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 1036

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

Similar topics

2
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
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
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
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
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...
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...
5
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.