Check Azure AD membership from code (not via rule)
- This topic has 1 reply, 2 voices, and was last updated 3 years, 4 months ago by .
Viewing 1 reply thread
Viewing 1 reply thread
- You must be logged in to reply to this topic.
Home › Forums › Classic DFFS › Check Azure AD membership from code (not via rule)
Hi Alexander,
is it possible to check Azure AD membership from code? I need check it dynamically, not from “static” rule.
Thanks Michal
You can use something like this. It uses functions in DFFS so you cannot use it outside of your DFFS forms.
function getAllAzureGroups() {
var d = jQuery.Deferred();
spjs.dffs.getMSGraphAccessToken().done(function (t) {
spjs.dffs.getAzureGroupsForUser(t).done(function (gData) {
var groups = {};
jQuery.each(gData.value, function () {
groups[this.displayName] = this;
});
d.resolve(groups);
}).fail(function (err) {
spjs.dffs.alert({
"title": "Error in spjs.dffs.getAzureGroupsForUser",
"msg": JSON.stringify(err)
});
});
}).fail(function (err) {
spjs.dffs.alert({
"title": "Error in spjs.dffs.getMSGraphAccessToken",
"msg": JSON.stringify(err)
});
});
return d.promise();
}
var userGroups = getAllAzureGroups().done(groups => {
console.log("Logged in users groups", groups);
});
Alexander