123456789101112131415161718192021222324252627282930 |
- using System;
- using System.Collections.Generic;
- using System.Security.Principal;
- namespace ISCSIConsole
- {
- public class SecurityHelper
- {
- public static bool IsAdministrator()
- {
- WindowsIdentity windowsIdentity = null;
- try
- {
- windowsIdentity = WindowsIdentity.GetCurrent();
- }
- catch
- {
- return false;
- }
- WindowsPrincipal windowsPrincipal = new WindowsPrincipal(windowsIdentity);
- return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
- }
- }
- }
|