IBS Portal真是经典的范例,实在值得好好研究。看看这两个Method:
//********************************************************************* // // PortalSecurity.IsInRole() Method // // The IsInRole method enables developers to easily check the role // status of the current browser client. // //********************************************************************* public static bool IsInRole(String role) { return HttpContext.Current.User.IsInRole(role); } //********************************************************************* // // PortalSecurity.IsInRoles() Method // // The IsInRoles method enables developers to easily check the role // status of the current browser client against an array of roles // //********************************************************************* public static bool IsInRoles(String roles) { HttpContext context = HttpContext.Current; foreach (String role in roles.Split( new char[] {';'} )) { if (role != "" && role != null && ((role == "All Users") || (context.User.IsInRole(role)))) { return true; } } return false; }