예제 #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);
 }