Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. Move PrincipalPermission from service code to app.config. [modified]

Move PrincipalPermission from service code to app.config. [modified]

Scheduled Pinned Locked Moved WCF and WF
csharpwcfhostinghelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Calla
    wrote on last edited by
    #1

    In my WCF Service I have implemented the methods of a contract called IFoo in Foo.cs, and I have used PrincipalPermission to set the Authorization of incoming calls. For instance:

    [PrincipalPermission(SecurityAction.Demand, Role = "Administrators")] //Move this setting to app.config
    public void FooMethod()
    {
    ...
    ...
    }

    Now instead of programmatically defining which role (in this case Administrators) that are allowed to make calls to FooMethod, I'd like to define this in an app.config file instead in order to change the permissions needed without recompiling. I believed this to be an easy task, but I'm stuck. Googling and reading my otherwise so excellent WCF book has got me nowhere. Does anyone know how this can be achieved? I'm hosting my WCF Service as a Windows NT Service.

    modified on Thursday, August 26, 2010 7:05 AM

    L 1 Reply Last reply
    0
    • C Calla

      In my WCF Service I have implemented the methods of a contract called IFoo in Foo.cs, and I have used PrincipalPermission to set the Authorization of incoming calls. For instance:

      [PrincipalPermission(SecurityAction.Demand, Role = "Administrators")] //Move this setting to app.config
      public void FooMethod()
      {
      ...
      ...
      }

      Now instead of programmatically defining which role (in this case Administrators) that are allowed to make calls to FooMethod, I'd like to define this in an app.config file instead in order to change the permissions needed without recompiling. I believed this to be an easy task, but I'm stuck. Googling and reading my otherwise so excellent WCF book has got me nowhere. Does anyone know how this can be achieved? I'm hosting my WCF Service as a Windows NT Service.

      modified on Thursday, August 26, 2010 7:05 AM

      L Offline
      L Offline
      Ladislav Mrnka
      wrote on last edited by
      #2

      Hello, with default infrastructure it is not possible. I think it's a security hole. If you really want something similar check this article Best regards, Ladislav

      C 1 Reply Last reply
      0
      • L Ladislav Mrnka

        Hello, with default infrastructure it is not possible. I think it's a security hole. If you really want something similar check this article Best regards, Ladislav

        C Offline
        C Offline
        Calla
        wrote on last edited by
        #3

        Thank you for your reply. I'll look into the article to see if it helps. [edit: a few hours later...] This is the way to do it - though I will probably define and group my methods as "edit", "delete" etc. and in the app.config I'll define which user groups are allowed to perform what kind of actions. An "edit" contains both "Administrators" and "Power Users" and "delete" contains only "Administrators" and so forth.

        modified on Friday, August 27, 2010 4:03 AM

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups