473,385 Members | 2,013 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,385 software developers and data experts.

Run with Administrator Credentials

JM
Hi

Is there a way to invoke an external program in C# with Administrator
credentials? You know run an external VBS or batch?

Any reference material would be useful.

TIA
Nov 17 '05 #1
3 2856

"JM" <JM@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi

Is there a way to invoke an external program in C# with Administrator
credentials? You know run an external VBS or batch?

Any reference material would be useful.

TIA


Yes, there is, you have to call Win32's CreateProcessWithLogonW using
PInvoke., or wait for v2.0 of the framework.
Note that this won't work when called from a service.

Willy.
Nov 17 '05 #2
Check out WindowsIdentity class in System.Security.Principal.

There is an Impersonate() method that will do what you are trying to
accomplish. The missing link with this class is that you have to obtain an
access token handle to use it. The only way I know of doing this is by
pinvoking one of the Win32 security functions like LogonUser().

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"JM" <JM@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi

Is there a way to invoke an external program in C# with Administrator
credentials? You know run an external VBS or batch?

Any reference material would be useful.

TIA

Nov 17 '05 #3

"Ken Varn" <nospam> wrote in message
news:Oz**************@TK2MSFTNGP15.phx.gbl...
Check out WindowsIdentity class in System.Security.Principal.

There is an Impersonate() method that will do what you are trying to
accomplish. The missing link with this class is that you have to obtain
an
access token handle to use it. The only way I know of doing this is by
pinvoking one of the Win32 security functions like LogonUser().

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

Ken,

No it won't. OP's needs to spawn another process that must run as
administrator.
When creating a process from an impersonating thread, the process will use
the callers PROCESS identity, not the impersonating thread's identity.

Willy.
Nov 17 '05 #4

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

Similar topics

0
by: mdh | last post by:
I have an application written for mod_perl and Apache that needs to be able to send some XML queries to a WebMethods server for access to corporate systems. I have been attempting to use LWP to...
2
by: Angelo Vargheese | last post by:
Hi, I am trying to retrieve XML created by ASP pages on different servers and display them on a single ASP.Net page. I was planning to use the XMLDocument and XMLResolver objects like below: ...
4
by: Grind Boy | last post by:
Hi, I'm writing this off the top of my head as I don't have the exact information to hand. We are attempting to set up a secure internet site using ASP.NET on IIS5. We are having some...
2
by: cindy.fisher | last post by:
I am using DownloadFile() on a C# web app to download a file to a client. When I set the WebClient credentials to the DefaultCredentials, I get a 401 Unauthorized exception. WebClient myWC = new...
3
by: Wild Wind | last post by:
Hello, I have an application which calls a web service across the Internet from a client machine. The site that I have deployed the application to is such that to browse the Internet using a...
0
by: Eagle | last post by:
Hi all. I want to known if it is possible to pass the Credentials (user and pass basicly) from one user I has validated in my intranet to another aplication (for example to an object who can...
5
by: =?Utf-8?B?SmltbWVy?= | last post by:
Hello, I've been trying to create a WCF SOAP Router Service that can forward not just the message body but also any security headers set by the originator of the message. The destination service...
5
by: idoha | last post by:
Hi, I am trying to write a script that kills processes that generated by the OS on a localhost. The problem is that this script must be run under a user with administrator privileges, otheriwse...
5
by: nagar | last post by:
I'm using the Process.Start method to launch an application from C#. How can I launch the App as Administrator in Windows Vista? Thanks. Andrea
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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.