Check Azure AD membership from code (not via rule)

Forums Classic DFFS Check Azure AD membership from code (not via rule)

Viewing 1 reply thread
  • Author
    Posts
    • #36932
      Michal Riha
      Participant

      Hi Alexander,

      is it possible to check Azure AD membership from code? I need check it dynamically, not from “static” rule.

      Thanks Michal

    • #36933
      Alexander Bautz
      Keymaster

      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

Viewing 1 reply thread
  • You must be logged in to reply to this topic.