Thanks for the sample, Marc!
We've decided to 'hard-code' a set of user-settings in a specific 'user.gen' 
covering all our test cases.
I did try these methods, but it didn't work on my first try, so...

However, I'm a little bit confused about 'home'-directory, and how to define it!
I have a couple of questions maybe you can answer!
 - If I specify "db/transfer" as home directory, the base is start-up 
directory, or? Ie <start-dir>/db/transfer will the start node for a connection 
as this user?
 - Can one control the 'base' by setting the user.dir property?

/Bosse

-----Ursprungligt meddelande-----
Från: Marc Chapman [mailto:[EMAIL PROTECTED]
Skickat: den 23 april 2007 15:26
Till: ftpserver-dev@incubator.apache.org
Ämne: Re: How to grant write permission on running server not using gui?


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 <[EMAIL PROTECTED]> 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
>
>

Reply via email to