public bool IsAuthorized(System.Security.Principal.IPrincipal user, IEnumerable<string> roles) { foreach(string role in roles) if(user.IsInRole(role)) return true; return false; }
public static bool Authorized(System.Security.Principal.IPrincipal user, string role) { if (user.IsInRole(SysAdminRole)) { return true; } string[] appGrp = role.Trim().Split(Group.CodeSep); if (appGrp.Length > 0) { string app = appGrp[0]; if (user.IsInRole(app)) { return true; } return user.IsInRole(role); } return false; }
private static bool MatchRole(System.Security.Principal.IPrincipal user, string role) { if (role == ALL_USERS) return true; else if (role == AUTHENTICATED_USERS) return user.Identity.IsAuthenticated; else return user.IsInRole(role); }
/// <summary> /// If any of the roles for the current user match with the Allowed roles for a particular resource (Folder\File.aspx) the user is allowed access. /// </summary> /// <param name="user">The user.</param> /// <param name="roles">List of allowed Role (configured for a particular resource{Folder\File.aspx}) to be compared with Input user's roles.</param> /// <returns> /// <c>true</c> if any of User's roles match with Allowed roles for a particular resource; otherwise, <c>false</c>. /// </returns> private bool MatchUserRolesToPermissions(System.Security.Principal.IPrincipal user, string[] roles) { if (user == null) return false; foreach (string role in roles) { if (user.IsInRole(role)) { return true; } } return false; }
public bool IsEditor(System.Security.Principal.IPrincipal principal) { return principal != null && principal.Identity.Name == "Editor" || principal.IsInRole("Editors"); }
public bool IsAdmin(System.Security.Principal.IPrincipal principal) { return principal != null && principal.Identity.Name == "Admin" || principal.IsInRole("Administrators"); }
/// <summary>Determines wether a user is permitted according to this role.</summary> /// <param name="user">The user to check.</param> /// <returns>True if the user is permitted.</returns> public virtual bool IsAuthorized(System.Security.Principal.IPrincipal user) { if (IsEveryone) return true; else if (user != null && user.IsInRole(Role)) return true; return false; }
public bool isAuthorized(System.Security.Principal.IPrincipal User, string albumid) { if (User.IsInRole("Friends")) return true; AlbumQuery query = new AlbumQuery(); PicasaEntry album = (PicasaEntry)service.Get( string.Format("http://picasaweb.google.com/data/entry/api/user/{0}/albumid/{1}", GetGUsername(), albumid) ); string summary = album.Summary.Text; if (summary.ToLower() == "coworkers" && User.IsInRole("Coworkers")) return true; if (summary.ToLower() == "all") return true; return false; }
public bool IsInRole(System.Security.Principal.IPrincipal user, string role) { return user.IsInRole(role); }
public static bool IsInRole(System.Security.Principal.IPrincipal principal, string role) { return principal.IsInRole(role); }
public bool IsAdmin(System.Security.Principal.IPrincipal principal) { return principal != null && string.Equals(principal.Identity.Name, "Admin", System.StringComparison.InvariantCultureIgnoreCase) || principal.IsInRole("Administrators"); }