I need to create FTP users via a C# software, which is run Client-Side, I have no idea where to start or how to do that, I am not even sure if this is possible as this may require to be logged as root?

My other option would be to call a PHP script via the C# software, which could call a system() script?

This function needs to work on Linux shared hosting (as this is shared I can't do everything I can).

share|improve this question
    
What FTP server are you using? How do you create FTP users normally? – William Jun 30 '10 at 17:35
    
Normally I create them via a DirectAdmin control panel, and I don't really know which server is installed. – Dominique Jun 30 '10 at 17:36
    
Do the users using your client software know the information to DirectAdmin? – William Jun 30 '10 at 17:38
    
No, they don't and they won't know the FTP password as well, the software manage all those informations. – Dominique Jun 30 '10 at 17:39

The only way YOU have to manage the FTP server is through DirectAdmin. So unless there is an API for DirectAdmin and you have access to it, or your shared hosting provider offers some kind of API, you won't be able to do this.

If you can manage your users on the shared host with system(), then by all means go that route.

If you can't, then you might need to create a script that runs on the server, that accepts incoming requests and then works directly with DirectAdmin to manage the users. This would require the script know the DirectAdmin credentials, and if any updates happen to DirectAdmin it could potentially break your script. I would be very careful with this method, as anyone with access to this script could then manage ftp users. If your client can manage these FTP users, anyone can. How will users be "authenticated" with the client if there is any authentication. If so, how are they authenticated? Because your "api" script will need to work with that authentication as well.

My question is, do you really NEED to create an FTP user? If they just need to upload a file, couldn't they simply upload a file via an online form? Or through the client? Are you required to use FTP?

EDIT: So as I said in the comments, one idea would be to have a server side script (maybe PHP) that would handle managing the files. It would accept requests to upload/delete/blah the files. When a file is uploaded to the site it would be stored, and it would return a special token along with the location of the file.

The client would then take the token, store it locally, and when the user manages the file on the client it would use that token for future modifications. I'd generate this token randomly (not based off any data of the user). How you store the token is up to you, could be on the file system with the files or in a database.

The communication between the client and the site should be done through SSL if possible, to stop MITM attacks.

As for uploading files, it's really up to how your client authenticates it's users. If it's via a central database, the shared hosting server could access that, if you don't want to do that, then you'd need to something similar to a public key system. So that the client can send a key that the shared hosting script can tell if the user is valid or not. But then you have to have the script know when the key has been revoked, etc.

So it's up to you how you want to proceed with this part.

share|improve this answer
    
The users of the software will rarelly create new FTP users, but they will send files online alot via it, and I don't want every users to use the same account/password for FTP, this is why I wanted to create 1 FTP per USER, I could use the same and have subfolder in it, but if someone want he could find the account/password and mess up other users files. – Dominique Jun 30 '10 at 17:52
    
But how are they sending files, do they already use FTP? Will they be sending them via the client, through an FTP client? – William Jun 30 '10 at 17:54
    
They are sending files only via the software, the user for this software have no idea what a FTP is, everything is send to a FTP server but in background, the user don't even know they have a FTP password associated with their software account. – Dominique Jun 30 '10 at 17:58
    
Okay so what if you wrote a simple PHP script that allow your C# client to send a file to, it would also send the user's account or some other kind of unique data about the user. It would upload the file, and then return back a token to the client. The token would be stored on the client and if they want to delete that file in the future, when they delete it the token would be sent back to the server. In other words, you cannot delete a file without knowing a special token that is randomly generated on the server and only talk to the server through SSL. – William Jun 30 '10 at 18:33
    
You would still have the issue of someone being able to upload files to the site, but not being able to delete them. To solve the upload issue, you need to figure out a way for the site to authenticate you're allowed to use the software. But this would most likely require a central database. I'll edit my post for a possible solution. – William Jun 30 '10 at 18:35

If this were me--and this is adding one more moving part, I realize--I'd decouple the creation of users, and place that in a long-running process on the remote server, where both the server process and the PHP facade work with something like Gearman to coordinate jobs. You're not going to be able to create the processes on the remote Linux server from C# without some external facility like rsh. Something just skeeves me out about the idea of creating users via a PHP site, unless it's only accessible over a private intranet with no external access. Having a separate process would give you just one extra step in which to validate.

share|improve this answer
    
I was thinking more like calling a system function or something like that to create the FTP user. The user of the software will need in some case to give access to someone to put file on the server, but I don't want them to create FTP user manually, nor to set the user/password/default folder. I also don't like the PHP idea, but I need to be able to create FTP users remotely, I hope to find a better solution too :) – Dominique Jun 30 '10 at 17:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.