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. How to get information of User?

How to get information of User?

Scheduled Pinned Locked Moved C#
tutorialquestion
3 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.
  • I Offline
    I Offline
    I am kai
    wrote on last edited by
    #1

    User name is? User in group?

    S S 2 Replies Last reply
    0
    • I I am kai

      User name is? User in group?

      S Offline
      S Offline
      Sebastian Schneider
      wrote on last edited by
      #2

      string mystring = Environment.UserName; As for the group: I have no clue. Try Win32-API or find out if it is in here: class Sample // MSDN-Sample { public static void Main() { Console.WriteLine(); Console.WriteLine("GetEnvironmentVariables: "); IDictionary environmentVariables = Environment.GetEnvironmentVariables(); foreach (DictionaryEntry de in environmentVariables) { Console.WriteLine(" {0} = {1}", de.Key, de.Value); } } } // MSDN-Sample

      1 Reply Last reply
      0
      • I I am kai

        User name is? User in group?

        S Offline
        S Offline
        shaunAustin
        wrote on last edited by
        #3

        If you want to find out if a user is a particular known group you can use... WindowsIdentity wi = WindowsIdentity.GetCurrent(); WindowsPrincipal wp = new WindowsPrincipal(wi); wp.IsInRole("Administrator"); //or whatever the role is. Getting a list of Groups a user is a member of is more difficult the last time I needed to do it I used the WinNT ADSI provider with the DirectoryServices classes... ----------------------------------------------------------------------- Shaun Austin: .NET Specialist. Spreading the word of .NET to the world... well the UK... well my tiny corner of it!! :-D

        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