Manually specifying an owner for invoked application

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Manually specifying an owner for invoked application

Postby 137th Gebirg » 11. January 2008 16:11

Hello, all:

This may be more of a Windows-centric question, but I figured this could be a good place to ask.

I'm trying to remotely invoke an instance of a Windows application from a PHP file running on Apache. I have successfully done this, but it has a curious side-effect. Normally, when a user invokes an application from the desktop, the user name assigned to the application (that you can see in the Windows Task Manager) is the user name currently logged in. However, if the same app is called up via PHP through Apache (or any other web service, I figure), the user name assigned to it is going to be either "SYSTEM" or "LOCAL SERVICE". This has WSW access a completely different set of preferences stored in the "C:\Documents and Settings\LocalService\Application Data\" directory rather than the user's personal preferences directory like "C:\Documents and Settings\John Smith\Application Data\". This can become confusing for users, as all preferences and other application settings will be different.

So, my question is this - is there some command-line option that I can specify in the PHP code that will force the application to be "owned" by the user currently logged in, rather than "SYSTEM" or "LOCAL SERVICE", preserving preferences and settings integrity on a user-by-user basis?

Additionally, if there is a way of specifying an owner on the command line, is there a system variable like "$CURRENT_USER" or something to that effect that the operating system will know which user is currently online?

Any assistance greatly appreciated.
137th Gebirg
 
Posts: 14
Joined: 07. December 2007 16:21

Re: Manually specifying an owner for invoked application

Postby Scory » 11. January 2008 16:59

137th Gebirg wrote:So, my question is this - is there some command-line option that I can specify in the PHP code that will force the application to be "owned" by the user currently logged in, rather than "SYSTEM" or "LOCAL SERVICE", preserving preferences and settings integrity on a user-by-user basis?


No, there is not. Once started, you cannot change the owner of the process.

But you can solve it anyway: the reason for the user being "SYSTEM" or "LOCAL SERVICE" is due to starting apache as a "Windows Service" on startup.

If you don't do so (remove the service from the list of services or disable it), you may start apache manually AFTER you have logged in. Simple call "apache.exe" from the apache\bin folder. The process "Apache" is then running as user "blabla" (your userid) and not as user "SYSTEM".

If you dont like to start Apache manually, you may add an appropriate entry to the Autostart Folder of your personal Explorer - then, Apache will also run with your userid instead of SYSTEM.

Simply avoid running Apache as a Service - that's it.

Regards
Scory
Scory
 

Postby 137th Gebirg » 11. January 2008 19:21

Interesting idea. Hadn't thought of that one. Thank you!

This brings to mind a follow up question, though:

If there are multiple users on the server, and I have an auto-start for Apache, will there then be multiple instances of Apache running for each user logged in and, if so, does that wreak havoc over which one has ownership of port 80 on the same machine, or does it automagically reconcile who's using which instance?
137th Gebirg
 
Posts: 14
Joined: 07. December 2007 16:21

Postby Scory » 11. January 2008 22:31

>If there are multiple users on the server, and I have an auto-start for Apache, will there then be multiple instances of Apache running for each user logged in and,

I've never heard about a Windows PC which runs several users (with several monitors etc.) at one time. Do you have such a thing? I dont know anybody running a real multi-user-Windows.
Scory
 

Postby 137th Gebirg » 11. January 2008 22:44

The idea is to have what I'm developing all running on a Windows 2003 server, which people will be logging into via Remote Desktop Connection. This will have multiple users running multiple instances of the applications in question, along with the web components managed by Apache. The laptops that people use to remotely log into the server with via RDC will be nothing more than expensive dumb terminals, for lack of a better word. It's not your typical kind of set up, but is required for what I've been asked to put together.
137th Gebirg
 
Posts: 14
Joined: 07. December 2007 16:21

Postby 137th Gebirg » 04. February 2008 19:44

Update: Tried having PHP call a shortcut to the application with "Run with different credentials" set under Advanced Shortcut properties. This will allow the app to run as if owned by the user. It kind of works, but the application then can't find any of its preferences and crashes. Any other ideas out there?
137th Gebirg
 
Posts: 14
Joined: 07. December 2007 16:21

remotely invoke an instance of a Windows application

Postby jackygrahamez » 15. February 2008 18:48

I'm trying to remotely invoke an instance of a Windows application


How exactly are you doing that? I want to make a google earth display which hosts a WAMP. Users sign in at the entrance to our museum. It update the Google KML data file and invokes google earth on the display.

I had it working with a bunch of vbscripts, but someone broke into the museum and stole the laptop. So I thought I would find a better solution.
jackygrahamez
 
Posts: 1
Joined: 15. February 2008 18:27
Location: Washington, DC

Postby 137th Gebirg » 15. February 2008 19:08

I was trying to use a command-line function such as "runas", "start" or some other equivalent third-party command to invoke an application via PHP/Apache so that the system would know which user was running the app. This tells the app which profile to use in the "Documents & Settings" directory. Unfortunately, Apahce runs as "Local Service" and all subsequent app calls are also attributed to "Local Service" and will ignore any other user-specific preferences that may have been saved as if the app was invoked through the Desktop or Start menu. "Local Service" has its own properties and preferences.

If you don't care about which user is running Google Earth, it should be just as simple as executing

"start C:\dirname\filename.exe"

In PHP, the command would look like this:

pclose(popen('start C:\\dirname\\filename.exe', 'r'));

This will make sure that any shell that is opened by Apache on the back-end will be closed after execution of the "start" command. Just a simple house-cleaning procedure.

Make sure that, if you're running Apache, that you go into the properties of your Apache service that's running, click the "Log On" tab and turn the "Allow service to interact with desktop" checkbox on so that the server can tell the operating system that it needs control over Windows applications. If you don't check this box, the app will start, but only run in the background without ever actually opening any window.
137th Gebirg
 
Posts: 14
Joined: 07. December 2007 16:21


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 47 guests