Esempio n. 1
0
 private bool Encrypt()
 {
     if (IsAutoMode)
     {
         if (ComputerName.IsNullOrEmpty())
         {
             var protector = new PasswordProtector();
             EncryptedValue = protector.Protect(OriginalValue, PasswordProtectionScope.LocalMachine);
             return true;
         }
         else
         {
             //var factory = new ImpersonatorFactory()
             //{
             //    IsEnabled = true,
             //    Username = "******",
             //    Password = "******",
             //    Domain = "LILI"
             //};
             //using (factory.Create())
             {
                 var powershell = new PowerShellExecutor(ComputerName);
                 if (powershell.Execute())
                 {
                     EncryptedValue = powershell.Result;
                     return true;
                 }
             }
         }
         return false;
     }
     return true;
 }
Esempio n. 2
0
 public SecureString GetSecureValue(string name)
 {
     var param = GetParameter(name);
     if (param.Encrypted == EncryptionOptions.Yes)
     {
         var protector = new PasswordProtector();
         var value = protector.UnProtect(param.Value);
         return value.ToSecureString();
     }
     return param.Value.ToSecureString();
 }