473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running a section of code under a specific account

Hi all

I’m trying to write a file to a different sever on the same domain then the server hosting the site, but the IIS user does not have access to the other server. I thought I would use impersonation to force the specific code to impersonate a user that does have the necessary permission with the code bellow. Unfortunately This code results in an "Unable to Logon" error as the System.Security.Principal.WindowsIdentity constructor expects a Windows account token and I been unable to determine how to do this Any ideas on how to achieve this?

Private Sub PerformTask(
Dim sUsers As String = "
Dim objImpersonatedIdentity As New System.Security.Principal.WindowsIdentity("Bill"
Dim MyImpersonation As System.Security.Principal.WindowsImpersonationCont ext = objImpersonatedIdentity.Impersonat
sUsers = objImpersonatedIdentity.Name(
MyImpersonation.Undo(
lblOutPut.Text = sUser
End Su

Thanks in advanc

Jak
Nov 18 '05 #1
1 897
Hi, Jake,

Try the code examples in this article:

http://support.microsoft.com/?kbid=306158

Greetings
Martin
"Jake" <an*******@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
Hi all,

I’m trying to write a file to a different sever on the same domain then the server hosting the site, but the IIS user does not have access to the
other server. I thought I would use impersonation to force the specific
code to impersonate a user that does have the necessary permission with the
code bellow. Unfortunately This code results in an "Unable to Logon" error
as the System.Security.Principal.WindowsIdentity constructor expects a
Windows account token and I been unable to determine how to do this Any
ideas on how to achieve this?
Private Sub PerformTask()
Dim sUsers As String = ""
Dim objImpersonatedIdentity As New System.Security.Principal.WindowsIdentity("Bill") Dim MyImpersonation As System.Security.Principal.WindowsImpersonationCont ext =
objImpersonatedIdentity.Impersonate sUsers = objImpersonatedIdentity.Name()
MyImpersonation.Undo()
lblOutPut.Text = sUsers
End Sub

Thanks in advance

Jake


Nov 18 '05 #2

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

Similar topics

3
1382
by: CES | last post by:
All, I was wondering is their a way of accessing/running .aspx pages that live above the web root. An example would webserver Account\Webroot1\default.aspx webserver...
2
1171
by: chortler | last post by:
I've changed bit in the processmodel section in the machine.config file, so that the aspnet_wp process runs under this new account (See below) I've run IISREST and now visual studio wouldn't allow...
0
918
by: mgonzales3 | last post by:
In 1.1 I was able to change the processmodel section in the machine.config to have the worker process run under that specific domain account. (Q315158). I'm using 2.0 now and am unable to do the...
60
4809
by: harshal | last post by:
Hi all, Can we read the stack frame's of the current process. as we know that whenever a function call is made in c new functions stack frame is created and pushed on to the stack. and when the...
0
7225
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,...
1
7042
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
5627
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,...
1
5052
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...
0
4707
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...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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...

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.