Security

The Connector requires several aspects of authentication to be considered and deployed. Security for accessing M-Files from SQL and accessing SQL from M-Files are different.

Credentials for accessing M-Files from SQL

SQL uses a standard M-Files connection to log in to M-Files.

The Connector allows both specific Windows and M-Files authentication as a user. We recommend using a dedicated M-Files authentication user with a distinct name such as MFSQL or MFSQLConnect as a named user license. The name of the user will appear on all objects in M-Files that is updated or created.

Assign administrator permissions in the vault to the user.

The M-Files user for the Connector must be assigned as a server-administrator in M-Files for the duration of the installation into the M-Files vault.  The installation of the vault applications will fail if the user does not have this required permissions.  The permissions of the installation user can be downgraded to a vault administrator when the installation is complete.

The M-Files user is automatically configured in the database on installation of the package. These details are maintained in the MFVaultSettings table. Re-running the installation package will automatically update the credentials. The connection settings can also be changed in MFVaultSettings using the spMFSettingsForVaultUpdate procedure.

The password is stored in the MFVaultSettings table in encrypted format.

Credentials for accessing SQL from M-Files

On installation the package automatically configures the authentication for access from M-Files to SQL.

It is required for the SQL Server to be installed with mixed mode authentication to operate.

The Context Menu functionality of the Connector uses an ODBC connection string for access to SQL operations from M-Files to SQL. A Web API method is available for cloud installations.

The connection method is configured in the M-Files Admin Configurator as part of the installation process. The password used in the configurator needs to be reset in SQL before the connection from M-Files to SQL will be operational.

The installation package automatically installs and assigns permissions for SQL operations. An SQL authentication login MFSQLConnect is created and assumes the permissions assigned to the db_MFSQLConnect role in the database.

Another user (including Windows authentication users) can be added to the db_MFSQLConnect role to allow specific users to perform Connector tasks.

Web API logins

When a vault uses the Web API, its Web API instance does not sign in as MFSQLConnect. Each instance signs in to SQL Server with a SQL login of its own:

  • One login for each Web API instance, and so for each vault. The default name is MFSQLWebAPI_<Key>, where <Key> is the instance key, with each hyphen written as _.

  • The login has a database user in that vault’s Connector database only, and the user is a member of db_MFSQLConnect.

  • The Web API install creates the login, or a DBA creates it with a script the install provides. The instance’s connection string, with the login’s password, is held in the instance’s web.config on the web server.

  • The Web API install never changes the MFSQLConnect login or its database user, which the Connector’s agent jobs and the on-premises vault application keep using. Removing a Web API instance never drops MFSQLConnect.

See Reference: install the MFSQL Connector Web API for the full detail.

Database roles

The installation, or the manual script installation, creates three database roles in the MFSQL Connector database:

Role

Permissions

db_MFSQLConnect

The role for the Connector login (MFSQLConnect) and for other users or service accounts that run Connector procedures. CREATE TABLE on the database, and the schema permissions below.

db_MFSQLReport

DELETE, EXECUTE, INSERT, SELECT and UPDATE on the Report schema only. Use it for reporting users that need nothing else.

db_MFSQLAdmin

A member of db_owner, so it has full control of the database. Add only administrators to this role.

Schema permissions of db_MFSQLConnect:

Schema

DELETE, EXECUTE, INSERT, SELECT, UPDATE

ALTER

dbo

Yes

Yes

Custom

Yes

Yes

setup

Yes

No

ContMenu

Yes

No

Report

Yes

No

Encryption of password in MFVaultSettings

The M-Files user credentials used for the Connector are stored in encrypted format using Microsoft cryptographic services (secret-key encryption, symmetric cryptography). Secret-key encryption algorithms use a single secret key to encrypt and decrypt data.

Two procedures are provided with the Connector to encrypt and decrypt passwords. You must secure these procedures from access by unauthorized agents, because any party that has these procedures can use them to decrypt the passwords in the Connector.

Check that the Connector login can use the database

The MFSQLConnect login exists on the SQL Server, but it can only work in the MFSQL Connector database through a database user that is mapped to it and is a member of db_MFSQLConnect. If that user is missing or not mapped, the Connector login can’t reach the database: for example, the vault application’s Dashboard shows no settings. This can happen after the database is restored or moved to another SQL Server, or when the login did not exist when the database scripts ran.

Run this in the MFSQL Connector database, as a sysadmin or the database owner:

SELECT  sp.name                                     AS LoginName,
        dp.name                                     AS UserName,
        IS_ROLEMEMBER(N'db_MFSQLConnect', dp.name)  AS InConnectorRole
FROM sys.server_principals AS sp
LEFT JOIN sys.database_principals AS dp
       ON dp.sid = sp.sid
WHERE sp.name = N'MFSQLConnect';

-- A database user named MFSQLConnect that no login is mapped to (orphaned)
SELECT dp.name AS OrphanedUser
FROM sys.database_principals AS dp
LEFT JOIN sys.server_principals AS sp
       ON sp.sid = dp.sid
WHERE dp.name = N'MFSQLConnect'
  AND sp.sid IS NULL;

How to read the result:

  • No row in the first query: the MFSQLConnect login does not exist on this SQL Server. Run the installer again, or create the login, then repeat the check.

  • UserName is NULL and the second query returns a row: the user exists but is orphaned, which is typical after a restore to another server. Map it to the login:

    ALTER USER [MFSQLConnect] WITH LOGIN = [MFSQLConnect];
    
  • UserName is NULL and the second query returns nothing: there is no user for the login. Create it and add it to the role:

    CREATE USER [MFSQLConnect] FOR LOGIN [MFSQLConnect];
    ALTER ROLE [db_MFSQLConnect] ADD MEMBER [MFSQLConnect];
    
  • InConnectorRole is 0: the user exists but is not in the role. Add it:

    ALTER ROLE [db_MFSQLConnect] ADD MEMBER [MFSQLConnect];
    

If the Connector uses a different login, replace MFSQLConnect with that login’s name.