0
我有一个ASP.NET C#web应用程序,通过AD进行登录控制认证。是否有可能在Powershell cmd上使用Login控件的凭据,我需要指定信用而不需要输入密码?LoginView并将凭据传递给Powershell
我有一个ASP.NET C#web应用程序,通过AD进行登录控制认证。是否有可能在Powershell cmd上使用Login控件的凭据,我需要指定信用而不需要输入密码?LoginView并将凭据传递给Powershell
我找到了一个解决方案,但我不知道它有多安全。
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";
建议?
这可能有所帮助:http://stackoverflow.com/questions/7109958/saving-credentials-for-reuse-by-powershell-and-error-convertto-securestring-ke –
你能详细说明你的意思吗: :“_我需要指定信用而不需要输入密码_” –