我创建了一个ASP.Net应用程序,它模拟用户以创建AD组,然后以用户身份启动PowerShell进程(与模拟分开).
由于某种原因,组创建工作正常并在事件查看器中显示为成功,但是当它尝试运行PowerShell脚本时,我收到以下错误:
未在此计算机上为用户授予所请求的登录类型.
以下是我正在使用的代码失败:
SecureString securePassword = new SecureString();
foreach (char c in model.AdminPassword)
{
securePassword.AppendChar(c);
}
PSCredential psCredential = new PSCredential("CONTOSO\\" + User.Identity.Name, securePassword);
ProcessStartInfo info = new ProcessStartInfo("c:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", "c:\\PowershellScripts\\EnableDL.ps1 -dlName '" + model.Name + "'");
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.RedirectStandardInput = true;
info.CreateNoWindow = true;
info.Domain = "CONTOSO.COM";
info.UserName = User.Identity.Name;
info.Password = securePassword;
Run Code Online (Sandbox Code Playgroud)
有没有办法绕过这个错误?我宁愿不理解服务器上的安全策略,这个应用程序需要大约30多个用户使用.
如果目标页面上存在某些内容,我有一个用户脚本会弹出通知.
在Tampermonkey/Chrome下,这不是问题.我可以使用该GM_Notification()功能轻松创建通知.
当我尝试在Firefox下执行此操作时,它没有任何相同的行为.
检查日志中没有关于该功能的错误,也没有任何通知弹出.
下面是一些示例代码,它们在Firefox + Greasemonkey或Firefox + Tampermonkey中不起作用,但在Chrome + Tampermonkey中有效:
// ==UserScript==
// @name Test Notifier
// @include *
// @grant GM_notification
// @grant window.focus
// ==/UserScript==
console.log('I am a pretty test script');
var notificationDetails = {
text: 'THIS IS A TEST NOTIFICATION!!!',
title: 'TEST',
timeout: 15000,
onclick: function() { window.focus(); },
};
GM_notification(notificationDetails);
Run Code Online (Sandbox Code Playgroud)
这是Firefox的标准行为吗?它是否以完全不同的方式处理HTML5通知(如果有的话)?在Firefox用户脚本中启用通知的常见做法是什么?