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 8480475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:18:16+00:00 2026-06-10T19:18:16+00:00

Common problem: How to implement user access rights differentiation system in any .NET application

  • 0

Common problem: How to implement user access rights differentiation system in any .NET application (for example, WCF application) by using class/method attributes?

So, we have:

  1. A set of users
  2. A set of roles (for example, enum Role)
  3. Every user have his own set of his roles.
  4. Every class/method could be specified for particular role.

    [AuthorizationAttribute(Roles = new Role[] { Role.Admin })]
    public class UserService : IUserService
    {

    }

  5. If user’s set of roles doesn’t contain this role, user mustn’t have access to the method.

Update. I’ve tried to make the problem description more clear. The Akton’s solution is good for this problem.

  • 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-06-10T19:18:17+00:00Added an answer on June 10, 2026 at 7:18 pm

    It is possible to create an attributed security model like you suggest but it is not easy. Your securable objects have to inherit from ContextBoundObject and your security attribute from ContextAttribute (or implement the IContextAttribute interface). Then:

    1. Implement the IContextAttribute.GetPropertiesForNewContext(IConstructionCallMessage) method. You create an object, call it MySecurityProperty, that implements the IContextProperty and IContributeObjectSink interfaces and add it to the IConstructionCallMessage.ContextProperties collection.
    2. In the implementation of MySecurityProperty.GetObjectSink(MarshalByRefObject, IMessageSink) construct an object, call it MySecurityAspect, that implements the IMessageSink interface.
    3. In the implementation of MySecurityAspect.SyncProcessMessage(IMessage), you actually check the call to see whether it is valid. If it casts to IMethodMessage, indicating a method call, you can query the properties of IMethodMessage to see whether it is calling a method or class with your security attribute and do the appropriate checks. If the call is unauthorized, throw an exception of the appropriate type.

    It will take you a few hours to get it working but, once it does, it makes sense. It is just a very undersupported part of the .Net framework. The big problem, beyond the complexity, is that it forces your securable classes to inherit from ContextBoundObject rather than any other library classes. ContextBoundObject also inherits from MarshalByRef, which can interfere with serialization.

    See http://www.developerfusion.com/article/5307/aspect-oriented-programming-using-net/3/ for a more in depth explanation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following tables to implement subtypes, which is a very common
I am building a community website using Grails and I want to implement user
I have two Java class hierarchies that share a common ancestor and implement a
It seems a very common problem. But I couldn't find any working solution. We
Let's imagine any common operation being executed on website. After user presses button the
Common problem I'm sure, but I can't figure it out. In my AndroidManifest.xml and
A common problem is that for validation you need to run the same code
This is a common problem for me. I make five or so commits then
It's a common problem, solved many times, but for some reason i cannot find
This is a fairly common problem, it probably has a name, I just don't

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.