How to detect current user of windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vijayB
    New Member
    • Mar 2008
    • 40

    How to detect current user of windows

    Hello friends,

    I want to detect the current user which is logged on to windows system using vb.net.
    This is required to notify end user under what privilages application is running.

    Please help
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Environment.Use rName

    Comment

    • cloud255
      Recognized Expert Contributor
      • Jun 2008
      • 427

      #3
      One day ...

      people started consulting text books before posting questions
      and magically the forum only consisted of questions that actually require
      experience and logic to solve ...

      one day ...

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Originally posted by cloud255
        One day ...

        people started consulting text books before posting questions
        and magically the forum only consisted of questions that actually require
        experience and logic to solve ...

        one day ...
        You said it, bro. The only reason I bothered answering this one is because I knew it off the top of my head and it literally took two words.

        Comment

        • vijayB
          New Member
          • Mar 2008
          • 40

          #5
          Originally posted by cloud255
          One day ...

          people started consulting text books before posting questions
          and magically the forum only consisted of questions that actually require
          experience and logic to solve ...

          one day ...
          Thanks for the help friendzzzzz
          But this is not the solution I was looking for. I know we can get current user name using Environment.
          What I was looking for is, current user, i.e., whether the current user is having administrator privilages or it is a restricted account.

          Anyways, I have found the solution for this, yesterday itself.
          Thanks once again for your valuable help.

          Comment

          • alag20
            New Member
            • Apr 2007
            • 84

            #6
            Originally posted by vijayB
            Thanks for the help friendzzzzz
            But this is not the solution I was looking for. I know we can get current user name using Environment.
            What I was looking for is, current user, i.e., whether the current user is having administrator privilages or it is a restricted account.

            Anyways, I have found the solution for this, yesterday itself.
            Thanks once again for your valuable help.
            We are happy that you found your solution. Though your question seemed as if you wanted to get their name rather than their rights!

            Comment

            • vijayB
              New Member
              • Mar 2008
              • 40

              #7
              Originally posted by alag20
              We are happy that you found your solution. Though your question seemed as if you wanted to get their name rather than their rights!

              Ya, I m really sorry. Next time I will be more specific.
              Thanks.

              Comment

              • Curtis Rutland
                Recognized Expert Specialist
                • Apr 2008
                • 3264

                #8
                If you don't mind, post your solution. That way, anyone else searching for the same kind of help will be able to get the help they need as well.

                Thanks.

                Comment

                • vijayB
                  New Member
                  • Mar 2008
                  • 40

                  #9
                  Originally posted by insertAlias
                  If you don't mind, post your solution. That way, anyone else searching for the same kind of help will be able to get the help they need as well.

                  Thanks.

                  Ya sure, it will be my pleasure.
                  Here is the solution;

                  Function IsAdministrator () As Boolean

                  System.AppDomai n.CurrentDomain .SetPrincipalPo licySystem.Secu rity.Principal. PrincipalPolicy .WindowsPrincip al)
                  Dim WP As System.Security .Principal.Wind owsPrincipal
                  WP = System.Threadin g.Thread.Curren tPrincipal
                  Return WP.IsInRole(Sys tem.Security.Pr incipal.Windows BuiltInRole.Adm inistrator)

                  End Function

                  One just needs to call this function, to get current role of administrator.

                  Comment

                  • Curtis Rutland
                    Recognized Expert Specialist
                    • Apr 2008
                    • 3264

                    #10
                    Thanks for posting it.

                    Comment

                    • Daxthecon
                      New Member
                      • Jul 2008
                      • 63

                      #11
                      I know what you thought the original question was is easy and in a book but I honestly forgot it and I don't have the book on me. Could anyone reference a google search real quick to help me find the answer to the original question(a list of those codes to gather the information that the windows authentication stores and transfers). It would be greatly appreciated. I'm in such a mind fog right now. Please forgive me.

                      Comment

                      Working...