How do you get credentials (NetworkCredential) of currently logged in user?

前端 未结 6 2090
夕颜
夕颜 2021-02-05 02:01

I\'m writing some code to utilise a 3rd party component, and I need to supply an object which implements ICredentials when I start to use it.

If I write the following...

6条回答
  •  伪装坚强ぢ
    2021-02-05 02:36

    if you just want to run a process as the current user adds the verb: "runas " & Environment.UserName

    If you want to run the process as admin just wrote "runas"

    in vb.net

    Dim ps As New System.Diagnostics.ProcessStartInfo("filepath", "arguments")
    
    ps.Verb = "runas" 'run as admin
    
    'ps.Verb = "runas " & Environment.UserName'run as current user, by default
    
    Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start(ps)
    

    if you want to get the current user password, you can not, in fact it is an unsafe practice. What right and for what purpose your service needs to get my Windows password secret? for example is like giving the pin code of your phone to whatsapp

提交回复
热议问题