title: How to get/set custom Azure Active Directory B2C user attributes in ASP.NET MVC?
body: <p>I have added a custom <code>Organization</code> field as a User Attribute in my Azure Active Directory B2C tenant, like so:</p>
  
  <p><a href="https://i.stack.imgur.com/U3qgE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U3qgE.jpg" alt="enter image description here"></a></p>
  
  <p>I am using the <a href="https://github.com/microsoftgraph/msgraph-sdk-dotnet" rel="nofollow noreferrer">Microsoft Graph .NET Client Library</a> to manage users in Azure Active Directory B2C and would like to use something similar to the following code to set the user's custom <code>Organization</code> field and the user's built-in <code>Email Addresses</code> field.</p>
  
  <pre><code>await graphClient.Users[user.Id].Request().UpdateAsync(new User()
  {
      Email Addresses = new StringCollection("myemail@mydomain.com")
      Organization = "Microsoft"
  });
  </code></pre>
  
  <p>Two questions:</p>
  
  <ol>
  <li>How do I set a Built-in field, like the <code>Email Addresses</code>?</li>
  <li>How do I set a Custom field, like <code>Organization</code>?</li>
  </ol>
  
  <p>This documentation shows <a href="https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-custom-attr#create-a-custom-attribute" rel="nofollow noreferrer">how to create a custom attribute</a> but does not tell how to access or use that attribute using the Graph Client. </p>
  
  <p>This documentation shows how to <a href="https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-create-custom-attributes-profile-edit-custom" rel="nofollow noreferrer">create custom attributes and edit the Relying Party (RP) file</a>. </p>
  
  <p>Is there an easier way? And what is the <code>graphClient</code> code to then get/set these custom user attributes?</p>