Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Copy Credentials for a worker thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maa - 10 Feb 2008 00:46 GMT
In my web app I am creating threads to do work.  I want to give the same
rights as my main asp.net thread.  The default is to give lesser rights so
when I access the db I get a log on failure with a trusted connection or a
user name/password.  
What is the std way to copy credentials in asp.net?

Thanks,
maa
Phil Johnson - 10 Feb 2008 09:51 GMT
Go to this article...

http://msdn2.microsoft.com/en-us/library/ms998258.aspx#pagguidelines0001_imperso
nationdelegation


and go to a section about two thirds down called ...

Avoid Losing Impersonation Tokens

I think it is exactly what you are after.

Hope that helps.

Signature

Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com

> In my web app I am creating threads to do work.  I want to give the same
> rights as my main asp.net thread.  The default is to give lesser rights so
[quoted text clipped - 4 lines]
> Thanks,
> maa
S. Justin Gengo - 10 Feb 2008 13:12 GMT
maa,

I think this will take care of what you're looking for. It's an excerpt from
the MSDN article found here:
http://support.microsoft.com/kb/306158

Impersonate the Authenticating User in Code
To impersonate the authenticating user (User.Identity) only when you run a
particular section of code, you can use the code to follow. This method
requires that the authenticating user identity is of type WindowsIdentity.

Visual Basic .NET
Dim impersonationContext As
System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity

currentWindowsIdentity = CType(User.Identity,
System.Security.Principal.WindowsIdentity)
impersonationContext = currentWindowsIdentity.Impersonate()

'Insert your code that runs under the security context of the authenticating
user here.

impersonationContext.Undo()

Visual C# .NET
System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext =
   ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();

//Insert your code that runs under the security context of the
authenticating user here.

impersonationContext.Undo();

Regards,

S. Justin Gengo, MCP

Free code and component libraries at:
http://www.aboutfortunate.com

> In my web app I am creating threads to do work.  I want to give the same
> rights as my main asp.net thread.  The default is to give lesser rights so
[quoted text clipped - 4 lines]
> Thanks,
> maa

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.