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