---
title: "Check for elevated rights in .NET 8"
description: "In the past, it was tricky to get if the current process runs under elevated rights. In the sense of it is run under the sudo group in *nix (Unix, Linux, macOS, you name it) or administrative rights in Windows.\n\nBut that changes with .NET 8 as we now have a unified API for that."
updated: 2022-12-07
tags: [".NET", ".NET 8", "C#"]
canonical: "https://steven-giesel.com/blogPost/fea90d87-a7d5-4312-b426-b976fa941ab9/check-for-elevated-rights-in-net-8"
---

# Check for elevated rights in .NET 8

A recent API was added to the framework under the name ["*Add API to check if process had administrator privileges*"](https://github.com/dotnet/runtime/issues/68770), which adds this API to the framework itself. 

And it is fairly simple:

```csharp
var hasPrivilegedRights = Environment.IsPrivilegedProcess;
```

Yes, that is all. The new call lives in the `System.Environment` class. That works independently of the underlying OS (as long as the underlying OS supports the .NET runtime). Currently (as of today - 7. December 2022) there is no API that grants you privileged rights nor an API that drops them. **But** there are ideas and smaller proposals for that. So let's see what the future brings.