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. Retrieving Username

Retrieving Username

Scheduled Pinned Locked Moved C#
csharpsecuritywcfhelpquestion
4 Posts 3 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.
  • B Offline
    B Offline
    briby
    wrote on last edited by
    #1

    Hi I'm new to C# & .Net and the wonderful world of web services so forgive me if this is a simple and/or stupid question :doh: The WebService we are writing needs to determine which user is using it. We are using Digest Authentication (thus handled by Windows before it hits the service) so the user/password login prompt is already taken care of. But how do we determine the user from within the code after this. I tried using, System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() but this just returned NT AUTHORITY\SYSTEM which is of no real use when I know I typed in TEST1 as the username. :confused: Any help would be gratefully received - Thanks in advance Brian

    H A 2 Replies Last reply
    0
    • B briby

      Hi I'm new to C# & .Net and the wonderful world of web services so forgive me if this is a simple and/or stupid question :doh: The WebService we are writing needs to determine which user is using it. We are using Digest Authentication (thus handled by Windows before it hits the service) so the user/password login prompt is already taken care of. But how do we determine the user from within the code after this. I tried using, System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() but this just returned NT AUTHORITY\SYSTEM which is of no real use when I know I typed in TEST1 as the username. :confused: Any help would be gratefully received - Thanks in advance Brian

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You must set up impersonation in your Web.config file. See the documentation on the <identity> config section in the .NET Framework SDK.

      Microsoft MVP, Visual C# My Articles

      1 Reply Last reply
      0
      • B briby

        Hi I'm new to C# & .Net and the wonderful world of web services so forgive me if this is a simple and/or stupid question :doh: The WebService we are writing needs to determine which user is using it. We are using Digest Authentication (thus handled by Windows before it hits the service) so the user/password login prompt is already taken care of. But how do we determine the user from within the code after this. I tried using, System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() but this just returned NT AUTHORITY\SYSTEM which is of no real use when I know I typed in TEST1 as the username. :confused: Any help would be gratefully received - Thanks in advance Brian

        A Offline
        A Offline
        Atilla Ozgur
        wrote on last edited by
        #3

        In you case I think windows has Authenticated your user and it is using NT AUTHORITY\SYSTEM to run your code.You have to use impersonation so that when you use that code line you will get correct user. Second solution could be to implement IPrincipal and explicitly set user information. Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition. Frank Herbert

        B 1 Reply Last reply
        0
        • A Atilla Ozgur

          In you case I think windows has Authenticated your user and it is using NT AUTHORITY\SYSTEM to run your code.You have to use impersonation so that when you use that code line you will get correct user. Second solution could be to implement IPrincipal and explicitly set user information. Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition. Frank Herbert

          B Offline
          B Offline
          briby
          wrote on last edited by
          #4

          Hi thanks for your reply. I seem to have found a solution by using Context.User.Identity.Name which returns the userid I was expecting of it Thanks once again

          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