使用Azure AD Graph&更新联系人详细信息节点

时间:2018-04-11 09:25:38

标签: node.js azure azure-active-directory azure-ad-graph-api

我正在使用Node.js和azure-graph在Azure中创建用户。它对Name等基本字段的预期效果如此。但是,无法更新通常在门户网站中找到的jobTitle和其他字段。有什么指针吗?

enter image description here

  let msRest = require('ms-rest-azure');
  let azureGraph = require('azure-graph');

  let tenantId = common.configDefaults.azure_tenant;
  let clientId = common.configDefaults.azure_client_id;
  let clientPwd = common.configDefaults.azure_client_secret; 

  let create_user_in_azure_ad = function (user, cb) {
    msRest.loginWithServicePrincipalSecret(clientId, clientPwd, tenantId, {
      tokenAudience: 'graph'
    }, function (err, credentials, subscriptions) {
      if (err) {
        done(err.message, null);
      } else {
        // Create Azure Graph Client to access
        let client = new azureGraph(credentials, tenantId);
        let password = common.generatePassword(10);
        let userParams = {
          accountEnabled: true,
          userPrincipalName: user.email_official, //please add your domain over here
          displayName: user.display_name,
          mailNickname: user.email_official.split("@")[0],
          jobTitle: "A FANCY TITLE",
          passwordProfile: {
            password: password,
            forceChangePasswordNextLogin: true
          },
        };

        // Now, we can create the User in Active Directory
        client.users.create(userParams, function (err, done) {
          if (err) {
            cb(err, null);
          } else {
            // The user is created now with a password. Return this information
            cb(null, {user: user, password: password});
          }
        });
      }
    });
  };

1 个答案:

答案 0 :(得分:0)

虽然我不了解Node.js,但我认为您可以updating contact of a specific user创建/更新jobTitle