获得Windows登录名没有Windows身份验证 [英] Get windows login name without Windows Authentication

查看:426
本文介绍了获得Windows登录名没有Windows身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的asp.net应用程序的登录用户名的窗口。这里是我的code

I am trying to get the windows Logon username from my asp.net application. Here is my code

string user_name = Request.ServerVariables.Get("LOGON_USER");

这是正常工作对我的当地环境,但是当我上传同样的code上的IIS它给了我一片空白,连我都被

this is works fine on my local environment but when I upload the same code on the IIS it gives me blank, even I have tried to get logon username by

HttpContext.Current.User.Identity.Name

但它给了我一片空白。一旦启用IIS身份验证Windows身份验证和禁用反义词验证它工作正常。任何人都可以请指导我如何,我会得到这个。如果我使用任何错误的计算策略,请大家指正。

but it gives me blank. Once I enable IIS authentication to Windows authentication and disable Antonyms Authentication it is working fine. Can anyone please guide me how I will get this. Please correct me if I am using any wrong approch.

先谢谢了。

编辑:我不想设置Windows身份验证,因此,它会通过在web.config中设置在ASP.NET页面级别的身份验证可能

I don't want to set Windows Authentication, so, Will it be possible in ASP.NET page level authentication by setting in Web.Config

<allow user="*"/> or <deny user="?"/>

如果我说错了请纠正。

推荐答案

为了获取用户名,你需要使用的东西,除了匿名身份验证。

In order to get username, you need to use something besides anonymous authentication.

使用匿名身份验证,则不能获得本地用户的用户名。即使这是可能的,它不会是一个面向公众的现场实践B / C,你可以有多台计算机使用相同的本地用户。

Using Anonymous authentication, you cannot get the username of a local user. Even if this were possible, it would not be practical with a public facing site b/c you could have multiple computers with the same local username.

此外,由于你提到,这是一个企业域之外的面向外部的网站,那么Windows身份验证是不是一种选择。 Windows身份验证主要用于内部网应用。

Also, since you mentioned that this is an external facing site outside of a corporate domain, then Windows Authentication is not an option. Windows Authentication is mainly used for internal intranet applications.

你所可能正在寻找的,如果你想唯一的ID每个用户,拥有的是窗体身份验证,其中ASP.NET支持,并提供了一​​个开箱即控制允许用户注册并创建为您的网站帐户。看看这个链接
http://msdn.microsoft.com/en-us/library/7t6b43z4.aspx

What you likely are looking for if you want to uniquely ID each user, and have is Forms authentication, which ASP.NET supports and provides an out of the box controls for allowing users to register and create accounts for your website. Check out this link http://msdn.microsoft.com/en-us/library/7t6b43z4.aspx

要回答:这将有可能在ASP.NET页面级认证通过在web.config中设置?
设置&LT的授权规则,允许用户=*/&GT;或LT;拒绝用户= /&GT?; 在web.config中控授权给定用户(无论是否给定用户可以得到一个网页在这种情况下)之后,用户已验证,但没有对验证的影响方法或者使用的成员资格提供程序。所以这个web.config中设置不会允许您使用匿名身份验证来获得一个用户名。

To answer: "Will it be possible in ASP.NET page level authentication by setting in Web.Config?" Setting the authorization rules of <allow user="*"/> or <deny user="?"/> in web.config controls the authorization for a given user (whether or not a given user can get to a page in this case) AFTER the user has been authenticated, but does not have an impact on the authentication method or the membership provider used. So this web.config setting will not allow you to get a username using anonymous authentication.

这篇关于获得Windows登录名没有Windows身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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