public void AssertHasRole(string role, string username, string password) { ConfigureAuthProviders(); if (string.IsNullOrEmpty(username)) { throw new Exception("Brukernavn mangler."); } if (string.IsNullOrEmpty(password)) { throw new Exception("Passord mangler."); } if (!membershipProvider.ValidateUser(username, password)) { throw new UnauthorizedAccessException(); } if (roleProvider.IsUserInRole(username, "Administrator")) { return; } if (!role.Equals("Dataleverandør")) { throw new UnauthorizedAccessException(); } if (roleProvider.IsUserInRole(username, "Dataleverandør")) { return; } throw new UnauthorizedAccessException(); }