Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Running a function as a specific user account.

Posted on 2005-04-14
3
Medium Priority
?
136 Views
Last Modified: 2010-04-07
I suspect the answer to this problem is no, however here it is.

Is there any way to run a specific function of code under a specified user account? I have an asp application (intranet) that uses the Integrated security method. ie if MyDomain\UserA is the owner of the browser, then MyDomain\UserA is the account that runs the code.

I have a page that need to use the current user for most of the code, however one function on that page needs to use a specific user account to get the job done.  I need to know how to run the page under integrated security, and yet run the one function as Mydomain\Superuser.

A web config file in folder wont do it, as it changes the security method for the entire page. So I am looking for a line(s) of code that can be contained within my function to swap the user

I need something like:-

CurrentUser.Name="MyDomain\Superuser"
Currentuser.Password="abc12345"

{execute code that needs new security access}

CurrentUser.Name= {Integrated user etc}

{rest of code that needs current user permissions now runs}
Can this be done?
0
Comment
Question by:CaptainRantflaps
1 Comment
 
LVL 20

Accepted Solution

by:
ihenry earned 500 total points
ID: 13780391
Yes, impersonation is the answer. However, depends on operating system on where your code is running; you'd need to set some security settings. This is best sample code I've seen so far:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecurityprincipalwindowsimpersonationcontextclasstopic.asp
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question