Beispiel #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;
                }
            }
        }