Get domain user from IPAddress or Hostname in .Net

情到浓时终转凉″ 提交于 2019-12-12 06:01:41

问题


We're trying to implement a custom solution for Growl for Windows. We tell the Growl client to subscribe to notifications from our server. The server then gets a message from the client via the GNTP (Growl messaging protocol). We require the name of the user logged into the client machine in order to do database lookups. The GNTP does not provide this information.

So, we have a connected client socket (and thus, IP address) and a message from this client containing its machine name.

Is there any possible way to determine the username of the user who is logged into the specified machine? We have access to windows domain services.


回答1:


This will give you the Windows domain and current user (if that's what you're after)

using System.Security.Principal;

        if (WindowsIdentity.GetCurrent().IsAuthenticated)
        {
            string Result = WindowsIdentity.GetCurrent().Name;



回答2:


We ended up doing the reverse (sorta) by having a client-side application run at logon and let our server know which user had logged in.



来源:https://stackoverflow.com/questions/2581743/get-domain-user-from-ipaddress-or-hostname-in-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!