public KnowledgeMaster(string server, string userName, string userPassword, AuthTyp authType)
        {
            VDF.Vault.Currency.Connections.AuthenticationFlags authFlags = VDF.Vault.Currency.Connections.AuthenticationFlags.Standard;

            if (authType == AuthTyp.ActiveDir)
            {
                authFlags = VDF.Vault.Currency.Connections.AuthenticationFlags.WindowsAuthentication;
            }
            VDF.Vault.Results.LogInResult result =
                VDF.Vault.Library.ConnectionManager.LogIn(server, null, userName, userPassword, VDF.Vault.Currency.Connections.AuthenticationFlags.ServerOnly | authFlags, null);

            if (result.Success == false)
            {
                string message = "Login failed";
                if (result.Exception == null)
                {
                    if (result.ErrorMessages.Count > 0)
                    {
                        message = result.ErrorMessages.ElementAt(0).Key.ToString() + ", " + result.ErrorMessages.ElementAt(0).Value;
                    }
                }
                else
                {
                    message = VDF.Library.ExceptionParser.GetMessage(result.Exception);
                }
                throw new ApplicationException(message);
            }
            AuthenticationType = authType;
            ServiceManager     = result.Connection.WebServiceManager;
        }
Example #2
0
        public void Run(ApplicationOptions options)
        {
            Options = options;

            VDF.Vault.Currency.Connections.AuthenticationFlags authFlags = VDF.Vault.Currency.Connections.AuthenticationFlags.Standard;

            if (Options.AuthenticationType == AWS.AuthTyp.ActiveDir)
            {
                authFlags = VDF.Vault.Currency.Connections.AuthenticationFlags.WindowsAuthentication;
            }
            VDF.Vault.Results.LogInResult result =
                VDF.Vault.Library.ConnectionManager.LogIn(Options.Server, Options.Vault, Options.UserName, Options.Password, authFlags, null);

            if (!result.Success)
            {
                if (result.Exception == null)
                {
                    if (result.ErrorMessages.Count > 0)
                    {
                        string message = result.ErrorMessages.ElementAt(0).Key.ToString() + ", " + result.ErrorMessages.ElementAt(0).Value;
                        throw new ApplicationException(message);
                    }
                    else
                    {
                        throw new ApplicationException("Error connecting to Vault.");
                    }
                }
                else
                {
                    throw result.Exception;
                }
            }

            try
            {
                ServiceManager = result.Connection.WebServiceManager;

                Data = ReadData();
                if (Options.SchemeType == SchemeType.File)
                {
                    ProcessFileScheme();
                }
                else if (Options.SchemeType == SchemeType.Item)
                {
                    ProcessItemScheme();
                }
            }
            finally
            {
                VDF.Vault.Library.ConnectionManager.CloseAllConnections();
            }
        }
        public void Run(ApplicationOptions options)
        {
            Options = options;
            VDF.Vault.Currency.Connections.AuthenticationFlags authFlags = VDF.Vault.Currency.Connections.AuthenticationFlags.Standard;

            if (Options.AuthenticationType == AWS.AuthTyp.ActiveDir)
            {
                authFlags = VDF.Vault.Currency.Connections.AuthenticationFlags.WindowsAuthentication;
            }
            VDF.Vault.Results.LogInResult result =
                VDF.Vault.Library.ConnectionManager.LogIn(Options.Server, Options.KnowledgeVault, Options.UserName, Options.Password, authFlags, null);

            if (result.Success == false)
            {
                string message = "Login failed";
                if (result.Exception == null)
                {
                    if (result.ErrorMessages.Count > 0)
                    {
                        message = result.ErrorMessages.ElementAt(0).Key.ToString() + ", " + result.ErrorMessages.ElementAt(0).Value;
                    }
                }
                else
                {
                    message = VDF.Library.ExceptionParser.GetMessage(result.Exception);
                }
                Log(MessageCategory.Error, "Error connecting to Vault: {0}", message);
                return;
            }

            try
            {
                ServiceManager = result.Connection.WebServiceManager;
                Data           = ReadData(Options.InputFile);

                Initialize();
                ImportFoldersAndProperties();
                UpdatePermissionsAndLifecycles();
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            finally
            {
                VDF.Vault.Library.ConnectionManager.CloseAllConnections();
            }
        }