473,386 Members | 1,720 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,386 software developers and data experts.

Run code under diffrent user

I have some code that I want to run under another user. I know his password.

I want the vb.net code in my program to strart under under that user and not
start an external program.

This because the application will run as a windows service and I cannot
start an exe from a service that runs under user account with administrator
rights. The service cannot run under localsystem because it also havs to
create users and add them to administrators group.
Jan 18 '06 #1
3 6976
"Philip Wagenaar" <ph*************@online.nospam> schrieb:
I have some code that I want to run under another user. I know his
password.


Impersonation:

..NET 1.0/1.1:

<URL:http://www.codeproject.com/csharp/RunAs.asp>
<URL:http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/msg/6a4c72eca2f437a4>

..NET 2.0:

<URL:http://msdn2.microsoft.com/en-us/library/bbthyk23(en-US,VS.80).aspx>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 19 '06 #2
this requires a filename of the application you want to start.

I do not want to start another application, I want part of my code to run
under a diffrent useraccount. This is because of the application is running
as a windows service.

"Herfried K. Wagner [MVP]" wrote:
"Philip Wagenaar" <ph*************@online.nospam> schrieb:
I have some code that I want to run under another user. I know his
password.


Impersonation:

..NET 1.0/1.1:

<URL:http://www.codeproject.com/csharp/RunAs.asp>
<URL:http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/msg/6a4c72eca2f437a4>

..NET 2.0:

<URL:http://msdn2.microsoft.com/en-us/library/bbthyk23(en-US,VS.80).aspx>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 19 '06 #3
Hi Philip,

From you description, I understand that you want to run some codes in your
VB.NET Windows Service application under another user account.

If I misunderstood, please feel free to let me know.

Based on my research, we can call the LogonUser API to get the user's
security token. In Whidbey, the WindowsImpersonationContext will use the
security token to set the current thread under that user's security context.

Here are some links for your reference.
How to Impersonate
http://blogs.msdn.com/shawnfa/archiv...21/400088.aspx

How To: Use Impersonation and Delegation in ASP.NET 2.0
http://msdn.microsoft.com/library/de...us/dnpag2/html
/paght000023.asp

Please try this and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Jan 19 '06 #4

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

Similar topics

1
by: Ricky K. Rasmussen | last post by:
Hello NG, I'm having some encoding trouble using my own RequestHandler: Since the RequestHandler must be able to serve content with diffrent encoding, I set the Response.Charset and...
2
by: yatharth | last post by:
I am facing a problem ,the situation is like this. I have a home page named "Index.html" ,on which there is login link,when i click on the login link the login popup opens and user enter the...
1
by: Joe Harrison | last post by:
Hello. I am having problems connecting ASP.NET to an Access Database. The Access Database is on one computer (ALPHA) and the web server is on another computer (BETA). I realize that the reason...
1
by: chiranjiv choudhary via .NET 247 | last post by:
Can we have CodeBehind file in another server or same machine but diffrent location or directory -------------------------------- From: chiranjiv choudhary ----------------------- Posted by a...
3
by: anders | last post by:
Hi! On my work we have a lot off diffrent server to make software for diffrent os from Windows, OS/X to Linux Solaris Everyting is scripted with shell, but Windows has batchfiles witch is...
1
by: lawardy | last post by:
Hi, I'm quite new with Reporting server 2005. I'm wondering if there is a way to write a select query that will get the data from 2 diffrent tables located in 2 diffrent database box. for...
0
by: jesper_lofgren | last post by:
Hi, I have a custom build provider that gets data from a webservice. I have the XMLFeedUrl as a config parameter on the provider, my question is... If i need to get xmlfeeds from two...
6
by: ambeer | last post by:
Hello everybody, so i need some hints where to start at... i want to create website, which generates some text, for example everyday this text will be diffrent... and i need to provide some...
1
by: krikaran adel | last post by:
Hi, First of all I found your tips very usfull, of course these tips becuas of all years working in access. really greet site. my Quation: is this away to change fonts in reports so the...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.