Allen Houchins
Allen Houchins
Fleet requires user full names to be configured in your Identity Provider (IdP) using specific attributes. Since Google Workspace doesn't natively provide a full name attribute that matches Fleet's requirements, this guide will walk you through setting up automatic synchronization of full names using Google's custom attributes and Apps Script.
Fleet looks for full names in one of these attributes:
name
displayname
cn
urn:oid:2.5.4.3
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
Google Workspace doesn't expose these attributes directly, so we need to:
First, we'll create a place to store the full name:
Fleet
(this should match the category name in the script)Attributes for Fleet integration
Fullname
Text
Visible to user and admin
Next, we'll create a script that automatically updates the full name attribute:
/**
* Updates all users in Google Workspace with their full name in the Fleet.Fullname custom attribute.
* This attribute can then be mapped in SAML configurations for Fleet integration.
*/
function updateFullnames() {
const users = AdminDirectory.Users.list({customer: 'my_customer'}).users;
users.forEach(user => {
const fullName = `${user.name.givenName} ${user.name.familyName}`.trim();
// Update custom schema using Fleet category and Fullname attribute
const customSchemas = {
Fleet: {
Fullname: fullName
}
};
try {
AdminDirectory.Users.update(
{customSchemas: customSchemas},
user.primaryEmail
);
console.log(`Updated ${user.primaryEmail} with full name: ${fullName}`);
} catch (error) {
console.log(`Error updating ${user.primaryEmail}: ${error}`);
}
});
}
/**
* Creates a daily trigger to run the updateFullnames function.
* Run this function once to set up the automatic daily updates.
*/
function createTrigger() {
// Check if trigger already exists
const triggers = ScriptApp.getProjectTriggers();
const triggerExists = triggers.some(trigger =>
trigger.getHandlerFunction() === 'updateFullnames' &&
trigger.getEventType() === ScriptApp.EventType.CLOCK
);
// Only create a new trigger if one doesn't already exist
if (!triggerExists) {
ScriptApp.newTrigger('updateFullnames')
.timeBased()
.everyDays(1)
.create();
console.log('Daily trigger created successfully');
} else {
console.log('Daily trigger already exists');
}
}
Now we'll run the script and set up automatic updates:
updateFullnames
function from the dropdown near the Run buttoncreateTrigger
function from the dropdownFinally, we'll map our custom attribute to one of Fleet's supported attributes:
Fleet > Fullname
name
(or one of the other supported attributes, like displayname
)To verify everything is working correctly:
If you encounter issues:
The script will automatically run daily to keep full names updated. If you make changes to the script, you may need to reauthorize it.
To monitor or manage the script's execution:
When new users are added to Google Workspace, they will be included in the next daily update cycle.
You've now successfully configured Google Workspace to provide full names to Fleet using a custom attribute and automated synchronization. This setup ensures that Fleet can automatically populate and the macOS local account name for all your users during the initial macOS setup experience.