1
Programatically Add Users
Question asked by Chris - 7/10/2017 at 8:18 AM
Answered
We're currently setup using Windows Authentication so we could also support FTP but are going to move to a new server and want to start using FileVista's authentication and stop supporting FTP.  I've always added users/root folders to FileVista programmatically using my own tool but since it was windows authentication I was able to leave the password field in the db blank.  Is there a way for me to programmatically add a user's password?  This way I can script the entire migration.

5 Replies

Reply to Thread
0
Chris Replied
And I suppose I should clarify, I can add to the database but the password hash is what's stopping me at this point.  So specifically, what's the hash algorithm and details maybe?
0
Cem Alacayir Replied
Employee Post Marked As Answer
Note that FileVista since many versions ago can authenticate against AD or Machine directly so you don't need to set password for them. This is called "Import users" which is accessible via right-click menu on Users in administration page.
 
However if you need to create users, you can easily do this by referencing GleamTech.FileVista.dll and using this code:​
 
//Replace Provider and ConnectionString with values from your App_Data\FileVista.config
var dataContext = new DataContext("Provider", "ConnectionString");

//Call this method with your own parameters for creating a user with a password:
dataContext.CreateUser(
    name, 
    fullName, 
    email, 
    description, 
    password, 
    passwordNeverExpires, 
    cannotChangePassword, 
    forceChangePassword, 
    isDisabled);

//If you want to mimic "Import Users" dialog behaviour on administration page 
//Note that no password is specified when importing a user because user will be
//authenticated against AD or Machine:
dataContext.CreateUser(
    name, 
    fullName, 
    email, 
    description, 
    userTpe //UserType.ActiveDirectoryDs or UserType.Machine
);
 
Regarding hashing passwords, this is done automatically in CreateUser method, however if you need to access it separately you can do this (after referencing GleamTech.Core.dll):
 
using GleamTech.Cryptography;

var hashedValue = CryptoManager.CreatePassword("plain password");
 
0
Sean Vreeland Replied
@cem

"Note that FileVista since many versions ago can authenticate against AD or Machine directly"

How do you authenticate against a windows10 Enterprise box that is running FileVista on IIS? I see how you can import users from AD, but I'm not running AD, I'm hosting FV on IIS 10.

I have several local windows users on the host box, and those CAN access the landing page of FileVista, but don't I need to create the users from the admin settings in FV?

I got how to create a "local" FileVista user, but that's obviously not created on the host machine.

Essentially, how do I use the hosting machine as a backend auth method?

thanks,

SV
0
Cem Alacayir Replied
Employee Post
In "Import Users" dialog, you can already import from local machine (Sam Store) not just from AD. Just choose "Machine (SAM Store of a computer)" for "Connect To" and enter MachineName below (in AD Domain field)
0
Heinrich Appert Replied
What Scriptlanguage is this?
Have you a code example how to reference to the dll?

Reply to Thread