> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/it/app/role-based-access.md).

# Accesso basato sui ruoli

Limiti le app e le pagine di PowerShell Universal in base al ruolo e utilizzi la variabile Roles per mostrare condizionalmente i componenti in base all'appartenenza ai ruoli dell'utente.

## Ruoli delle app

Quando l'autenticazione delle app è abilitata, può definire il ruolo di cui un utente deve fare parte per accedere alla dashboard. I ruoli vengono configurati in **Secure > Roles** o dall'interno del file di configurazione `roles.ps1`.

Se un utente tenta di visitare un'app a cui non ha accesso, gli verrà mostrata una pagina Not Authorized.

## Ruoli delle pagine

Può anche mostrare o nascondere le pagine in base ai ruoli. Per definire un ruolo per una pagina, utilizzi il parametro `-Role` di `New-UDPage`. Solo gli utenti del ruolo specificato avranno accesso a questa pagina.

```powershell
New-UDPage -Role 'Administrators' -Content {
    New-UDTypography -Text 'Admins only'
}
```

## Variabile $Roles

Oltre ai ruoli delle app e delle pagine, può anche verificare di quali ruoli fa parte un utente utilizzando la variabile `$Roles` disponibile all'interno delle app. Questa variabile contiene un array dei ruoli assegnati all'utente.

Ad esempio, potrebbe mostrare il pulsante `Restart-Computer` solo agli amministratori.

```powershell
if ($Roles -contains "Administrator") {
    New-UDButton -Text 'Restart Server' -OnClick {
        Restart-Computer
    }
}
```

### Vedi anche

* [Devolutions Academy – Outline and authentication](https://academy.devolutions.net/student/activity/3542770-part-1-outline-and-authentication)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/it/app/role-based-access.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
