LoginView并传递凭据PowerShell的 [英] LoginView and passing credentials to Powershell
本文介绍了LoginView并传递凭据PowerShell的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Login控件通过AD认证一个ASP.NET C#的Web应用程序。是否有可能使用Login控件的凭据上一个PowerShell CMD,我需要没有被要求输入密码,指定creds?
I have a ASP.NET C# web app with a Login control authenticating via AD. Is it possible to use the Login control's credentials on a Powershell cmd where I need to specify creds without being asked for the password?
推荐答案
我已经找到了解决办法,但我不知道它是多么安全。
I've found a solution, but I don't know how secure it is.
string un = System.Web.HttpContext.Current.Session["UserName"].ToString();
string pw = System.Web.HttpContext.Current.Session["Password"].ToString();
sText += "$securePasssword = ConvertTo-SecureString \"" + pw + "\" -AsPlainText -Force \n";
sText += "$credentials = New-Object System.Management.Automation.PSCredential ($un, $securePasssword) \n";
sText += "$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $url -Authentication Kerberos -Credential $credentials \n";
sText += "Import-PSSession $Session \n";
建议?
这篇关于LoginView并传递凭据PowerShell的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文