Thread: Retrieving local name of "Users" group

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Retrieving local name of "Users" group

    I'm looking for a way to (programatically) retrieve the name of the windows "Users" group on a computer. You know, the common group a user belongs to, others which might be "Admin" etc... I need the proper local name which may differ in different languages. As an example in swedish the name is "Användare" instead of the standard english "Users". How can I achieve this? Can it be done using the dot net framework?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Registered User
    Join Date
    Aug 2007
    Location
    Gloucester, England
    Posts
    11

    Cool From MSDN

    Here's some info from MSDN that might help.

    http://msdn2.microsoft.com/en-us/lib...le(VS.71).aspx

    Code:
    [C#] 
    
        public static void DemonstrateWindowsBuiltInRoleEnum()
        {
            AppDomain myDomain = Thread.GetDomain();
    
            myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
            WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
    
        
            Console.WriteLine("{0} belongs to: ", myPrincipal.Identity.Name.ToString());
    
            Array wbirFields = Enum.GetValues(typeof(WindowsBuiltInRole));
    
            foreach (object roleName in wbirFields)
            {
                try
                {
                     Console.WriteLine("{0}? {1}.", roleName,
                     myPrincipal.IsInRole((WindowsBuiltInRole)roleName));
                } 
                catch (Exception)
                {
                    Console.WriteLine("{0}: Could not obtain role for this RID.", roleName);
                }
            }
        }
    Not sure about the language part

    Regards
    Pete
    Last edited by Pete_O; 09-14-2007 at 02:23 PM. Reason: readability

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. ray casting
    By lambs4 in forum Game Programming
    Replies: 62
    Last Post: 01-09-2003, 06:57 PM