> For the complete documentation index, see [llms.txt](https://help.glpi-project.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.glpi-project.org/glpi-12/administration/rules/authorizations-assignment-rules.md).

# Authorizations assignment rules

## User Rights Assignment Rules

GLPI's rights assignment rules allow for the automation of user access and role management during their connection or synchronization with the directory (LDAP / Active Directory, SCIM, etc.).

Main Benefits:

* **Lifecycle Automation**: They instantly assign the correct profile (e.g., *Self-Service*, *Technician*, *Admin*) and entity upon the user's first login, eliminating manual entry.
* **Security and Compliance Guarantee**: By directly leveraging attributes or groups from your corporate directory, they ensure that each employee has precisely the rights corresponding to their role.
* **Reduced Administrative Overhead**: They prevent GLPI administrators from having to manage rights on a case-by-case basis, while also ensuring automatic profile updates in case of department changes or departures.

{% hint style="info" %}
The engine executes all rules and does not stop after the first rule that applies to the user. Multiple rules can therefore be used to assign different permissions to the same user. A user with multiple permissions can, during their session and depending on their activities, change their profile and entity context.
{% endhint %}

***

### Default Profile

If a default profile is defined in the GLPI profile configuration, and if a rights assignment rule does not include a profile assignment, then the default profile is used when assigning a user to an entity.

If no default profile is defined, the user is imported without rights: they are neither assigned to an entity nor a profile. Only the super-admin profile can see them in the root entity.

***

### Permissions Based on Mail Server

IMAP mail information can be used to automatically assign permissions. The IMAP identifier (user login) and the mail server URL can be used as criteria. Users can be created on the fly during their login. However, it is not possible to perform a bulk import from the mail server.

#### Permissions Based on Mail Server URL

When multiple mail servers are defined as authentication sources and the mail server URL is a relevant criterion, this information can be used to define permissions.

{% hint style="info" %}
**Example**

Authentication uses the following IMAP servers: `imap.example.fr` and `imap.example.be`. Each server is defined as an authentication source. This information allows assigning the user to the `France` or `Belgium` entities. To do this, two static rules are necessary:

* Rule for `Belgium`:
  * Criteria: IMAP is `imap.example.be`
  * Actions: assign the `Belgium` entity
* Rule for `France`:
  * Criteria: IMAP/POP is `imap.example.fr`
  * Actions: assign the `France` entity
    {% endhint %}

#### Permissions Based on Mail Identifier

When user email addresses contain multiple domain names, or information relevant for defining permissions, this information can be used to define permissions. It is also possible to assign an entity to a user using the mail domain if it is specific to an entity. The mail domain used by the entity is defined in the advanced entity information.

{% hint style="info" %}
**Example**

Users authenticate using email addresses of the following format: `user@example.fr` and `user@example.be`. It does not matter if one or more mail servers are used for authentication. This information is used to assign the user to the `France` or `Belgium` entity. For this purpose, two static rules will be necessary:

* Rule for `Belgium`:
  * Criteria: IMAP/POP identifier finished by `example.be`
  * Actions: assign the `Belgium` entity
* Rule for `France`:
  * Criteria: IMAP/POP identifier finished by `example.fr`
  * Actions: assign the `France` entity
    {% endhint %}

#### Permissions Based on LDAP Directories

An LDAP attribute of a user can be used as a source to dynamically assign permissions to that user using permission assignment rules. There are many ways to use an LDAP tree to create authorization rules for users, with the best solution depending on the context of the directory implementation.

**Permissions Based on LDAP Directory Organizational Units**

Given an LDAP directory where the organization of branches (organizational units) corresponds to the organization of GLPI entities. Each organizational unit (`ou`) contains users, either directly or in a sub-branch. Each of these branches can be used to establish a rule for assigning a user to an entity. The case of users belonging to multiple entities must be handled elsewhere. This model is relevant when a default profile can be assigned to the majority of users. The assignment of non-standard profiles must be handled elsewhere. The user information sent by the directory is sufficient to create the assignment rules in GLPI.

{% hint style="info" icon="vial" %}
**Example**

Consider an LDAP tree of the following form:

```
dc=org
└── ou=countries
    ├── ou=france
    │   ├── ou=paris
    │   ├── ou=lyon
    │   └── ou=bordeaux
    └── ou=belgium
        └── ou=brussels
```

Each of the branches is formalized as in the following example: `ou=lyon,ou=france,dc=example,dc=org`

In the configuration of each entity, under the advanced information tab, indicate the LDAP information representing the entity (in this case, the "unique name" of the entity).

For example, for the Lyon entity: LDAP information representing the entity: `ou=lyon,ou=france,dc=example,dc=org`. Then, define the rule(s) in *Administration > Rules > User Rights Assignment Rules*.

The user has two options: a set of static rules or an adaptive rule.

* Static rule: for each entity, define an assignment rule of the following form:
  * Criteria: (LDAP)UniqueName finished by: `ou=lyon,ou=france,dc=example,dc=org`
  * Actions: assign the `lyon` entity
* Adaptive rule: a single rule based on regular expressions is sufficient to define the assignment to all entities:

  * Criteria: (LDAP)UniqueName matches the following regular expression: `/(ou=.*)/`
  * Actions: assign entity from LDAP, regular expression value: `#0`

  or even

  * Criteria: (LDAP)UniqueName matches the following regular expression: `/(ou=.*)/`
  * Actions: assign entity full name regular expression value: Root entity > `#0`

The execution of the rule retrieves the organizational unit (`ou`) from the user's *unique name*. It will then compare it to the values of the "LDAP information representing the entity" attribute in the database. If an entity has the attribute whose value matches, then this attribute is used as the rule's result.
{% endhint %}

{% hint style="success" icon="lightbulb-on" %}
The value `#0` in the action indicates that the first result of the regular expression should be used. `#1` indicates the second, and so on. The **Test** button in the form allows you to try values and see the obtained result.
{% endhint %}

#### Group or User Attribute-Based Authorizations in an LDAP Directory

In the directory, each user belongs to a group corresponding to a GLPI profile and a group corresponding to an entity. A user can belong to multiple profiles and multiple entities. Depending on the directory configuration, information about the user's group membership can be found in the user object or in the group object.

* In the first case, the information contained in the user object is sufficient to create authorization rules: it is not necessary to import the directory groups into GLPI.
* In the second case, the information contained in the user object is not sufficient, and it is necessary to retrieve group information. You must first configure LDAP groups and automatic user-group linking.

{% hint style="info" %}
this is not limited to group-type attributes, but applies to other types of attributes stored in the directory.
{% endhint %}

{% hint style="info" %}
**Example**

Consider an LDAP tree structured as follows:

```
dc=org
└── ou=example
    ├── ou=profil
    │   ├── cn=post-only
    │   ├── cn=tech
    │   ├── cn=admin
    │   └── cn=super-admin
    ├── ou=entité
    │   ├── ou=france
    │   │   ├── ou=paris
    │   │   └── ou=lyon
    └── ou=people
```

In this example, profiles and entities are defined as groups. For instance: `cn=post-only,ou=profil,dc=exemple,dc=org` or `cn=paris,ou=entité,dc=exemple,dc=org`

No specific entity configuration is required.

In *Administration > Rules > Entity and Rights Assignment Rules*, define the following rules:

* to assign a profile to a user:
  * Criteria: LDAP group directory is `post-only`
  * Actions: Assign profile `post-only`
* to assign an entity:
  * Criteria: LDAP group directory is `paris`
  * Actions: Assign entity *Example > France > Paris*
    {% endhint %}

{% hint style="warning" %}
The calculation of authorizations is performed after all rules have been executed. In the previous example, one rule assigns only an entity and the other only a profile. The combination of the two defines the user's authorization. Similarly, if the user is assigned 2 entities by 2 different rules and only one profile, they will then have 2 authorizations: one on each entity with the same profile.
{% endhint %}

#### Using Different Authorization Sources

Mixed scenarios can occur: rules can use both organizational unit membership for entity assignment and group membership for profile assignment.

{% hint style="info" %}
It is possible to add additional LDAP criteria by clicking the *plus button* next to the dropdown list. A criterion consists of a name (used in the dropdown list), a criterion (corresponding to the attribute in the LDAP directory), and a comment.
{% endhint %}

***

### Available Criteria

| Name                     | Description                                                                                                                                   | Key                | Operator                                                                                                                                                                                                  |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| LDAP Directory           | LDAP directory configured in GLPI                                                                                                             | `LDAP_SERVER`      | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `is under`, `is not under`              |
| E-mail                   | E-mail entered in the user profile                                                                                                            | `MAIL_EMAIL`       | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `is under`, `is not under`              |
| Group                    | User present in the group                                                                                                                     | `_groups_id`       | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regular expression does not match`, `exists`, `does not exist`, `is under`, `is not under` |
| Identifier               | User login identifier                                                                                                                         | `LOGIN`            | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `is under`, `is not under`              |
| Mail Server              | Connection type via a mail server configured in GLPI                                                                                          | `MAIL_SERVER`      | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `is under`, `is not under`              |
| Authentication Type      | One of the connection types present in GLPI (internal database, external authentications, mail server, etc.)                                  | `TYPE`             | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `is under`, `is not under`              |
| (AD) User ID             | User ID present in LDAP                                                                                                                       | `samaccountname`   | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `is under`, `is not under`              |
| (LDAP) Memberof          | Member of an LDAP group                                                                                                                       | `memberof`         | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `is under`, `is not under`              |
| (LDAP) Title             | User's title                                                                                                                                  | `title`            | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `is under`, `is not under`              |
| (LDAP) Common Name       | User's name in LDAP                                                                                                                           | `cn`               | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (LDAP) Department Number | Department number present in LDAP                                                                                                             | `departmentnumber` | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (LDAP) DistinguishedName | Alias present in LDAP                                                                                                                         | `dn`               | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (LDAP) Email             | Email present in LDAP                                                                                                                         | `mail`             | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (LDAP)Emplyee Number     | User's employee number                                                                                                                        | `employeenumber`   | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (LDAP) Manager           | User's manager declared in LDAP                                                                                                               | `manager`          | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (LDAP) Organisation      | Organization entered in the user's LDAP record                                                                                                | `o`                | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (LDAP) Telephone Number  | User's telephone number present in LDAP                                                                                                       | `phone`            | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (LDAP) User ID           | User ID present in LDAP                                                                                                                       | `uid`              | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| (SCIM)homePhone          | Phone number present in the SCIM server user record                                                                                           | TODO               | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |
| Object Class             | Ensure the authorization rule applies only to the correct LDAP directory object type (example: `**user**`, `**group**`, `**computer**`, etc.) | `objectclass`      | `is`, `is not`, `contains`, `does not contain`, `starting with`, `finished by`, `regular expression matches`, `regex does not match`, `exists`, `does not exist`, `under`, `not under`                    |

### Available Actions

| Name                         | Description | Key                              | Operator |
| ---------------------------- | ----------- | -------------------------------- | -------- |
| Skip remaining rules         |             | `_stop_rules_processing`         | `assign` |
| Entity                       |             | `entities_id`                    | `assign` |
| Entity from LDAP information |             | `_affect_entity_by_dn`           | `assign` |
| Entity from TAG              |             | `_affect_entity_by_tag`          | `assign` |
| Entity from email domain     |             | `_affect_entity_by_domain`       | `assign` |
| Entity from full name        |             | `_affect_entity_by_completename` | `assign` |
| Profiles                     |             | `profiles_id`                    | `assign` |
| Recursive                    |             | `is_recursive`                   | `assign` |
| Enabled                      |             | `is_active`                      | `assign` |
| Ignore import                |             | `_ignore_user_import`            | `assign` |
| Default entity               |             | `_entities_id_default`           | `assign` |
| Groups                       |             | `specific_groups_id`             | `assign` |
| Default group                |             | `groups_id`                      | `assign` |
| Timezone                     |             | `timezone`                       | `assign` |
| Language                     |             | `language`                       | `assign` |
| Deny login                   |             | `_deny_login`                    | `assign` |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.glpi-project.org/glpi-12/administration/rules/authorizations-assignment-rules.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
