About IBS Portal
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;
}
评论 (3)
public bool IsInRole(params SchRole[] roles)
{
foreach(MyRole role in roles)
{
if (roleList.Contains( role.ToString() ))
return true;
}
return false;
}
比如BAN了此帐号,如果还在登陆中的话,帐号一切功能都正常,要等他退出以后,重新登陆才会起作用。
如果他不幸选择了保留Cookies,那就完蛋了,这俩方法根本不能控制……所以我把他们改造了,HOHO
发表评论