c# - how to determine which group a user is a member of in azure active directory -


i'm using azure active directory control user access web app. works well, cant figure out how identify group logged in user member of. in claimsidentity can see both groups setup in azure, cant determine 1 of these groups user member of (they belong 1 of 2 groups). have code , key in web.config matches key of admin user, both of groups in claimsidentity object. how can determine if user in admin group ?

var groups = identity.claims.where(x => x.type.equals("groups")).tolist();         //this guid should match group objectid adminusers in azure active directory         string admin = helpers.settings.adminuser;         if (groups.any(c => c.value.contains(admin)))         {             return true;         }         else         {             return false;         } 

i must going wrong way, me out ?

it seems have enabled group claims check user’s membership in specific security group (or groups).

the group claims return collection of groups , directoryroles current user member of . example , if user global administrator in aad , , belongs 1 group . group claims 2 records(1 groups , 1 directory role) .

if want of groups(no directoryroles) user has direct or transitive membership in , call getmembergroups function using azure ad graph api .

in scenario , check whether user in admin group , can check whether object id of admin group exists in groups claim . if exists ,the user belongs admin group .


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -