Files
PulsarK-main/Pulsar.Client/User/UserAccount.cs
T
i2p 773d05f8f1
Pulsar .NET 9.0 Windows Release / build (push) Waiting to run
Mirror to Codeberg and Gitea / mirror (push) Waiting to run
initial commit
2026-08-27 10:57:58 -06:00

40 lines
1.1 KiB
C#

using Pulsar.Common.Enums;
using System;
using System.Security.Principal;
namespace Pulsar.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;
}
}
}
}
}