# Exported variables

## Presentation

Exported variables are the variables available to write rules and headers. They are extracted from the users database by the users module.

To create a variable, you've just to map a user attributes in LL::NG using `Variables` » `Exported variables`. For each variable, The first field is the name which will be used in rules, macros or headers and the second field is the name of the user database field.

Examples for LDAP:

Variable name | LDAP attribute
--- | ---
uid | uid
number | employeeNumber
name | sn

## Extend variables using macros and groups

Macros and groups are calculated during authentication process by the portal:

- macros are used to extend (or rewrite) exported variables. A macro is stored as attributes: it can contain boolean results or any string
- groups are stored as space-separated strings in the special attribute “groups”: it contains the names of groups whose rules were returned true for the current user

Example for macros:

    # boolean macro
    isAdmin -> $uid eq 'foo' or $uid eq 'bar'
    # other macro
    displayName -> $givenName." ".$surName

    # Use a boolean macro in a rule
    ^/admin -> $isAdmin
    # Use a string macro in a HTTP header
    Display-Name -> $displayName

Example for groups:

    # group
    admin -> $uid eq 'foo' or $uid eq 'bar'

    # Use a group in a rule
    ^/admin -> $groups =~ /\badmin\b/