How to run an application in User B from user A - web-services

I have a REST endpoint (developed with spring mvc) on windows server that has more than one user, tomcat instance is running under admin user, from that user I need to start an application in another user under the same server, can I do that using CMD command somehow?
so, Admin will receive REST request, and based on the parameters given, REST endpoint will run an application ( notepad as example ) in another user under the same server.
I hope that my question is clear.
what I was thinking to do is, to start tomcat instance under all the users and deploy web services that can handle this request, but it will be easier for me to use CMD command instead, but I have no idea about administrations.
in short, from user A, I need to start notepad.exe in user B.

Related

How to access currently logged in user information from a c++ program which is running as service?

I am able to retrieve currently logged in user information through my C++ program which is running in IDE. After I changed it into service and try to get the information, I couldn't. What is the issue with that?
When you run desktop application, that is not as a service, it runs under the user you are logged in as.
When your program is running as a service, it defaults to be running using the LocalSystem user.
If you want to run as another user, you need to specify it using the lpServiceStartName argument in the CreateService call.

Django - How can you execute a process as a user other than the apache user

I have a django web server which allows users to run jobs/tasks on our server. When a job is run from the web application, it is run as the www-data user. We would like the jobs to be run as the actual logged in user. To do this, we would obviously need to authenticate against the linux authentication system so that the users can log in with their server credentials and then we would need to somehow make all tasks run by that user run as their user on the server and not the www-data user. Is there a way to do this, possibly using ldap authentication?
We are using the Django web framework on Ubuntu 12.04. The web server is hosted with Apache2. The web server will be run on a local network and not be accessible from outside our building.
I know my answer might not satisfy all of your needs and it's not very fast to implement, but I was thinking that in your Django app you could send a Linux su - your_user command (which would set the correct Linux user based on the currently logged in Django user) using Python's subprocess and then, still using subprocess, call the jobs/tasks which need to be executed.
Subprocess: https://docs.python.org/3.4/library/subprocess.html
EDIT: you can also have a look at Pexpect https://github.com/pexpect/pexpect

Mini Filter driver communication with windows service

I am creating a mini-filter driver. In that i communicate with user mode application to get the some of the data form user. i communicate with user mode using "communication port". i tried to communicate with user mode application it worked fine.
One the suggestion i got form others is to use windows service to fetch the data since it will always be running and we want user mode application to run always.
My question is
1) Can i create "communication port" in windows service?
2) If i create windows service, how to get specific user information. i mean, when i send the request to service how service come to know from which user session data needs to be fetched?
3) which one is better, i mean user mode or windows service is better solution.
1) Can i create "communication port" in windows service?
Yes you can create it in service.
2) If i create windows service, how to get specific user information. i mean, when i send the request to service how service come to know from which user session data needs to be fetched?
Service does runs under system account and not under any logged in user. So to show popup or dialog to current logged in user, you can look at WTSGetActiveConsoleSessionId() or similar api to get console session.
3) which one is better, i mean user mode or windows service is better solution.
Depends upon your design. As you mentioned service is always running to if your driver depends upon such requirement then do with service. But it will take more efforts to actually interact with user.
But if your driver can work without any service/app connection as such then go with application.

How to use same User state across multiple WCF services

I have a WCF web service that uses FormsAuthentication that logs the User into the Silverlight website. I have another web-service that needs to know what Role the user is in (e.g. Admin, User, Guest) to determine which functions that will run when called by the user from the Silverlight.
How can I pass this session state / User to the 2nd WCF web-service, or how can I get the username/password in the Silverlight application, and then pass that to the web-service to re-authenticate?
After doing research into this, the eastiest thing appears to be have some methods in my first web service where the user logs in. From there I can check what roles they are in and if they are authenticated. If anyone has a better idea I'm eager to hear it.

AppHarbor: Communication between Web App and Background Worker

I have two questions, but let me set the stage first:
Say you have a typical scenario where you have a web application and a mid-tier web service.
The web application receives a request from the user, queries the web service and sends a response to the user.
If the web service and the web application were running on the same machine, the web app would go through localhost:port to access the web service.
(I do understand that AppHarbor web and background workers are not running on traditional machines but it's easier to use that metaphor)
To make this slightly complex, the web service is actually a console app running a HTTP server and thus acting as a web service, let's call it webservice.exe.
My first question is: will AppHarbor run webservice.exe on the same machine as the web application and so enable the web application to access the web service via localhost:port.
If not, will the machine name where the console app is running always be static (which allows web app to reliably access machinename:port). If so, will the webservice.exe machine allow incoming connections from the web application machine?
My second question is if both apps run on the same machine (the localhost scenario), will external users be able to access webservice.exe via myapp.apphb.com:port ?
Thanks!!
AppHarbor does not currently support background workers (which is where your console application would be running) attaching to ports.
If you instead decide to host the service in an ASP.NET application and run it in a web worker on AppHarbor (as a normal web site), then it would be available at myawesomeapplication.apphb.com or using a custom hostname if you decide to add one.
If the service-abstraction is not needed, you might also want to just do away with it and fold it into the main web site.