User object

<< Click to Display Table of Contents >>

Navigation:  Handling Events via Scripting > Objects and Functions > Syncplify.me Server! Objects >

User object

The User object represents the current user who wants to log in or who has already logged in and to whom the current connection (and session) belongs.

 

It is defined as follows:

  TSrvUser = class(TObject)  

  // [...]
  public
    constructor Create(Collection: TCollection);
    destructor Destroy; override;
    function Clone(newuname: string): TSrvUser;
    function LoadFromDB(uid: string): boolean;
    function SaveChanges: boolean;
  published
    property UserID: AnsiString read fUserID;
    property Username: string read fUsername;
    property Description: string read fDescription write fDescription;
    property Salt: string read fSalt;
    property Password: string read fPassword;
    property PubKeys: TSSHPubKeyCollection read fPubKeys write fPubKeys;
    property HomeDir: WideString read fHomeDir write fHomeDir;
    property Permissions: TPermissions read fPermissions write fPermissions;
    property VirtualFolders: TSSHFolderCollection read fVirtualFolders write fVirtualFolders;

    property SpeedLimits: TSpeedLimitCollection read fSpeedLimits write fSpeedLimits;
    property AuthTypes: integer read fAuthTypes write fAuthTypes;
    property AuthAll: boolean read fAuthAll write fAuthAll;
    property AllowFTP: boolean read fAllowFTP write fAllowFTP;

    property AllowFTPSE: boolean read fAllowFTPSE write fAllowFTPSE;

    property AllowFTPSI: boolean read fAllowFTPSI write fAllowFTPSI;
    property AllowSFTP: boolean read fAllowSFTP write fAllowSFTP;

    property AllowSSH: boolean read fAllowSSH write fAllowSSH;
    property AllowForward: boolean read fAllowForward write fAllowForward;
    property AllowWebDAV: boolean read fAllowWebDAV write fAllowWebDAV;
    property AccountStatus: TAccountStatus read fAccountStatus write fAccountStatus;
    property AutoDisable: boolean read fAutoDisable write fAutoDisable;
    property AutoDisWhen: TDateTime read fAutoDisWhen write fAutoDisWhen;
    property AllowedIPs: AnsiString read fAllowedIPs write fAllowedIPs;
    property AllowedFwd: AnsiString read fAllowedFwd write fAllowedFwd;
    property IsAdmin: boolean read fIsAdmin write fIsAdmin;
  end;

 

In addition to the main object, two more sub-objects are defined:

  TAccountStatus = (asEnabled, asDisabled);

 
  TPermissions = class(TPersistent)

  // [...]
  published
    property canGetFile: boolean read fGetFile write fGetFile;
    property canPutFile: boolean read fPutFile write fPutFile;
    property canDelFile: boolean read fDelFile write fDelFile;
    property canModFile: boolean read fModFile write fModFile;
    property canRenFile: boolean read fRenFile write fRenFile;
    property canListDir: boolean read fListDir write fListDir;
    property canMakeDir: boolean read fMakeDir write fMakeDir;
    property canDelDir: boolean read fDelDir write fDelDir;
    property canRenDir: boolean read fRenDir write fRenDir;
  end;

 

Moreover, there are two collection properties in the main User object, which are defined as follows:

  TSSHFolderCollectionItem = class(TCollectionItem)
  published
    property VirtualDir: WideString read fVirtualDir write fVirtualDir;
    property ActualDir: WideString read fActualDir write fActualDir;
    property Permissions: TPermissions read fPermissions write fPermissions;
    property Visible: boolean read fVisible write fVisible;
  end;
 
  TSSHFolderCollection = class(TCollection)
  public
    property Items[Index:Integer]: TSSHFolderCollectionItem read GetSSHFolderCollection
            write SetSSHFolderCollection; default;
  end;

 

  TSSHPubKeyCollectionItem = class(TCollectionItem)
  published
    property KeyName: WideString read fKeyName write fKeyName;
    property PubKey: AnsiString read fPubKey write SetPublicKey;
  end;
 
  TSSHPubKeyCollection = class(TCollection)
  published
    property Items[Index:Integer]: TSSHPubKeyCollectionItem read GetSSHKeyCollection
            write SetSSHKeyCollection; default;
  end;

 

  TSpeedLimitCollectionItem = class(TCollectionItem)
  published
    property KBPSUp: integer read fSpeedLimitUp write fSpeedLimitUp;
    property KBPSDown: integer read fSpeedLimitDn write fSpeedLimitDn;
    property IPNetwork: AnsiString read fIPNetwork write fIPNetwork;
  end;
 
  TSpeedLimitCollection = class(TCollection)
  public
    property Items[Index:Integer]: TSpeedLimitCollectionItem read GetSpeedLimCollection
            write SetSpeedLimCollection; default;
  end;

 

Through the above collections you can temporarily (or permanently, if you call SaveChanges afterwards) add virtual folders and public keys, and manage or delete existing ones.