如何使用C#获取系统名称? [英] How to get the system name using C#?

查看:83
本文介绍了如何使用C#获取系统名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的应用程序实现单点登录

我想使用asp.net获取当前的pc用户名c#



我在服务器上托管我的应用程序。



我尝试过:



我使用下面的代码,但函数获取服务器PC的用户名我想获取当前pc的用户名怎么做?



I want to implement single sign on for my application
I want to get current pc user name using asp.net c#

I host my application in server.

What I have tried:

I use the below codes but the function get the user name of server PC i want to get user name of current pc how to do it?

string username = System.Environment.MachineName;

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

推荐答案

你不能。

您只能获取服务器的系统名称 - 即运行C#代码的位置 - 出于安全原因您无法访问客户端系统详细信息,客户端浏览器将不允许这样做。
You can't.
You can only get the system name of the server - that is where your C# code runs - you cannot access the client system details for security reasons, the client browser will not allow it.


如果您可以说服远程计算机的用户安装实现WCF服务的软件,则可以执行此操作。但这不太可能发生。
You can do it if you can convince the user of the remote machine to install software that implements a WCF service. That's not very likely to happen though.


这篇关于如何使用C#获取系统名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆