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. C#
  4. Securing a web method

Securing a web method

Scheduled Pinned Locked Moved C#
question
4 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.
  • K Offline
    K Offline
    KaurGurpreet
    wrote on last edited by
    #1

    Is it possible to have few secure and few unsecure web methods within a webservice. If yes, how?

    Gurpreet

    S 1 Reply Last reply
    0
    • K KaurGurpreet

      Is it possible to have few secure and few unsecure web methods within a webservice. If yes, how?

      Gurpreet

      S Offline
      S Offline
      SarahMcM
      wrote on last edited by
      #2

      Put the security within the webmethod call itself. I have a service that does that .. some methods are "public" others are only accessible by users in particular security groups. So the secure web methods have an if around all the code that checks if the user is allowed to use it. The Webservice implements Integrated Windows Authentication so the user's identity is available and I have a procedure that decides whether a user is authorised or not.

      K 1 Reply Last reply
      0
      • S SarahMcM

        Put the security within the webmethod call itself. I have a service that does that .. some methods are "public" others are only accessible by users in particular security groups. So the secure web methods have an if around all the code that checks if the user is allowed to use it. The Webservice implements Integrated Windows Authentication so the user's identity is available and I have a procedure that decides whether a user is authorised or not.

        K Offline
        K Offline
        KaurGurpreet
        wrote on last edited by
        #3

        Could you provide me some example / code snippet to do that.

        Gurpreet

        S 1 Reply Last reply
        0
        • K KaurGurpreet

          Could you provide me some example / code snippet to do that.

          Gurpreet

          S Offline
          S Offline
          SarahMcM
          wrote on last edited by
          #4

          Well, not really because I don't know how you want to secure it. In my webmethods I have eg

          if (isUserAuthorised(this.User.Identity.Name))
          {
          //do stuff in the web method

          } else
          {
          //return that they're unauthorised
          }

          The isUserAuthorised method takes a string that is the user name and you can then do whatever you want to determine if they are infact allowed access. It depends on how you secure things. If you use AD groups then check whether the user is in the appropriate group (google for DirectoryEntry - there should be loads of examples out there and you'd be looking for something with objGroup.Invoke("IsMember" ...) I can't remember the exact syntax). If you have some database that says whether they're allowed in then call a stored procedure.

          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