在ASP.NET中将Windows身份验证与活动目录一起使用 [英] Using windows authentication with active directory in ASP.NET

查看:52
本文介绍了在ASP.NET中将Windows身份验证与活动目录一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在尝试创建一个登录页面,该页面允许用户在2个文本框中输入他的Windows用户ID和密码,以在站点中记录用户.
文本框是:
txtUserId和txtPassword
现在我想做以下算法:
如果txtUserId.Text = Windows用户ID和txtPassword.Text = Windows密码,则转到下一页
否则显示一条消息错误的用户名或密码."

有人可以帮我吗?

谢谢.

Hi all
I''m trying to create a login page that allows user to enter his windows user id and password in 2 text boxes to logs user in the site.
Text boxes are:
txtUserId, and txtPassword
now I want to do the following algorithm:
if txtUserId.Text = windows user id AND txtPassword.Text = windows password Then go to next page
otherwise display a message "Wrong User ID or Password."

Can anybody helps me?

Thak you.

推荐答案

尝试:
public bool CheckAuthentication()
{      
      System.Security.Principal.IPrincipal currUser;
      bool isCurrentUserAuthenticated = false;
            
      currUser = System.Web.HttpContext.Current.User;
      if (currUser.Identity.IsAuthenticated)
      {
            // Do stuff related to authenticated case
            isCurrentUserAuthenticated = true;
      }
      else
      {
             // Do stuff related to NOT authenticated case
      }      
      return isCurrentUserAuthenticated ;
}


看看这篇文章.阅读.它告诉所有以及如何启用Windows身份验证并起作用:
在ASP.NET中实现Windows身份验证 [链接1 [链接2 [
Have a look at this article. Read it. It tell all and how windows authentication can be enabled and works:
Windows Authentication implemented in ASP.NET[^]

Details on Windows authentication here:
Link 1[^]
Link 2[^]


这篇关于在ASP.NET中将Windows身份验证与活动目录一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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