Using SQL to store users for SFTP Server

0 votes
asked Jun 29, 2015 by kpierce0 (120 points)

Can I use SQL to store users credentials ?


Applies to: File Server

1 Answer

0 votes
answered Jun 30, 2015 by Tomas Knopp (58,890 points)
edited Jun 30, 2015 by Tomas Knopp

Yes, this is possible with Rebex File Server component. Just implement your own custom authentication provider with the help of the Authentication event, e.g.:

// register authentication event handler server.Authentication += (sender, e) => {
    MyDbUser myUser;

    // try authenticating the user against a custom user database
    if (MyUserDatabase.TryAuthenticate(
        e.UserName, e.Password, out myUser))
        // construct a user object
        var user = new FileServerUser(myUser.UserName, null, myUser.VirtualRoot);

        // accept authentication attempt with this user object
        // reject authentication attempt
    } };

In the above example you have to replace the MyUserDatabase.TryAuthenticate method with your own method that will will access your database and check whether user is allowed to authenticate or not based on the content of the database).