using System.Security.Principal;
public static bool IsAdministrator()
{
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
{
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
}
More Related Contents:
- c# How to pass value from EDI(1) to EDI(2) [closed]
- Store value in Yes/No field in Access using C#
- ASP.NET MVC – Attaching an entity of type ‘MODELNAME’ failed because another entity of the same type already has the same primary key value
- Why do we need boxing and unboxing in C#?
- Cannot open database “test” requested by the login. The login failed. Login failed for user ‘xyz\ASPNET’
- Ignoring a class property in Entity Framework 4.1 Code First
- Is there a .NET/C# wrapper for SQLite? [closed]
- Evaluate string with math operators [duplicate]
- How do I call a non-static method from a static method in C#?
- Creating instance of type without default constructor in C# using reflection
- addFontFile from Resources
- Getting unique items from a list [duplicate]
- Change values in JSON file (writing files)
- How to make a call to my WCF service asynchronous?
- In WPF can you filter a CollectionViewSource without code behind?
- Pass click event of child control to the parent control
- How can Xml Documentation for Web Api include documentation from beyond the main project?
- How to add parameters into a WebRequest?
- Why is this code invalid in C#?
- C# SqlCommand – cannot use parameters for column names, how to resolve?
- Getting odd/even part of a sequence with LINQ
- How to consume a Scoped service from a Singleton?
- Different LIKE behaviour between my application and the Access query wizard
- Adding distance to a GPS coordinate
- Why doesn’t C# support implied generic types on class constructors?
- How/Can I use linq to xml to query huge xml files with reasonable memory consumption?
- Most efficient way to find all exe files on disk using C#?
- C# Stream.Read with timeout
- Keeping window visible through “Show Desktop”/Win+D
- how do i get TcpListener to accept multiple connections and work with each one individually?