【问题标题】:Opening AD from vb.net with different credentials使用不同的凭据从 vb.net 打开 AD
【发布时间】:2017-09-14 02:04:13
【问题描述】:

我找到了以下代码

    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"

通过打开应用程序有效,但不传递用户名或提示输入密码,我不知道如何伪造不同的凭据和参数。

想法??

【问题讨论】:

    标签: vb.net process active-directory passwords


    【解决方案1】:

    好的 - 这是我使用的代码

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-17
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多