Azure ad user mail attribute

In Azure Active Directory (Azure AD), the mail attribute is a user attribute that stores the user's email address. This attribute is used to identify the user and is used in various scenarios, such as:

  1. Authentication: The mail attribute is used to verify the user's identity during the authentication process.
  2. Directory searches: The mail attribute is used to search for users in the Azure AD directory.
  3. Email notifications: The mail attribute is used to send email notifications to users, such as password reset notifications.

Here are some key points to note about the mail attribute in Azure AD:

  1. Required: The mail attribute is not required for Azure AD users, but it is recommended to set it to ensure that users can be identified and authenticated correctly.
  2. Format: The mail attribute should be in the format [email protected].
  3. Case sensitivity: The mail attribute is case-insensitive, so [email protected] and [email protected] are considered the same.
  4. Unique: The mail attribute should be unique for each user in the Azure AD directory.
  5. Update: The mail attribute can be updated by the user or by an administrator.

You can manage the mail attribute for Azure AD users using the Azure AD portal, PowerShell, or the Azure AD Graph API.

Azure AD portal:

  1. Sign in to the Azure AD portal as an administrator.
  2. Go to the "Users" tab.
  3. Select the user you want to manage.
  4. Click on the "Edit" button.
  5. Scroll down to the "Contact info" section.
  6. Update the "Email" field with the new email address.

PowerShell:

  1. Install the Azure AD PowerShell module.
  2. Connect to Azure AD using the Connect-AzureAD cmdlet.
  3. Use the Get-AzureADUser cmdlet to retrieve the user object.
  4. Use the Set-AzureADUser cmdlet to update the mail attribute.

Example:

$user = Get-AzureADUser -ObjectId <userObjectId>
$user.Mail = "[email protected]"
Set-AzureADUser -ObjectId <userObjectId> -User $user

Azure AD Graph API:

  1. Install the Azure AD Graph API client library.
  2. Use the Get user method to retrieve the user object.
  3. Use the Update user method to update the mail attribute.

Example:

var client = new HttpClient();
var graphClient = new GraphServiceClient(client);

var user = await graphClient.Users["<userObjectId>"].Request().GetAsync();
user.Mail = "[email protected]";
await graphClient.Users["<userObjectId>"].Request().UpdateAsync(user);

Remember to replace <userObjectId> with the actual object ID of the user you want to manage.