c# - 如何从同一网络中的IP地址获取活动用户
问题描述
我有网络 IP 地址我可以根据特定的 IP 地址知道活动用户吗
我在同一个网络的详细信息下
"host"+"-" + new Program().GetHostName(ip[0].ToString()).ToString() + "<br>" +
"KeepAlive" + request.KeepAlive + "<br>" +
"Local end point: {0}" + "-" + request.LocalEndPoint.ToString() + "<br>" +
"Remote end point: {0}" + "-" + "--" + "<br>" +
"Is local? {0}" + "-" + request.IsLocal + "<br>" +
"HTTP method: {0}" + "-" + request.HttpMethod + "<br>" +
"Protocol version: {0}" + "-" + request.ProtocolVersion + "<br>" +
"Is authenticated: {0}" + "-" + request.IsAuthenticated + "<br>" +
"Is secure: {0}" + "<br>" + request.IsSecureConnection + "<br>" +
//"username " + "-"+ username + "<br>"+
解决方案
我假设您在这里使用 HttpListener/HttpRequestListener,如果是,请参阅HttpListener:如何获取 http 用户和密码?- 那里接受的答案涉及基本身份验证,但它链接到详细说明如何请求 Windows 身份验证的文章,因此客户端应将登录的 Windows 用户名引用到您的应用程序。
Ps:看起来你正在创建一个日志?那个字符串 concat 代码有点乱,可以从整理中受益,也许使用插值字符串:
$@"Host: {new Program().GetHostName(ip[0].ToString())}<br/>
KeepAlive: {request.KeepAlive}<br/>
Local end point: {request.LocalEndPoint}<br/>
... and so on ...
推荐阅读
- c++ - 试图在 C++ 中给 ifstream 一个变量
- android - IAP 在 alpha 版本中发布到 play store 后无法正常工作
- javascript - 何时更喜欢 Javascript 函数构造函数而不是类?
- jenkins - 从 jenkins 更新 webdriver-manager 期间下载 geckodriver 时出错
- python - 链式模运算的最大值
- zabbix - 有没有办法在脚本中不提供用户名和密码的情况下登录 zabbix API
- android - 构建 QT Android 应用程序:..i686-linux-android-g++:没有这样的文件或目录
- spring - Spring-boot:使用 mvn 激活多个配置文件
- javascript - 滑动特定位置的详细信息应该存储在本地存储中吗?
- java - 如何知道元素是否包含命名空间(xmlns)?