public bool SetCredentials(UserPass up)
        {
            var cm = new Credential {
                Target = CredentialName, PersistanceType = PersistanceType.Enterprise, Username = up.UserName, Password = up.Password
            };

            return(cm.Save());
        }
        public UserPass GetCredentials()
        {
            var cm = new Credential {
                Target = CredentialName
            };

            if (!cm.Exists())
            {
                return(null);
            }

            cm.Load();
            var up = new UserPass(cm);

            return(up);
        }
Пример #3
0
        private string RetrievePassword()
        {
            CredentialManager credentialManager = new CredentialManager(this.ConfigData.Name);
            UserPass          pass     = credentialManager.GetCredentials();
            string            password = String.Empty;

            if (pass == null || string.IsNullOrEmpty(pass.Password))
            {
                Console.WriteLine(Constants.DeploymentCommand5, this.ConfigData.User);

                password = Console.ReadLine();

                credentialManager.SetCredentials(new UserPass(new Credential(this.ConfigData.User, password)));

                Console.WriteLine(Constants.WinCredentialsCreated);
            }
            else
            {
                Console.WriteLine(Constants.ReadWinCredentials);
                password = pass.Password;
            }
            return(password);
        }