Environment.UserName

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SGVsZW4gVHJpbQ==?=

    Environment.UserName

    I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
    our intranet. I want to identify users to save them logging in.

    The line:

    UserName = Environment.Use rName

    is returning "ASPNET", instead of my user name.

    I have read all the Help documentation, but I can't find any reason why this
    isn't working.

    Am I missing a reference or import? I have added a reference to
    System.Security .dll. My imports are:

    Imports System

    Imports System.Configur ation

    Imports System.Security .Principal

    Imports System.Security .Permissions

    Imports System.Threadin g

    Thanks for your help,

    Helen
  • Patrice

    #2
    Re: Environment.Use rName

    What if you try System.Web.Http Context.Current .User.Identity. Name instead ?

    System.Environm ent is rather related to the server side Windows process
    rather than to the IIS context for a web connexion....

    --
    Patrice

    "Helen Trim" <HelenTrim@disc ussions.microso ft.coma écrit dans le message
    de groupe de discussion :
    3C128B85-81D3-492A-B75D-F848AB618EC9@mi crosoft.com...
    I am developing a web application in Visual Studio 2003, .NET 1.1 to run
    on
    our intranet. I want to identify users to save them logging in.
    >
    The line:
    >
    UserName = Environment.Use rName
    >
    is returning "ASPNET", instead of my user name.
    >
    I have read all the Help documentation, but I can't find any reason why
    this
    isn't working.
    >
    Am I missing a reference or import? I have added a reference to
    System.Security .dll. My imports are:
    >
    Imports System
    >
    Imports System.Configur ation
    >
    Imports System.Security .Principal
    >
    Imports System.Security .Permissions
    >
    Imports System.Threadin g
    >
    Thanks for your help,
    >
    Helen

    Comment

    • =?Utf-8?B?SGVsZW4gVHJpbQ==?=

      #3
      Re: Environment.Use rName

      Hello Patrice

      Thanks for your reply. I tried this, but it gave me an empty string.

      Any more ideas, please?

      Regards
      Helen


      "Patrice" wrote:
      What if you try System.Web.Http Context.Current .User.Identity. Name instead ?
      >
      System.Environm ent is rather related to the server side Windows process
      rather than to the IIS context for a web connexion....
      >
      --
      Patrice
      >
      "Helen Trim" <HelenTrim@disc ussions.microso ft.coma crit dans le message
      de groupe de discussion :
      3C128B85-81D3-492A-B75D-F848AB618EC9@mi crosoft.com...
      I am developing a web application in Visual Studio 2003, .NET 1.1 to run
      on
      our intranet. I want to identify users to save them logging in.

      The line:

      UserName = Environment.Use rName

      is returning "ASPNET", instead of my user name.

      I have read all the Help documentation, but I can't find any reason why
      this
      isn't working.

      Am I missing a reference or import? I have added a reference to
      System.Security .dll. My imports are:

      Imports System

      Imports System.Configur ation

      Imports System.Security .Principal

      Imports System.Security .Permissions

      Imports System.Threadin g

      Thanks for your help,

      Helen
      >
      >

      Comment

      • Joergen Bech

        #4
        Re: Environment.Use rName


        ASPNET is the default "user name" the ASP.Net process uses
        to log into the IIS service.

        Nothing to do with the user browsing your pages.

        Regards,

        Joergen Bech



        On Wed, 4 Jun 2008 07:55:01 -0700, Helen Trim
        <HelenTrim@disc ussions.microso ft.comwrote:
        >Hello Patrice
        >
        >Thanks for your reply. I tried this, but it gave me an empty string.
        >
        >Any more ideas, please?
        >
        >Regards
        >Helen
        >
        >
        >"Patrice" wrote:
        >
        >What if you try System.Web.Http Context.Current .User.Identity. Name instead ?
        >>
        >System.Environ ment is rather related to the server side Windows process
        >rather than to the IIS context for a web connexion....
        >>
        >--
        >Patrice
        >>
        >"Helen Trim" <HelenTrim@disc ussions.microso ft.coma crit dans le message
        >de groupe de discussion :
        >3C128B85-81D3-492A-B75D-F848AB618EC9@mi crosoft.com...
        I am developing a web application in Visual Studio 2003, .NET 1.1 to run
        on
        our intranet. I want to identify users to save them logging in.
        >
        The line:
        >
        UserName = Environment.Use rName
        >
        is returning "ASPNET", instead of my user name.
        >
        I have read all the Help documentation, but I can't find any reason why
        this
        isn't working.
        >
        Am I missing a reference or import? I have added a reference to
        System.Security .dll. My imports are:
        >
        Imports System
        >
        Imports System.Configur ation
        >
        Imports System.Security .Principal
        >
        Imports System.Security .Permissions
        >
        Imports System.Threadin g
        >
        Thanks for your help,
        >
        Helen
        >>
        >>

        Comment

        • Patrice

          #5
          Re: Environment.Use rName

          So IsAuthenticated is false ? Do you have an auhtentication method in place
          on your site ?

          If not try :



          --
          Patrice

          "Helen Trim" <HelenTrim@disc ussions.microso ft.coma écrit dans le message
          de groupe de discussion :
          9C7525B3-2AB9-4227-A3F9-90D988B2F764@mi crosoft.com...
          Hello Patrice
          >
          Thanks for your reply. I tried this, but it gave me an empty string.
          >
          Any more ideas, please?
          >
          Regards
          Helen
          >
          >
          "Patrice" wrote:
          >
          >What if you try System.Web.Http Context.Current .User.Identity. Name instead
          >?
          >>
          >System.Environ ment is rather related to the server side Windows process
          >rather than to the IIS context for a web connexion....
          >>
          >--
          >Patrice
          >>
          >"Helen Trim" <HelenTrim@disc ussions.microso ft.coma crit dans le message
          >de groupe de discussion :
          >3C128B85-81D3-492A-B75D-F848AB618EC9@mi crosoft.com...
          I am developing a web application in Visual Studio 2003, .NET 1.1 to
          run
          on
          our intranet. I want to identify users to save them logging in.
          >
          The line:
          >
          UserName = Environment.Use rName
          >
          is returning "ASPNET", instead of my user name.
          >
          I have read all the Help documentation, but I can't find any reason why
          this
          isn't working.
          >
          Am I missing a reference or import? I have added a reference to
          System.Security .dll. My imports are:
          >
          Imports System
          >
          Imports System.Configur ation
          >
          Imports System.Security .Principal
          >
          Imports System.Security .Permissions
          >
          Imports System.Threadin g
          >
          Thanks for your help,
          >
          Helen
          >>
          >>

          Comment

          • Joe Duchtel

            #6
            Re: Environment.Use rName

            Hello -

            What about using Dim lUser =
            Environment.Get EnvironmentVari able("USERNAME" )?

            Joe



            On Jun 4, 11:18 am, "Patrice" <http://www.chez.com/scribe/wrote:
            So IsAuthenticated is false ? Do you have an auhtentication method in place
            on your site ?
            >
            If not try :
            >
            http://www.microsoft.com/technet/pro...ver2003/Librar...
            >
            --
            Patrice
            >
            "Helen Trim" <HelenT...@disc ussions.microso ft.coma écrit dans le message
            de groupe de discussion :
            9C7525B3-2AB9-4227-A3F9-90D988B2F...@mi crosoft.com...
            >
            >
            >
            Hello Patrice
            >
            Thanks for your reply.  I tried this, but it gave me an empty string.
            >
            Any more ideas, please?
            >
            Regards
            Helen
            >
            "Patrice" wrote:
            >
            What if you try System.Web.Http Context.Current .User.Identity. Name instead
            ?
            >
            System.Environm ent is rather related to the server side Windows process
            rather than to the IIS context for a web connexion....
            >
            --
            Patrice
            >
            "Helen Trim" <HelenT...@disc ussions.microso ft.coma crit dans le message
            de groupe de discussion :
            3C128B85-81D3-492A-B75D-F848AB618...@mi crosoft.com...
            I am developing a web application in Visual Studio 2003, .NET 1.1 to
            run
            on
            our intranet.  I want to identify users to save them logging in.
            >
            The line:
            >
            UserName = Environment.Use rName
            >
            is returning "ASPNET", instead of my user name.
            >
            I have read all the Help documentation, but I can't find any reason why
            this
            isn't working.
            >
            Am I missing a reference or import?  I have added a reference to
            System.Security .dll.  My imports are:
            >
            Imports System
            >
            Imports System.Configur ation
            >
            Imports System.Security .Principal
            >
            Imports System.Security .Permissions
            >
            Imports System.Threadin g
            >
            Thanks for your help,
            >
            Helen- Hide quoted text -
            >
            - Show quoted text -

            Comment

            • Patrice

              #7
              Re: Environment.Use rName

              Would be likely the same. Environment is not related with the web context
              but with the server side process that runs ASP.NET...

              Step 1 is to make sure an authentication method is actually configured.
              Step 2 is then to get the user identity from System.web.Http Context.User
              (which is also exposed on web pages).

              User authentication is dealt between the browser and IIS, it does not
              necessarily have something to do with the identity that actually runs
              ASP.NET processes server side...

              --
              Patrice


              "Joe Duchtel" <duchtel@gmail. coma écrit dans le message de groupe de
              discussion :
              976504ad-9584-4f67-a050-2b843c9849cd...l egroups.com...
              Hello -
              >
              What about using Dim lUser =
              Environment.Get EnvironmentVari able("USERNAME" )?
              >
              Joe
              >
              >
              >
              On Jun 4, 11:18 am, "Patrice" <http://www.chez.com/scribe/wrote:
              >So IsAuthenticated is false ? Do you have an auhtentication method in
              >place
              >on your site ?
              >>
              >If not try :
              >>
              >http://www.microsoft.com/technet/pro...ver2003/Librar...
              >>
              >--
              >Patrice
              >>
              >"Helen Trim" <HelenT...@disc ussions.microso ft.coma écrit dans le
              >message
              >de groupe de discussion :
              >9C7525B3-2AB9-4227-A3F9-90D988B2F...@mi crosoft.com...
              >>
              >>
              >>
              Hello Patrice
              >>
              Thanks for your reply. I tried this, but it gave me an empty string.
              >>
              Any more ideas, please?
              >>
              Regards
              Helen
              >>
              "Patrice" wrote:
              >>
              >What if you try System.Web.Http Context.Current .User.Identity. Name
              >instead
              >?
              >>
              >System.Environ ment is rather related to the server side Windows
              >process
              >rather than to the IIS context for a web connexion....
              >>
              >--
              >Patrice
              >>
              >"Helen Trim" <HelenT...@disc ussions.microso ft.coma crit dans le
              >message
              >de groupe de discussion :
              >3C128B85-81D3-492A-B75D-F848AB618...@mi crosoft.com...
              I am developing a web application in Visual Studio 2003, .NET 1.1 to
              run
              on
              our intranet. I want to identify users to save them logging in.
              >>
              The line:
              >>
              UserName = Environment.Use rName
              >>
              is returning "ASPNET", instead of my user name.
              >>
              I have read all the Help documentation, but I can't find any reason
              why
              this
              isn't working.
              >>
              Am I missing a reference or import? I have added a reference to
              System.Security .dll. My imports are:
              >>
              Imports System
              >>
              Imports System.Configur ation
              >>
              Imports System.Security .Principal
              >>
              Imports System.Security .Permissions
              >>
              Imports System.Threadin g
              >>
              Thanks for your help,
              >>
              Helen- Hide quoted text -
              >>
              >- Show quoted text -
              >

              Comment

              • Cor Ligthert[MVP]

                #8
                Re: Environment.Use rName

                Helen,

                The user that is running a WebApplication is ASPNET.

                A user that is using the WebApplication is in fact unknown on your
                environment, it can be thousands. Normally this is handled by a logon
                procedure where you set the user after the authentiated login in in a
                session.

                As you wish, you can avoid the next login procedure by using cookies.
                However every user from the client computer even a malicious one can then
                login on your application.

                Cor

                "Helen Trim" <HelenTrim@disc ussions.microso ft.comschreef in bericht
                news:3C128B85-81D3-492A-B75D-F848AB618EC9@mi crosoft.com...
                >I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
                our intranet. I want to identify users to save them logging in.
                >
                The line:
                >
                UserName = Environment.Use rName
                >
                is returning "ASPNET", instead of my user name.
                >
                I have read all the Help documentation, but I can't find any reason why
                this
                isn't working.
                >
                Am I missing a reference or import? I have added a reference to
                System.Security .dll. My imports are:
                >
                Imports System
                >
                Imports System.Configur ation
                >
                Imports System.Security .Principal
                >
                Imports System.Security .Permissions
                >
                Imports System.Threadin g
                >
                Thanks for your help,
                >
                Helen

                Comment

                • Michel Posseth  [MCP]

                  #9
                  Re: Environment.Use rName


                  Hello ,,,


                  The process is running in the server context ,,, however on a corporate
                  network you could use windows authentication and so determine wich user is
                  logged on to the website


                  "Helen Trim" <HelenTrim@disc ussions.microso ft.comschreef in bericht
                  news:3C128B85-81D3-492A-B75D-F848AB618EC9@mi crosoft.com...
                  >I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
                  our intranet. I want to identify users to save them logging in.
                  >
                  The line:
                  >
                  UserName = Environment.Use rName
                  >
                  is returning "ASPNET", instead of my user name.
                  >
                  I have read all the Help documentation, but I can't find any reason why
                  this
                  isn't working.
                  >
                  Am I missing a reference or import? I have added a reference to
                  System.Security .dll. My imports are:
                  >
                  Imports System
                  >
                  Imports System.Configur ation
                  >
                  Imports System.Security .Principal
                  >
                  Imports System.Security .Permissions
                  >
                  Imports System.Threadin g
                  >
                  Thanks for your help,
                  >
                  Helen

                  Comment

                  • =?Utf-8?B?SGVsZW4gVHJpbQ==?=

                    #10
                    RE: Environment.Use rName

                    Thanks for your advice, everyone. I found the answer by following the link
                    from Patrice. Turning off anonymous access in IIS solved the problem.

                    Regards
                    Helen

                    "Helen Trim" wrote:
                    I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
                    our intranet. I want to identify users to save them logging in.
                    >
                    The line:
                    >
                    UserName = Environment.Use rName
                    >
                    is returning "ASPNET", instead of my user name.
                    >
                    I have read all the Help documentation, but I can't find any reason why this
                    isn't working.
                    >
                    Am I missing a reference or import? I have added a reference to
                    System.Security .dll. My imports are:
                    >
                    Imports System
                    >
                    Imports System.Configur ation
                    >
                    Imports System.Security .Principal
                    >
                    Imports System.Security .Permissions
                    >
                    Imports System.Threadin g
                    >
                    Thanks for your help,
                    >
                    Helen

                    Comment

                    • Michel Posseth  [MCP]

                      #11
                      Re: Environment.Use rName


                      By switching of anonymous access you are actually using windows
                      authentication , note that unknown users from outside your known corporate
                      environment ( active directory ? ) cannot access the website unless you
                      activate some kind of authentication

                      regards

                      Michel


                      "Helen Trim" <HelenTrim@disc ussions.microso ft.comschreef in bericht
                      news:4AC145DC-1306-41D8-B674-404EA176A45F@mi crosoft.com...
                      Thanks for your advice, everyone. I found the answer by following the
                      link
                      from Patrice. Turning off anonymous access in IIS solved the problem.
                      >
                      Regards
                      Helen
                      >
                      "Helen Trim" wrote:
                      >
                      >I am developing a web application in Visual Studio 2003, .NET 1.1 to run
                      >on
                      >our intranet. I want to identify users to save them logging in.
                      >>
                      >The line:
                      >>
                      >UserName = Environment.Use rName
                      >>
                      >is returning "ASPNET", instead of my user name.
                      >>
                      >I have read all the Help documentation, but I can't find any reason why
                      >this
                      >isn't working.
                      >>
                      >Am I missing a reference or import? I have added a reference to
                      >System.Securit y.dll. My imports are:
                      >>
                      >Imports System
                      >>
                      >Imports System.Configur ation
                      >>
                      >Imports System.Security .Principal
                      >>
                      >Imports System.Security .Permissions
                      >>
                      >Imports System.Threadin g
                      >>
                      >Thanks for your help,
                      >>
                      >Helen

                      Comment

                      Working...