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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:46:24+00:00 2026-05-31T03:46:24+00:00

I need to implement some kind of RBAC for a WPF app that I’m

  • 0

I need to implement some kind of RBAC for a WPF app that I’m writing at the moment. Since v2.0 ASP.NET has had the Security, Membership and Role Management infrastructure (as described here for example) and while I could use that it still feels that to use it in this context would be a bit hacky. I’ll welcome feedback from anyone who has used it and had success in a similar context.

I’ve also considered using AD LDS, read the TechNet articles and looked at some of the MSDN code samples but I’m wondering if there’s any component (for .NET) out there that removes some of the inherent complexity behind creating the database, setting it up for deployment and the on-going maintenance. Free or commercial is okay in this instance.

Other questions on SO mention Client Application Services but this entails adding IIS into the mix, which, while not beyond the bounds of possibility, was something I didn’t envisage at the outset of the project.

What are the best practices in this case? The app is a typical n-tier type affair, which talks to a remote SQL Server database so the roles could be stored there if needs be

  • 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-31T03:46:26+00:00Added an answer on May 31, 2026 at 3:46 am

    You could have a look at the P&P guidance / code for ideas (or you could use their block perhaps). http://msdn.microsoft.com/en-us/library/ff953196(v=pandp.50).aspx

    I implemented my own back-end store in SQLServer. Its not that hard, tables like User,UserRole,SecurityItem,SecurityItemUser,SecurityItemRole. I authenticate the user’s windows login against AD, but only store their windows login name in the database (eg the key for the User table).

    It is a good idea to abstract things away via interfaces / provider model. That way if your app changes in the future, it won’t require much refactoring.

    I built a 2 tier app (WPF -> SQLServer) that grew a lot, and management have decided for security they now want a 3 tier app (WCF middle tier). I am working on this now, and it is a real pain because I coupled my authorization code too closely with the client app. It is apparent now that the authorization should be happening in the service tier, but will require a lot of work.

    In terms of how to identify a particular ‘securable’, I came up with a nice trick that saves a lot of work. Although, ironically this is part of the problem I now have trying to re-engineer it for 3 tiers. The trick is to use the fully qualified name of the class as a unique identifier for a securable, then you can use some simple code each time you check :

    _secUtil.PromptSecurityCheck(_secUtil.GetFullyQualifiedObjectName(this, "Save"))
    

    Here is some other code to give you an idea how I did it (using P&P framework).

    public class SecurityUtil : ISecurityUtil
    {
        public string DatabaseUserName { get { return LocalUserManager.GetUserName(); } }
    
        public bool PromptSecurityCheck(string securityContext)
        {
            bool ret = IsAuthorized(securityContext);
    
            if (!ret)
            {
                MessageBox.Show(string.Format("You are not authorised to perform the action '{0}'.", securityContext), Settings.Default.AppTitle,
                                            MessageBoxButton.OK, MessageBoxImage.Error);
            }
    
            return ret;
        }
    
        public bool IsAuthorized(string securityContext)
        {
            IAuthorizationProvider ruleProvider = AuthorizationFactory.GetAuthorizationProvider("MyAuthorizationProvider");
    
            //bool ret = ruleProvider.Authorize(LocalUserManager.GetThreadPrinciple(), securityContext);
            bool ret = ruleProvider.Authorize(LocalUserManager.GetCurrentPrinciple(), securityContext);            
            return ret;
        }
    
        public string GetFullyQualifiedName(object element)
        {
            return element.GetType().FullName;
        }
    
        public string GetFullyQualifiedObjectName(object hostControl, string objectName)
        {
            return GetFullyQualifiedName(hostControl) + "." + objectName;
        }
    }
    
    [ConfigurationElementType(typeof(CustomAuthorizationProviderData))]
    public class MyAuthorizationProvider : AuthorizationProvider
    {
        public SitesAuthorizationProvider(NameValueCollection configurationItems)
        {
        }
    
        public override bool Authorize(IPrincipal principal, string context)
        {
    
            bool ret = false;
    
            if (principal.Identity.IsAuthenticated)
            {
                // check the security item key, otherwise check the screen uri
                ret = LocalCacheManager.GetUserSecurityItemsCache(LocalUserManager.UserId, false).Exists(
                    si => si.SecurityItemKey.Equals(context, StringComparison.InvariantCultureIgnoreCase));
    
                if (!ret)
                {
                    // check if this item matches a screen uri
                    ret = LocalCacheManager.GetUserSecurityItemsCache(LocalUserManager.UserId, false).Exists(
                    si => si.Uri.Equals(context, StringComparison.InvariantCultureIgnoreCase));
                }
            }
    
            return ret;
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement some kind of metric space search in Postgres(*) (PL or
Hey, i'm extending some WPF controls, and need to implement some custom events. I've
I need to implement something. Something that could do some certain task in my
I am trying to implement some kind of console menu wich has to retrieve
i need to implement some kind of bit to status mapping and i don't
I have an ASP.NET page that has three div s within the only form
Suppose there is a business function you need to implement, which sets some kind
I need to implement some form of communication mechanism in my application, to send
To implement data access code in our application we need some framework to wrap
So, I need some way to implement an undirected network ( I think this

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.