# AppDynamics

#### AppDynamics Configuration

* Log into your AppDynamics admin session, go to Administration and then to the Authentication Providers tab

* Select the SAML option and fill the following fields:
  * Login URL

   ```exp
   https://mydomain.trustelem.com/app/33XXXX/sso
   ```

  * Logout URL

   ```exp
   https://mydomain.trustelem.com/app/33XXXX/on_logout
   ```

  * Identity Provider Certificate

   ```exp
   https://mydomain.trustelem.com/app/33XXXX/metadata
   ```
  
  * Username Attribute

   ```exp
   username
   ```

  * Display Name Attribute

   ```exp
   displayname
   ```

  * Email Attribute

   ```exp
   email
   ```

* By default the username will be the user email but you can change that in Custom scripting ; if you want username to be firstname.lastname for example add these two lines:

```ts
function CustomSAMLResponse(msg: SAMLResponse, user: User, groups: Groups, deny: Deny): void {
    msg.setAttr("username", user.firstname+"."+user.lastname);
}
```

* You can also define AppDynamics roles according to attributes sent by Trustelem in SAML Group Mappings

  * In SAML Group Attribute Name write 'groups'

  * In Group Attribute Value, check the Multiple Nested Group Values option

  * In Mapping of Group to Roles add Trustelem groups to which you want to match AppDynamics roles

#### Trustelem Configuration

* On Trustelem, write your AppDynamics name account in the corresponding field. You can find your name account on your AppDynamics url which looks like `https://[name-account].saas.appdynamics.com/`

* To send your users' Trustelem groups, add these lines in Custom scripting:

```ts
function CustomSAMLResponse(msg: SAMLResponse, user: User, groups: Groups, deny: Deny): void {
  for (let g in groups) {
      msg.addAttr("groups", groups[g].name);
  };
}
```