使用 ASP.NET Windows 身份验证 & Impersonation,
// Enable windows authentication & impersonation
在 Web.Config 文件中添加下面的应用程序角色,默认情况下用户属于 Everyone 组
// Assign application roles
在代码中检查用户是否属于指定的应用程序角色,例如“Admins”。
// Check if user is in Admins role if (HttpContext.Current.User.IsInRole("Admins")) { // Allow access to admin features } else { // Redirect to an error page or deny access }