windows系统登录用户名 在ASP.NET中使用Windows登录[1]
在ASP.NET中使用Windows登录[1]
——此文章摘自《ASP NET网络数据库开发实例精解》定价 ¥ 特价 ¥ 详细>>在目前流行的网上论坛中 网站或应用程序也可以使用用户的系统账户登录 该登录方式的好处就是用户一旦登录本身的操作系统之后 不再需要输入用户名称和密码 而是直接使用系统的登录名称和密码就可以直接登录网站或应用程序 因此该登录方式可以集成用户操作系统内部的登录信息
本实例介绍如何使用ASP NET实现用户使用操作系统的系统账户登录网站或应用程序的方法 还介绍了如何在ASP NET中调用Windows API
.创建新ASP NET应用程序
在Visual Studio NET 集成开发环境中创建新的ASP NET Web应用程序 命名为Example_ _
![windows系统登录用户名 在ASP.NET中使用Windows登录[1]](http://img.zhputi.com/uploads/2c05/2c0537d91643d06a9cb496bf90837a0a15045.jpg)
.设计页面WindowsLogin aspx
把应用程序Example_ _ 的默认页面WebForm aspx重命名为 WindowsLogin aspx 并在页面上添加 个TextBox控件 个Button控件和 个Label控件 它们的名称分别为 tUserName tPassword tDomain UserLoginBtn CancelBtn和LoginMsg
控件tUserName tPassword和tDomain分别用来输入用户的名称 密码以及系统所在的域名 控件UserLoginBtn和CancelBtn分别用来实现用户登录和取消登录 控件LoginMsg用来显示用户登录成功的消息 页面 WindowsLogin aspx的设计界面如图 所示
图 页面WindowsLogin aspx的设计界面
页面WindowsLogin aspx的HTML设计代码如下 <asp:TextBox id= tUserName runat= server width= ></asp:TextBox> <asp:TextBox id= tPassword runat= server width= TextMode= Password ></asp:TextBox> <asp:TextBox id= tDomain runat= server width= ></asp:TextBox> <asp:Button id= UserLoginBtn runat= server Text= 确 定 ></asp:Button> <asp:Button id= CancelBtn runat= server Text= 取 消 ></asp:Button> <asp:Label id= LoginMsg runat= server ForeColor= Red Width= % Visible= False ></asp:Label>
lishixinzhi/Article/program/net/201311/15541