ArGoSoft ArGo Software Design Low Cost Efficient Servers Merry Christmas
Skip Navigation Links
Home
News
ProductsExpand Products
ServicesExpand Services
Download
Support
Register
Search
Forum
Registered Users
Our Users
Link to Us
Site Map
Skip Navigation LinksHome > Products > Ftp Server .NET > Developers

Information for Developers

Main
Upgrade
Newsgroups
FAQ
List of Changes
Register
Extend
Developers


Our other sites
Backup Exchangers
Email Address Validator

Here we will provide information, which could be useful for developers, willing to manupulate the FTP server from their applications.

Adding users programmatically

Information below is valid for the FTP server version 1.0.0.4 or later.

Users can be easily added by inserting a record into the FtpServerData database:

    SqlConnection conn = new SqlConnection(connString);
    conn.Open();
    try
    {
        string cmdString = "INSERT INTO Users (UserName,Password,HomeDirectory,Quota,Disabled,GroupName,CanRead," +
            "CanWrite,CanList,CanDelete,CanSiteDos,CanSiteZip,CanSiteCopy) VALUES (@UserName,@Password," +
            "@HomeDirectory,@Quota,@Disabled,@GroupName,@CanRead,@CanWrite,@CanList,@CanDelete,@CanSiteDos,@CanSiteZip,@CanSiteCopy)";
        SqlCommand cmd = new SqlCommand(cmdString, conn);
        cmd.Parameters.AddWithValue("@UserName", "joe");
        cmd.Parameters.AddWithValue("@Password", "_clear_topsecret");
        cmd.Parameters.AddWithValue("@HomeDirectory", "c:\\");
        cmd.Parameters.AddWithValue("@Quota", 0);
        cmd.Parameters.AddWithValue("@Disabled", false);
        cmd.Parameters.AddWithValue("@GroupName", "None");
        cmd.Parameters.AddWithValue("@CanRead", true);
        cmd.Parameters.AddWithValue("@CanWrite", false);
        cmd.Parameters.AddWithValue("@CanList", true);
        cmd.Parameters.AddWithValue("@CanDelete", false);
        cmd.Parameters.AddWithValue("@CanSiteDos", false);
        cmd.Parameters.AddWithValue("@CanSiteZip", false);
        cmd.Parameters.AddWithValue("@CanSiteCopy", false);
        cmd.ExecuteNonQuery();
    }
    finally
    {
        conn.Close();
    }
                    

Note the way how we are adding password. In the database passwords are hashed. When adding users externally, we cannot use the hash algorythm. We have to tell the server, that the password we are adding is in clear text, that's why we are preceeding it with the string _clear_. In the above example, actual password of user is topsecret.

After the first attempt to validate the password of user on the server, the password will be converted into the hashed format, and resaved into the database.



Copyright © 1995-2017 ArGo Software Design. All rights reserved.