本文整理汇总了C#中MonkeyWrench.DataClasses.Logic.WebServiceResponse.IsInRole方法的典型用法代码示例。如果您正苦于以下问题:C# WebServiceResponse.IsInRole方法的具体用法?C# WebServiceResponse.IsInRole怎么用?C# WebServiceResponse.IsInRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonkeyWrench.DataClasses.Logic.WebServiceResponse
的用法示例。
在下文中一共展示了WebServiceResponse.IsInRole方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyUserInRole
public static void VerifyUserInRole (HttpContext Context, DB db, WebServiceLogin login, string role, bool @readonly)
{
WebServiceResponse dummy = new WebServiceResponse ();
Authenticate (Context, db, login, dummy, @readonly);
if (!dummy.IsInRole (role)) {
log.InfoFormat ("The user '{0}' has the roles '{1}', and requested role is: {2}", login.User, dummy.UserRoles == null ? "<null>" : string.Join (",", dummy.UserRoles), role);
throw new UnauthorizedException ("You don't have the required permissions.");
}
}
示例2: VerifyUserInRole
public static void VerifyUserInRole (string remote_ip, DB db, WebServiceLogin login, string role, bool @readonly)
{
WebServiceResponse dummy = new WebServiceResponse ();
Authenticate (remote_ip, db, login, dummy, @readonly);
if (!dummy.IsInRole (role)) {
Logger.Log (2, "The user '{0}' has the roles '{1}', and requested role is: {2}", login.User, dummy.UserRoles == null ? "<null>" : string.Join (",", dummy.UserRoles), role);
throw new HttpException (403, "You don't have the required permissions.");
}
}
示例3: VerifyUserInRoles
public static void VerifyUserInRoles (HttpContext Context, DB db, WebServiceLogin login, string[] roles, bool @readonly)
{
WebServiceResponse dummy = new WebServiceResponse ();
Authenticate (Context, db, login, dummy, @readonly);
foreach (var role in roles) {
if (string.IsNullOrEmpty(role))
continue;
if (dummy.IsInRole(role))
return;
}
var userRoles = dummy.UserRoles == null ? "<null>" : string.Join(",", dummy.UserRoles);
var requestedRoles = roles == null ? "<null>" : string.Join(",", roles);
log.InfoFormat("The user '{0}' has the roles '{1}', and requested roles are: {2}", login.User, userRoles, requestedRoles);
throw new UnauthorizedException("You don't have the required permissions.");
}