473,385 Members | 1,838 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,385 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
1 1217
Sorry for posting four times, I had problems with my mail-client...

matthias
Feb 22 '06 #2

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...
0
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.