开幕AD从vb.net与不同的凭据
问题描述:
我发现下面的代码开幕AD从vb.net与不同的凭据
Dim p As New ProcessStartInfo With {
.FileName = "c:\Windows\System32\dsa.msc",
.Arguments = "/SAVECRED /user:DOMAIN\username"
}
' Start the process
Process.Start(p)
我希望能够通过下列CMD,对于用户名
c:\Windows\System32\runas.exe /SAVECRED /user:DOMAIN\username "c:\Windows\System32\mmc.exe c:\Windows\System32\dsa.msc"
其中通过打开工作提示该应用程序,但没有通过用户名或提示输入密码,我无法弄清楚如何改变不同的声望和争论。
想法??
答
好想通了 - 这是我用
Function ConvertToSecureString(ByVal str As String)
Dim password As New SecureString
For Each c As Char In str.ToCharArray
password.AppendChar(c)
Next
Return password
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim passwordString As String
passwordString = "..........."
Dim password As SecureString = ConvertToSecureString(passwordString)
' New ProcessStartInfo created
Dim p As New ProcessStartInfo
' Specify the location of the binary
p.FileName = "mmc.exe"
p.WorkingDirectory = "c:\Windows\System32\"
' Use these arguments for the process
p.Arguments = "dsa.msc"
p.Domain = "........"
p.UserName = "......."
p.Password = password
p.UseShellExecute = False
' Start the process
Process.Start(p)
End Sub
代码