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

前端 未结 6 2198
夕颜
夕颜 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:45

    Unfortunately you have to interop with the WMI like this:

    http://www.codeproject.com/Articles/28161/Using-WMI-to-manipulate-services-Install-Uninstall

    The value you're looking to query for is StartName, which will evaluate to something like "NT Authority\NetworkService" (or whatever you're using). If you mash up the second part of this article with the first part getting it should be pretty straightforward.

提交回复
热议问题