473,662 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run process under diffrent user

Framework 1.1

I want to start AcrobatReader to print a printjob under a specific username
(so that the owner of the printjob is not the username of the application
that the .net application runs under).

So how can I start a process under another user? The password of the user is
known. (I already have code to create user if needed)

If this can be done easier in Framework 2.0 I can switch to that, but it
would be my first 2.0 app so if it can be done with as much easy, or trouble,
then I'd prefer 1.1.
Dec 8 '05 #1
3 6006
"Philip Wagenaar" <ph************ *@online.nospam > schrieb:
I want to start AcrobatReader to print a printjob under a specific
username
(so that the owner of the printjob is not the username of the application
that the .net application runs under).

So how can I start a process under another user? The password of the user
is
known. (I already have code to create user if needed)

If this can be done easier in Framework 2.0 I can switch to that, but it
would be my first 2.0 app so if it can be done with as much easy, or
trouble,
then I'd prefer 1.1.


..NET 1.0/1.1 doesn't provide managed support to do that.

In .NET 2.0 you can use the 'Process' class:

..NET Framework Class Library -- 'ProcessStartIn fo.UserName' Property
<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/>

Dec 8 '05 #2
Hey Philip,

I think Herfried's suggestion are reasonable. For .NET 1.X, we have to use
unmanaged API to start process running under a specfic user... In .net
2.0 the new ProcessStartInf o has been modified to support specific user
credentials to start a new process under that specified account.... E.G:
=============== ===============
Sub StartNewProcess ()

Dim psi As New ProcessStartInf o("notepad.exe" )
psi.Domain = "machinenam e"
psi.UserName = "username"
Dim sstr As New System.Security .SecureString
Dim pwd As String = "Password01 !"

Dim chars() As Char = pwd.ToCharArray ()

Dim i As Integer

For i = 0 To chars.Length - 1
sstr.AppendChar (chars(i))
Next

psi.Password = sstr
psi.UseShellExe cute = False

Process.Start(p si)

Console.WriteLi ne("Sub Process started........ ...")

Console.ReadLin e()
End Sub
=============== ===============

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Herfried K. Wagner [MVP]" <hi************ ***@gmx.at>
| References: <8F************ *************** *******@microso ft.com>
| Subject: Re: Run process under diffrent user
| Date: Thu, 8 Dec 2005 12:56:55 +0100
| Lines: 27
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="Utf-8";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <uB************ *@TK2MSFTNGP14. phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.langua ges.vb
| NNTP-Posting-Host: v208-105.vps.tuwien. ac.at 128.131.208.105
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl microsoft.publi c.dotnet.langua ges.vb:307728
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb
|
| "Philip Wagenaar" <ph************ *@online.nospam > schrieb:
| > I want to start AcrobatReader to print a printjob under a specific
| > username
| > (so that the owner of the printjob is not the username of the
application
| > that the .net application runs under).
| >
| > So how can I start a process under another user? The password of the
user
| > is
| > known. (I already have code to create user if needed)
| >
| > If this can be done easier in Framework 2.0 I can switch to that, but it
| > would be my first 2.0 app so if it can be done with as much easy, or
| > trouble,
| > then I'd prefer 1.1.
|
| .NET 1.0/1.1 doesn't provide managed support to do that.
|
| In .NET 2.0 you can use the 'Process' class:
|
| .NET Framework Class Library -- 'ProcessStartIn fo.UserName' Property
| <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/>
|
|

Dec 9 '05 #3
"Steven Cheng[MSFT]" <st*****@online .microsoft.com> schrieb:
I think Herfried's suggestion are reasonable. For .NET 1.X, we have to use
unmanaged API to start process running under a specfic user...


Sample:

<URL:http://www.gssg.de/net_impersonate .htm>

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

Dec 9 '05 #4

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

Similar topics

2
2605
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 login information in it. Now when the user click the submit button then new popup window
1
1173
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 user from .NET 247 (http://www.dotnet247.com/) <Id>8svNZUU0T0eArey2uATMWw==</Id>
11
1290
by: Brian Henry | last post by:
Hi everyone, What I am doing in my application is I have a base app, then a bunch of plug-in dll files. Well this gets confuseing to diferentiate between the real plug-ins and the actual link libraries that are not to be used as plugins (in reality they are both DLL files) is there anyway I could make VS.NET compile my VB.NET DLL plug-in projects into a diffrent extension but still be DLL files? (i dont feel like changeing tens of...
8
6731
by: Philip Wagenaar | last post by:
I need to send printjobs to a printqueue under diffrent usernames. The printsoftware on the queue is not very 'secure' so I can create a user on 1 system and send a printjob under it's name to the printqueue. This is why I created a program that picks the username out for the .PRN file, creates a local user, copies the PRN file the network printer and deletes the user. I cannot get it to work. I tried first copying a normal text file...
3
6985
by: Philip Wagenaar | last post by:
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...
1
19919
by: ABCL | last post by:
Hi All, I am working on the situation where 2 different Process/Application(.net) tries to open file at the same time....Or one process is updating the file and another process tries to access it, it throws an exception. How to solave this problem? So second process can wait until first process completes its processing on the file. Thanks in advance
3
1180
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 very limited, compared to cshell etc. So my boss has told me that it okej if i want to make somting better
1
2188
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 example select * from employee where category in (select * from category);
1
1531
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 same field in diffrent record could have diffrent font.
0
8343
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
8856
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...
0
8762
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6185
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
5653
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();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
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.