📄 myuser.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic.ApplicationServices;
public partial class MyUser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//读取用户信息
Microsoft.VisualBasic.ApplicationServices.User user = new User();
user.InitializeWithWindowsUser();
int pos = user.Name.IndexOf("\\");
Response.Write("用户姓名:" + user.Name.Substring(pos + 1, user.Name.Length - pos - 1) + "<BR/>");
Response.Write("CurrentPrincipal:" + user.CurrentPrincipal + "<BR/>");
Response.Write("是否经过验证:" + user.IsAuthenticated + "<BR/>");
Response.Write("是否属于Administrator角色:" + user.IsInRole(BuiltInRole.Administrator) + "<BR/>");
///*您也可以使用下列方式
Response.Write("User Domain Name:" + System.Environment.UserDomainName + "<BR/>");
Response.Write("User Name:" + System.Environment.UserName + "<BR/>");
Response.Write("AuthenticationType:" + User.Identity.AuthenticationType + "<BR/>");
Response.Write("IsAuthenticated:" + User.Identity.IsAuthenticated + "<BR/>");
Response.Write("Name:" + User.Identity.Name + "<BR/>");
Response.Write("IsInRole:" + User.IsInRole("Administrator") + "<BR/>");
//* */
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -