473,624 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Still Problems with Thread Impersonation

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 to allow
anonymous access (using the default Account IUSR_<servernam e>). In
Web.config I have set
<identity impersonate="tr ue" userName=<myUse r> 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 windowsIdentity Token;
System.IntPtr newToken = System.IntPtr.Z ero;
WindowsIdentity currentIdentity = WindowsIdentity .GetCurrent();
DuplicateToken( currentIdentity .Token, 2, ref newToken);
this.windowsIde ntityToken = newToken;

and inside the thread I re-impersonate with:

WindowsImperson ationContext impersonatedUse r =
WindowsIdentity .Impersonate(th is.windowsIdent ityToken);

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

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

- I also use encryption inside the thread. Command
SymmetricAlgori thm symm = new TripleDESCrypto ServiceProvider ();
leads to Exception:
System.Security .Cryptography.C ryptographicExc eption: Cryptographic
service provider (CSP) could not be found for this algorithm.

- Other accesses of COM-Objects also don't work...

If I don't impersonate the thread by commenting out
//WindowsImperson ationContext impersonatedUse r =
WindowsIdentity .Impersonate(th is.windowsIdent ityToken);
both commands work, but the thread can't access some files I need.

does anyone have any idea?

Thanks,
matthias
Feb 24 '06 #1
0 958

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

Similar topics

2
2254
by: Mong | last post by:
Hi all, Well I reckon I've just read through 200 messages on this subject and tried every combination of every setting the is and I'm still getting a return of false on IsInRole. Here's my code: Dim rolUI_Admin as String Dim wp As WindowsPrincipal rolUI_Admin = "DOMAIN/DOM_ACL_TestAdmins"
2
1975
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, (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...
2
1490
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 Impersonated user is logged to the domain. When I'm doing the same, logged as the same user, but on the server computer, it works.
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 I know it's not NTFS/share-level security at fault - it's readable to everyone which is usually enough for scheduler or any other usually-not-network-user to reach it. I've checked my credentials in my remote session and it says it's
1
8121
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 I'm just running it locally and saving the file locally using my machines UNC path. I have given user ASPNET full control over the folder I want to write the file to. I've also tried using the web config identity impersonation to use my user...
1
1233
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 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>/> ...
0
1512
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 against an active directory and the windows identity is retrieved (and stored in the session!!) 3. user is impersonated using the windows identity (thread is now running under the identity of the user)
5
5741
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 thread when it accesses SQL: Login failed for user ''. The user is not associated with a trusted SQL Server connection. Note the blank user. It seems that the new thread does not have the credentials but looking at "Thread.CurrentPrincipal",...
4
2322
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 2003 that connects to a SQL server database and authenticates itself using windows authentication. The web application is configured to impersonate a local user account that has been granted access to the database. Here's the impersonation snip...
0
8242
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7170
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.