title: Apache FTP Server - Create user programmatically
body: <p>I am using Apache FTP Server embedded in my code. I used the example from the Apache Website and did indeed embed the server in 5 mins (as shown)</p>
  
  <p><a href="http://mina.apache.org/ftpserver-project/embedding_ftpserver.html" rel="nofollow">Apache Example here</a></p>
  
  <p>This example uses the users.properties file which is fine. </p>
  
  <p>However, I would like to create my user in the code. I don't want users to be able to change attributes. </p>
  
  <p>I've found various examples on the web but all seem incomplete and don't quite seem to have everything I need. </p>
  
  <p>In a nutshell I would like to create a user in code based on the following properties configurations</p>
  
  <pre><code># Password is "admin"
  ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3
  ftpserver.user.admin.homedirectory=/home/ftproot
  ftpserver.user.admin.enableflag=true
  ftpserver.user.admin.writepermission=true
  ftpserver.user.admin.maxloginnumber=0
  ftpserver.user.admin.maxloginperip=0
  ftpserver.user.admin.idletime=0
  ftpserver.user.admin.uploadrate=0
  ftpserver.user.admin.downloadrate=0
  </code></pre>
  
  <p>I've tried a few things including the following to no avail:</p>
  
  <pre><code>    UserFactory uf = new UserFactory();
  
      uf.setName( "admin" );
      uf.setPassword( "admin" );
      uf.setHomeDirectory( "/home/ftproot" );
      uf.setMaxIdleTime( 0 );
      uf.setEnabled(true);
      uf.createUser();
  </code></pre>
  
  <p>I'm missing something and am unable to find any complete/working examples on the web.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is the error message I get</p>
  
  <pre><code>C:\WINDOWS&gt;ftp localhost
  Connected to localhost.
  220 Service ready for new user.
  User (localhost:(none)): admin
  331 User name okay, need password for admin.
  Password:
  530 Authentication failed.
  Login failed.
  ftp&gt;
  </code></pre>