You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-dev@incubator.apache.org by Bo Öberg <bo...@idainfront.se> on 2007/04/23 11:09:59 UTC
How to grant write permission on running server not using gui?
Hi,
I want to be able to add user programatically and grant them write permission. How do I achieve this?
Found a WritePermission-class, but not sure how to use it!
I need this feature during enterprise testing.
Adding user using:
FtpServerContext context = server.getServerContext();
UserManager userManager = context.getUserManager();
BaseUser userToAdd = new BaseUser();
userToAdd.setName(name);
userToAdd.setPassword(pass);
userManager.save(userToAdd);
This works fine.
Also there is a need to set home directory later on...
Appreciate any hints!
/Bosse
Re: How to grant write permission on running server not using gui?
Posted by Marc Chapman <ma...@gmail.com>.
I had to do something similar to this recently. You add the write
permission as an Authority on the user. The following code will add a user
(based on the code provided), with a specified home directory as well as
write permissions to that directory:
FtpServerContext context = server.getServerContext();
UserManager userManager = context.getUserManager();
BaseUser userToAdd = new BaseUser();
final String homeDir = "/DIRECTORY/TO/GRANT/";
WritePermission wp = new WritePermission(homeDir);
userToAdd.setAuthorities(new Authories[]{ wp });
userToAdd.setHomeDirectory(homeDir);
userToAdd.setName(name);
userToAdd.setPassword(pass);
userManager.save(userToAdd);
Hope this helps.
marc
On 4/23/07, Bo Öberg <bo...@idainfront.se> wrote:
>
> Hi,
> I want to be able to add user programatically and grant them write
> permission. How do I achieve this?
> Found a WritePermission-class, but not sure how to use it!
>
> I need this feature during enterprise testing.
>
> Adding user using:
> FtpServerContext context = server.getServerContext();
> UserManager userManager = context.getUserManager();
>
> BaseUser userToAdd = new BaseUser();
> userToAdd.setName(name);
> userToAdd.setPassword(pass);
>
> userManager.save(userToAdd);
>
> This works fine.
>
> Also there is a need to set home directory later on...
>
> Appreciate any hints!
> /Bosse
>
>