Is it possible, in Java, to authenticate a user over active directory and then perform tasks that user has permissions for?
I have a java app that is running as a service on a server.
The service is running as the local system user. Which does not have access to folder XYZ
However, let's say there is a user, who does have access to folder XYZ. Is it possible for this user to somehow login through the java app, thus giving the app permissi开发者_JAVA百科on to access the folder?
The network revolves around active directory.
not really... the app while its running has only the privilege of the user account that started it..
now if you want to do some activity as a different user (when you have his/her credentials) you can start a new process & do the activity in it.
on windows you can say runas /user:<<username>> <<command to run>>
. again this requires sufficient privilege to execute the runas
command & the runas service must be running.
you could also try to start another instance of your app (but I wouldn't recommend this)
If you can install the server as a Windows service then you can chose the user that will be used to run the server. If you chose the user to be one that has access to the required folder, then your app will also have access to the folder.
On the run command or command prompt, run services.msc. Look at the 'Log On As' column of the services. 'Log On As' is set to 'Local system' by default. If you right-click the service and go to its properties, the Log On tab will have an option to start the service under any user that you desire.
As for install a new windows service to automatically start your server with, try http://wsinnovations.com/softeng/support/manualservice.html
精彩评论