如何获得当前用户是谁在访问ASP.net应用程序? [英] How to get Current User who's accessing ASP.net app?

查看:104
本文介绍了如何获得当前用户是谁在访问ASP.net应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要获取登录的用户目前在我用这个code系统:

To get the current logged in user at the system I use this code:

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

我在一个ASP.net应用程序,我需要这个信息的工作。所以,我把我的应用程序在服务器上,并试图在code以上,我在字符串OPL获得网络服务。我需要知道谁访问我的ASP.net应用程序的计算机的当前用户。

I work on an ASP.net app where I need this info. So I've put my app on a server and tried the code above and I get "Network Service" in the string opl. I need to know the current user of the PC who accesses my ASP.net app.

任何帮助AP preciated!谢谢你在前进。

Any help is appreciated! Thank you in advance.

推荐答案

如果你使用的会员可以这样做: Membership.GetUser()

If you're using membership you can do: Membership.GetUser()

您code将返回被分配与ASP.NET Windows帐户。

Your code is returning windows account which is assigned with ASP.NET.

这篇关于如何获得当前用户是谁在访问ASP.net应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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