# ADFS - Roles and Groups with Rules

**URL:** <https://community.auth0.com/t/adfs-roles-and-groups-with-rules/7868>\
**Category:** Get Help\
**Tags:** adfs, rules, groups, roles\
**Created:** [August 16, 2017, 8:52pm UTC](https://community.auth0.com/t/adfs-roles-and-groups-with-rules/7868 "2017-08-16T20:52:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![supportservices](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@supportservices](https://community.auth0.com/u/supportservices)\
**Post date:** [August 16, 2017, 8:52pm UTC](https://community.auth0.com/t/adfs-roles-and-groups-with-rules/7868/1 "2017-08-16T20:52:49Z")

</div>

Hello,  
I am trying to get the roles and groups associated with my ADFS user. I have follow this question here. [Groups and roles not returned to client application - Auth0 Community](http://community.auth0.com/questions/4161/groups-and-roles-not-returned-in-sample-java-appli)  
but it does not seem to work still.

I wrote out the whole user object to the debugger but there are no roles inside of the user object. I also wrote out context but that does not contain any of the groups either.

Under the user area after they sign in they have Identity Provider Attributes and it has theirs groups inside of there. How do I get this transfered to the JWT Token?  
I have tried doing this as an OIDC comformant application and then unchecking it to see if that matters. Is there anything that I am missing here?

Would be nice if this question could be answered? [How to use Rules to add user roles based on AD group membership - Auth0 Community](http://community.auth0.com/questions/5741/how-to-use-rules-to-add-user-roles-based-on-ad-gro)

```
function (user, context, callback) {
  // TODO: implement your rule
  var namespace = 'https://app.subdomainname.com/';
  context.accessToken[namespace + 'roles'] = user.roles;
  context.accessToken[namespace + 'groups'] = user.groups;
  console.log(user.groups);
  console.log(user.roles);
  console.log(user.user_metadata);
  console.log(user.app_metadata);
  console.log(context);
      callback(null, user, context);
}

```

---

<div class="post-metadata">

**Author:** ![supportservices](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@supportservices](https://community.auth0.com/u/supportservices)\
**Post date:** [August 16, 2017, 9:49pm UTC](https://community.auth0.com/t/adfs-roles-and-groups-with-rules/7868/2 "2017-08-16T21:49:13Z")

</div>

I thought the user object inside of the rules was coming from the provider and should provide everything? Inside of the user section in Auth0 it has the groups filled in. Is this a problem with Auth0 not providing the correct information?

---

<div class="post-metadata">

**Author:** ![supportservices](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@supportservices](https://community.auth0.com/u/supportservices)\
**Post date:** [August 17, 2017, 1:25am UTC](https://community.auth0.com/t/adfs-roles-and-groups-with-rules/7868/3 "2017-08-17T01:25:32Z")

</div>

The above code was correct, but there was another rule that was auto generated that caused the issue.

This rule been automatically generated by auth0-authz-extension  
Once I disabled this rule it worked fine.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:55am UTC](https://community.auth0.com/t/adfs-roles-and-groups-with-rules/7868/4 "2018-03-02T05:55:58Z")

</div>


