# ConnectWise Control

#### ConnectWise Configuration

* Log into your admin session on ControlWise Control

* Go on the Administration panel, then go in Security and Enable SAML

* Click on Configure and fill the following fields:
  * IdentityProviderMetadataUrl

  ```exp
  https://mydomain.trustelem.com/app/33XXXX/metadata
  ```

  * UserNameAttributeKey

  ```exp
  NameID
  ```

  * UserDisplayNameAttributeKey

  ```exp
  displayname
  ```

  * EmailAttributeKey

  ```exp
  email
  ```

  * RoleNamesAttributeKey

  ```exp
  role
  ```

  * DisplayName
    * The value written here will complete the Connect with displayed on the ConnectWise authentication page
  
#### Trustelem Configuration

* Click on Save Configuration and then on Generate Metadata

* In the metadata, on the first line, copy the link located in entityID=" "

* On Trustelem, cut the link in the EntityID field

* Fill the Roles fields with one or several roles separated by commas; these roles with be applied by default to all users

* You can overload the roles with the Advanced setting's script, for example:

```ts
function CustomSAMLResponse(msg: SAMLResponse, user: User, groups: Groups, deny: Deny): void {
    for (const cust_group in groups) {
      if (cust_group === "admin") {
        msg.addAttr("role", "Control Administrator");
      }
    }
}
```