Example #1
0
        /// <summary>
        /// Method for connecting to the M-Files server and logging into the Vault
        /// </summary>
        private void Login()
        {
            mfserver = new MFilesAPI.MFilesServerApplication();
            if (sessionID != null)
            {
                vault = mfserver.ConnectWithExistingVaultSession(sessionID, protocol, serverName, port, false);
                return;
            }
            var tmz = new MFilesAPI.TimeZoneInformation();

            tmz.LoadWithCurrentTimeZone();
            var res = mfserver.ConnectEx3(tmz, MFilesAPI.MFAuthType.MFAuthTypeSpecificMFilesUser, user, pw, "", "", protocol, serverName, port, false, "", false, true, "");

            if (res == MFilesAPI.MFServerConnection.MFServerConnectionAnonymous)
            {
                // need to decide what to do with error situations!
                Console.WriteLine("Invalid credentials provided");
                return;
            }
            if (res == MFilesAPI.MFServerConnection.MFServerConnectionNone)
            {
                // need to decide what to do with error situations!
                Console.WriteLine("Unable to connect to server");
                return;
            }
            else
            {
                if (session == null)
                {
                    vault     = mfserver.LogInAsUserToVaultEx(vaultGUID, tmz, MFilesAPI.MFAuthType.MFAuthTypeSpecificMFilesUser, user, pw, "", "");
                    session   = vault.SessionInfo;
                    sessionID = Encoding.Unicode.GetBytes(vault.LoginSessionID);
                    Console.WriteLine("connected to vault: " + vault.Name);
                    return;
                }
            }
        }
Example #2
0
        protected virtual MFilesServerApplication GetServerApp(
            string username,
            string password,
            string domain,
            string protocolSequence,
            string networkAddress,
            string endpoint,
            bool encryptedConnection,
            string localComputerName,
            MFAuthType authType)
        {
            var serverApp = new MFilesServerApplication();

            serverApp.ConnectEx3(AuthType: authType,
                                 UserName: username,
                                 Password: password,
                                 Domain: domain,
                                 ProtocolSequence: protocolSequence,
                                 NetworkAddress: networkAddress,
                                 Endpoint: endpoint,
                                 EncryptedConnection: encryptedConnection,
                                 LocalComputerName: localComputerName);
            return(serverApp);
        }