简体   繁体   English

使用Active Directory域凭据asp.net进行自动身份验证

[英]Auto authentication using Active Directory domain credentials asp.net

I'm trying to implement auto authentication in an asp portal which will be used in an intranet only. 我正在尝试在只会在Intranet中使用的asp门户中实现自动身份验证。 I want to allow only specific users to use that and want to authenticate them using their NT logins of Active Directory. 我只想允许特定的用户使用它,并希望使用其Active Directory的NT登录名对其进行身份验证。 Using the following code to get the user id but it is gives null. 使用以下代码获取用户ID,但它为null。

String sUser = Request.ServerVariables["LOGON_USER"].ToLower();

Help will be highly appreciated. 非常感谢您的帮助。

Before you can access the LOGON_USER variable you must make sure the user is in fact logged in - that variable is not present when using anonymous auth. 在访问LOGON_USER变量之前,必须确保用户实际上已经登录-使用匿名身份验证时该变量不存在。

In your web.config change the auth mode to 在您的web.config中,将身份验证模式更改为

<authentication mode="Forms" />

Windows is also a valid alternative for Forms if you wish to use it. 如果您希望使用Windows,它也是Forms的有效替代方法。

Have a look here for more info 在这里看看更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM