You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by nitin403 <ni...@gmail.com> on 2007/12/10 06:57:46 UTC

How to specify windows user in runtime in tomcat?

Hi, all.
I have create a servlet which needs to read a file on a share folder.
When I run tomcat service as anonymous it is not able to access read this
file.
But when I run tomcat service as a user who as access to this file, then it
runs fine.

My Question is, is it possible to something similar to this in servlet code
at run time for running the servlet in tomcat.

Thanks for your help in advance.
-- 
View this message in context: http://www.nabble.com/How-to-specify-windows-user-in-runtime-in-tomcat--tp14247742p14247742.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to specify windows user in runtime in tomcat?

Posted by nitin403 <ni...@gmail.com>.
Thanks for your help.
I will try JCIFS.
Your are correct about using a dedicated account.
But on the tomcat server which I am deploying the servlet, has other
servlets and It is not feasible for me to change its access rights.

Once again thanks a lot.


br1 wrote:
> 
> You can try with jcifs (http://jcifs.samba.org/).
> It should allow you to access a remote share using a different user
> context, though I'd reccommend using a dedicated account for this kind of
> job. 
> 
> Hope it helps,
> b.
> 
> 
> nitin403 wrote:
>> 
>> 
>> 
>> Juha Laiho wrote:
>>> 
>>> nitin403 wrote:
>>>> I have create a servlet which needs to read a file on a share folder.
>>>> When I run tomcat service as anonymous it is not able to access read
>>>> this
>>>> file.
>>>> But when I run tomcat service as a user who as access to this file,
>>>> then it
>>>> runs fine.
>>>> 
>>>> My Question is, is it possible to something similar to this in servlet
>>>> code
>>>> at run time for running the servlet in tomcat.
>>> 
>>> No, you can't change Tomcat user at runtime. What you can do is to
>>> run Tomcat as a specific user, and allow that spcific user to access
>>> the files it needs to (via group membership or a per-account
>>> permission).
>>> -- 
>>> ..Juha
>>> 
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>> 
>>> 
>>> 
>> 
>> Thanks for your help Juha Laiho.
>> 
>> The reason for my asking this question was that every time I deploy this
>> servlet on any system then I have to always make the tomcat to with the
>> user.
>> 
>> Is there no other way in java to read a file.
>> 
>> Thanks for your help in advance.
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-specify-windows-user-in-runtime-in-tomcat--tp14247742p14331879.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to specify windows user in runtime in tomcat?

Posted by br1 <my...@myrealbox.com>.
You can try with jcifs (http://jcifs.samba.org/).
It should allow you to access a remote share using a different user context,
though I'd reccommend using a dedicated account for this kind of job. 

Hope it helps,
b.


nitin403 wrote:
> 
> 
> 
> Juha Laiho wrote:
>> 
>> nitin403 wrote:
>>> I have create a servlet which needs to read a file on a share folder.
>>> When I run tomcat service as anonymous it is not able to access read
>>> this
>>> file.
>>> But when I run tomcat service as a user who as access to this file, then
>>> it
>>> runs fine.
>>> 
>>> My Question is, is it possible to something similar to this in servlet
>>> code
>>> at run time for running the servlet in tomcat.
>> 
>> No, you can't change Tomcat user at runtime. What you can do is to
>> run Tomcat as a specific user, and allow that spcific user to access
>> the files it needs to (via group membership or a per-account permission).
>> -- 
>> ..Juha
>> 
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
>> 
>> 
> 
> Thanks for your help Juha Laiho.
> 
> The reason for my asking this question was that every time I deploy this
> servlet on any system then I have to always make the tomcat to with the
> user.
> 
> Is there no other way in java to read a file.
> 
> Thanks for your help in advance.
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-specify-windows-user-in-runtime-in-tomcat--tp14247742p14331680.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to specify windows user in runtime in tomcat?

Posted by nitin403 <ni...@gmail.com>.


Juha Laiho wrote:
> 
> nitin403 wrote:
>> I have create a servlet which needs to read a file on a share folder.
>> When I run tomcat service as anonymous it is not able to access read this
>> file.
>> But when I run tomcat service as a user who as access to this file, then
>> it
>> runs fine.
>> 
>> My Question is, is it possible to something similar to this in servlet
>> code
>> at run time for running the servlet in tomcat.
> 
> No, you can't change Tomcat user at runtime. What you can do is to
> run Tomcat as a specific user, and allow that spcific user to access
> the files it needs to (via group membership or a per-account permission).
> -- 
> ..Juha
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

Thanks for your help Juha Laiho.

The reason for my asking this question was that every time I deploy this
servlet on any system then I have to always make the tomcat to with the
user.

Is there no other way in java to read a file.

Thanks for your help in advance.

-- 
View this message in context: http://www.nabble.com/How-to-specify-windows-user-in-runtime-in-tomcat--tp14247742p14268008.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to specify windows user in runtime in tomcat?

Posted by Juha Laiho <Ju...@iki.fi>.
nitin403 wrote:
> I have create a servlet which needs to read a file on a share folder.
> When I run tomcat service as anonymous it is not able to access read this
> file.
> But when I run tomcat service as a user who as access to this file, then it
> runs fine.
> 
> My Question is, is it possible to something similar to this in servlet code
> at run time for running the servlet in tomcat.

No, you can't change Tomcat user at runtime. What you can do is to
run Tomcat as a specific user, and allow that spcific user to access
the files it needs to (via group membership or a per-account permission).
-- 
..Juha

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org