Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
930 views
in CompleteFTP by (160 points)
I am writing a simple UI and want to be able to create new users. Is this possible?

3 Answers

0 votes
by (51.6k points)
We recently wrote a little sample HTML web app that can be used to create users for another user. Would a web-app hosted by CompleteFTP suit you?

- Hans (EnterpriseDT)
0 votes
by (160 points)
Yes! That would be great!
0 votes
by (51.6k points)
Hi Mitch (is that your name?)

Firstly, you'll only be able to use it with the Enterprise Edition of CompleteFTP. If you're not already evaluating the Enterprise Edition then you can upgrade the trial via the Licensing tab in CompleteFTP Manager.

Before the script will run we'll create a new user that has permission to add other users:
  1. Open CompleteFTP Manager
  2. Create a non-Windows user with any user-name and password of your choice.
  3. You now need to allow this new user to create users:
    1. Select the Extensions panel
    2. Click 'Add user permission'
    3. In the newly created row select 'AdminCustomCommand' in the first column and the newly created user in the second column.
    4. Press the tab button so that the Apply button lights up
    5. Click the Apply button
The new user should now be able to add users. You can verify this from your browser.
  1. Navigate to https://localhost. You may get a security warning due to the fact that no proper SSL certificate has been installed. Ignore this error and proceed.
  2. Click "Login".
  3. Log in using the user-name and password of the user that you created just before.
  4. Now copy this URL into your browser.
After a few seconds you should see a user called Test1 in the user list in CompleteFTP Manager.

Now, to create a web-app that does this:
  1. Copy code below into a file called index.jss, located in the directory, C:\ProgramData\Enterprise Distributed Technologies\Complete FTP\Users\USERNAME where USERNAME is the user-name of the user you created in step 2.
  2. Navigate to https://localhost/Home/USERNAME/index.jss where USERNAME. You should see a form titled Add user and three fields.
  3. Fill out the fields and hit submit. Again after a few seconds you should see this user appear in the Manager.

The JSS code:
var userName = request.form.userName;
var password = request.form.password;
var confirmPassword = request.form.confirmPassword;
var message = null;

if (password && !confirmPassword)
   message = "Please enter password twice";
else if (password!=confirmPassword)
   message = "ERROR: Passwords don't match.";
else if (userName && password && password==confirmPassword)
   message = system.executeCustomCommand("AddUser", ["-r", password, userName]);

response.write("<html><body><h1>Add user</h1>");

if (message)
   response.write(message + "<br><br>");

response.write("\
   <form method=post>\
     <table>\
     <tr>\
       <td>User-name:</td>\
       <td><input type=text name=userName></td>\
     </tr>\
     <tr>\
       <td>Password:</td>\
       <td><input type=password name=password></td>\
     </tr>\
     <tr>\
       <td>Confirm password:</td>\
       <td><input type=password name=confirmPassword></td>\
     </tr>\
     </table>\
     <input type=submit>\
   </form>\
");
response.write("</body></html>");


Note that this JSS code has been written so that it's easy to understand for someone who doesn't already know JSS. It can be greatly improved through the use of a template. I can tell you more about that later after you get this working. You can read more about JSS in the 'Web apps' section of the CompleteFTP User Guide.

Please let me know how this goes for you.

- Hans (EnterpriseDT)

Categories

...