Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4056398
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:49:21+00:00 2026-05-20T14:49:21+00:00

My question is similar to this question . I hope I can provide some

  • 0

My question is similar to this question. I hope I can provide some more detail and context to get it answered.

So here’s some context: I have a simple in-house silverlight (ver 4) app with WCF Ria services that I’m building for our small support team. It uses authentication against a third-party vended database, but all other user information, e.g. FriendlyName and Roles (only 1 role per user) comes from our own database. I’m trying to keep this simple and don’t want to implement custom membership and role providers.

I have few domain service operations that I want to restrict to certain roles, so I tried using the RequiresRole attribute like so:

[RequiresRole("Admin", "HelpDesk", "Billing" )]
public RisStudyInfo GetStudyInfo(string accession) {
    return ris.GetStudyInfo(accession);
}

On the client side WebContext.Current.User.IsInRole("Admin") returns true, but I always get access denied when calling the service. The RequiresAuthentication attribute works as expected.

Below is the implementation of my AuthenticationService. The User class simply inherits from UserBase and adds the FriendlyName property. Any ideas what I’m doing wrong?

[EnableClientAccess]
public class AuthenticationService : AuthenticationBase<User> {

    UserDataService userData = new UserDataService();

    protected override bool ValidateUser(string userName, string password) {
        var auth = new DatabaseAuthenticator();
        return auth.Authenticate(userName, password);
    }

    protected override User GetAuthenticatedUser(IPrincipal principal) {
        User user = null;
        if (principal.Identity.IsAuthenticated) {
            user = new User();
            user.FriendlyName = userData.GetFriendlyName(principal.Identity.Name);
            user.Name = principal.Identity.Name;
            user.Roles = GetRolesFor(user.Name);
        }
        return user;
    }

    private IEnumerable<string> GetRolesFor(string username) {

        IList<string> roles = new List<string>();

        string role = userData.GetRolesFor(username);
        if (role != null)
            roles.Add(role);

        return roles;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:49:22+00:00Added an answer on May 20, 2026 at 2:49 pm

    Figured it out. At least 2 things wrong. First clue found here. The second clue here

    1.Turns out I really do need to write a custom role provider. Only need to implement GetRolesForUser though.

    public override string[] GetRolesForUser(string username) {
       return new string[] { _userService.GetRolesFor(username) };
    }    
    

    2.Configure the custom role provider correctly in the web.config

    <roleManager cacheRolesInCookie="true" enabled="true" defaultProvider="MyRoleProvider">
        <providers>
          <add name="MyRoleProvider" type="MyProject.Web.Providers.MyRoleProvider, MyProject.Web"/>
        </providers>
    </roleManager>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I already asked similar question here, but I still get some errors, so I
Question similar to this: select from two tables where linked column can be null
I have a question similar to this: how to manually assign imagefield in Django
I have asked a question similar to this in the past but this is
Question is similar to this , earlier question Which Dimitre has answered already. There
I found this similar question here , but this is really old. Was it
To keep it simple, my question is similar to THIS QUESTION, PART 2 ,
My question is similar to this question . Though I have not been able
I have made a question which is a bit similar to this, though the
I'm looking for an answer to a question similar to this one: protect users'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.