Files
Troll-V2/Quasar.Client/User/UserAccount.cs
T
2026-08-27 11:22:16 -06:00

40 lines
1.1 KiB
C#

using Quasar.Common.Enums;
using System;
using System.Security.Principal;
namespace Quasar.Client.User
{
public class UserAccount
{
public string UserName { get; }
public AccountType Type { get; }
public UserAccount()
{
UserName = Environment.UserName;
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
{
WindowsPrincipal principal = new WindowsPrincipal(identity);
if (principal.IsInRole(WindowsBuiltInRole.Administrator))
{
Type = AccountType.Admin;
}
else if (principal.IsInRole(WindowsBuiltInRole.User))
{
Type = AccountType.User;
}
else if (principal.IsInRole(WindowsBuiltInRole.Guest))
{
Type = AccountType.Guest;
}
else
{
Type = AccountType.Unknown;
}
}
}
}
}