- using System.Security.Principal;
- namespace NetworkTool.Client.Services;
- public sealed class AdminPrivilegeService
- {
- public bool IsAdministrator()
- {
- using var identity = WindowsIdentity.GetCurrent();
- var principal = new WindowsPrincipal(identity);
- return principal.IsInRole(WindowsBuiltInRole.Administrator);
- }
- }
|