Package com.independentsoft.graph.users

# Class User

java.lang.Object
com.independentsoft.graph.DirectoryObject
com.independentsoft.graph.users.User

All Implemented Interfaces:
  `ICreatable`, `IUpdatable`

public class User extends DirectoryObject implements ICreatable, IUpdatable
Represents a Microsoft Entra user account in Microsoft Graph.

The User resource represents a user account in Microsoft Entra ID (formerly Azure AD). This class provides access to user profile information, organizational data, and relationships to other Microsoft 365 resources like mail, calendar, contacts, and files.

User objects can be created, retrieved, updated, and deleted through the Microsoft Graph API. Common operations include:

- Getting user profile information (name, email, job title, etc.)
- Updating user properties (department, phone numbers, etc.)
- Managing user licenses and subscriptions
- Accessing user's mailbox, calendar, and contacts
- Managing user's OneDrive files
- Listing groups and teams the user belongs to

Example usage:

     GraphClient client = new GraphClient();
     // ... configure authentication ...

     // Get current user
     User user = client.me();
     System.out.println(\"Display Name: \" + user.getDisplayName());
     System.out.println(\"Email: \" + user.getEmailAddress());
     System.out.println(\"Job Title: \" + user.getJobTitle());

     // Update user properties
     user.setMobilePhone(\"+1-555-0123\");
     client.updateUser(user.getId(), user);

Since:
  1.0
See Also:
  User resource type, Get user, Update user

- ## Field Summary

  ### Fields inherited from class com.independentsoft.graph.DirectoryObject

  `id`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `User()`
  `User​(JsonObject jsonObject)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getAboutMe()`
  `boolean`
  `getAccountEnabled()`
  `AgeGroup`
  `getAgeGroup()`
  `List<AssignedLicense>`
  `getAssignedLicenses()`
  `List<AssignedPlan>`
  `getAssignedPlans()`
  `Date`
  `getBirthday()`
  `List<String>`
  `getBusinessPhones()`
  `String`
  `getCity()`
  `String`
  `getCompanyName()`
  `ConsentProvidedForMinor`
  `getConsentProvidedForMinor()`
  `String`
  `getCountry()`
  `Date`
  `getCreatedTime()`
  `Date`
  `getDeletedTime()`
  `String`
  `getDepartment()`
  `String`
  `getDisplayName()`
  `String`
  `getEmailAddress()`
  `String`
  `getEmployeeId()`
  `ExternalUserState`
  `getExternalUserState()`
  `Date`
  `getExternalUserStateChangeTime()`
  `String`
  `getFaxNumber()`
  `String`
  `getGivenName()`
  `Date`
  `getHireDate()`
  `List<String>`
  `getImAddresses()`
  `List<String>`
  `getInterests()`
  `String`
  `getJobTitle()`
  `LegalAgeGroupClassification`
  `getLegalAgeGroupClassification()`
  `List<LicenseAssignmentState>`
  `getLicenseAssignmentStates()`
  `MailboxSettings`
  `getMailboxSettings()`
  `String`
  `getMailNickname()`
  `String`
  `getMobilePhone()`
  `String`
  `getMySite()`
  `String`
  `getOfficeLocation()`
  `String`
  `getOnPremisesDistinguishedName()`
  `String`
  `getOnPremisesDomainName()`
  `OnPremisesExtensionAttributes`
  `getOnPremisesExtensionAttributes()`
  `String`
  `getOnPremisesImmutableId()`
  `Date`
  `getOnPremisesLastSyncTime()`
  `List<OnPremisesProvisioningError>`
  `getOnPremisesProvisioningErrors()`
  `String`
  `getOnPremisesSamAccountName()`
  `String`
  `getOnPremisesSecurityIdentifier()`
  `boolean`
  `getOnPremisesSyncEnabled()`
  `String`
  `getOnPremisesUserPrincipalName()`
  `List<String>`
  `getOtherEmailAddresses()`
  `String`
  `getPasswordPolicies()`
  `PasswordProfile`
  `getPasswordProfile()`
  `List<String>`
  `getPastProjects()`
  `String`
  `getPostalCode()`
  `String`
  `getPreferredDataLocation()`
  `String`
  `getPreferredLanguage()`
  `String`
  `getPreferredName()`
  `String`
  `getPrincipalName()`
  `List<ProvisionedPlan>`
  `getProvisionedPlans()`
  `List<String>`
  `getProxyAddresses()`
  `Date`
  `getRefreshTokensValidFromTime()`
  `List<String>`
  `getResponsibilities()`
  `List<String>`
  `getSchools()`
  `boolean`
  `getShowInAddressList()`
  `List<SignInActivity>`
  `getSignInActivity()`
  `List<String>`
  `getSkills()`
  `String`
  `getState()`
  `String`
  `getStreetAddress()`
  `String`
  `getSurname()`
  `String`
  `getType()`
  `String`
  `getUsageLocation()`
  `boolean`
  `isResourceAccount()`
  `void`
  `setAboutMe​(String aboutMe)`
  `void`
  `setAccountEnabled​(boolean accountEnabled)`
  `void`
  `setAgeGroup​(AgeGroup ageGroup)`
  `void`
  `setAsResourceAccount​(boolean isResourceAccount)`
  `void`
  `setBirthday​(Date birthday)`
  `void`
  `setCity​(String city)`
  `void`
  `setCompanyName​(String companyName)`
  `void`
  `setConsentProvidedForMinor​(ConsentProvidedForMinor consentProvidedForMinor)`
  `void`
  `setCountry​(String country)`
  `void`
  `setCreatedTime​(Date createdTime)`
  `void`
  `setDeletedTime​(Date deletedTime)`
  `void`
  `setDepartment​(String department)`
  `void`
  `setDisplayName​(String displayName)`
  `void`
  `setEmployeeId​(String employeeId)`
  `void`
  `setExternalUserState​(ExternalUserState externalUserState)`
  `void`
  `setFaxNumber​(String faxNumber)`
  `void`
  `setGivenName​(String givenName)`
  `void`
  `setHireDate​(Date hireDate)`
  `void`
  `setJobTitle​(String jobTitle)`
  `void`
  `setMailNickname​(String mailNickname)`
  `void`
  `setMobilePhone​(String mobilePhone)`
  `void`
  `setMySite​(String mySite)`
  `void`
  `setOfficeLocation​(String officeLocation)`
  `void`
  `setOnPremisesExtensionAttributes​(OnPremisesExtensionAttributes onPremisesExtensionAttributes)`
  `void`
  `setOnPremisesImmutableId​(String onPremisesImmutableId)`
  `void`
  `setPasswordPolicies​(String passwordPolicies)`
  `void`
  `setPasswordProfile​(PasswordProfile passwordProfile)`
  `void`
  `setPostalCode​(String postalCode)`
  `void`
  `setPreferredDataLocation​(String preferredDataLocation)`
  `void`
  `setPreferredLanguage​(String preferredLanguage)`
  `void`
  `setPreferredName​(String preferredName)`
  `void`
  `setPrincipalName​(String principalName)`
  `void`
  `setShowInAddressList​(boolean showInAddressList)`
  `void`
  `setSkuId​(MailboxSettings mailboxSettings)`
  `void`
  `setState​(String state)`
  `void`
  `setStreetAddress​(String streetAddress)`
  `void`
  `setSurname​(String surname)`
  `void`
  `setType​(String type)`
  `void`
  `setUsageLocation​(String usageLocation)`
  `String`
  `toCreateJson()`
  Converts this object to its JSON representation for creation.
  `String`
  `toString()`
  `String`
  `toUpdateJson()`
  Converts this object to its JSON representation for update.
  `String`
  `toUpdateJson​(List<String> propertyNames)`
  Converts this object to JSON for update with specific properties.

  ### Methods inherited from class com.independentsoft.graph.DirectoryObject

  `getId, setId`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### User

    public User()

  - ### User

    public User​(JsonObject jsonObject)

- ## Method Details

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `DirectoryObject`

  - ### toCreateJson

    public String toCreateJson()
    Description copied from interface: `ICreatable`
    Converts this object to its JSON representation for creation.

    This method generates a JSON string containing all properties needed to create a new instance of this resource in Microsoft Graph. Only properties appropriate for creation should be included (e.g., excluding read-only properties like ID, createdTime, etc.).

    Specified by:
      `toCreateJson` in interface `ICreatable`
    Returns:
      JSON string representation for creating this resource

  - ### toUpdateJson

    public String toUpdateJson()
    Description copied from interface: `IUpdatable`
    Converts this object to its JSON representation for update.

    This method generates a JSON string containing all modified properties that should be updated in Microsoft Graph. Only writeable properties with non-null values are typically included.

    Specified by:
      `toUpdateJson` in interface `IUpdatable`
    Returns:
      JSON string representation for updating this resource

  - ### toUpdateJson

    public String toUpdateJson​(List<String> propertyNames)
    Description copied from interface: `IUpdatable`
    Converts this object to JSON for update with specific properties.

    This method generates a JSON string containing only the specified properties. This enables partial updates where only certain fields need to be modified, reducing payload size and avoiding unintended changes to other properties.

    Specified by:
      `toUpdateJson` in interface `IUpdatable`
    Parameters:
      `propertyNames` - List of property names to include in the JSON. If null or empty, all modified properties are included.
    Returns:
      JSON string representation for updating specific properties

  - ### getAboutMe

    public String getAboutMe()

  - ### setAboutMe

    public void setAboutMe​(String aboutMe)

  - ### getAccountEnabled

    public boolean getAccountEnabled()

  - ### setAccountEnabled

    public void setAccountEnabled​(boolean accountEnabled)

  - ### getAgeGroup

    public AgeGroup getAgeGroup()

  - ### setAgeGroup

    public void setAgeGroup​(AgeGroup ageGroup)

  - ### getBusinessPhones

    public List<String> getBusinessPhones()

  - ### getAssignedLicenses

    public List<AssignedLicense> getAssignedLicenses()

  - ### getAssignedPlans

    public List<AssignedPlan> getAssignedPlans()

  - ### getBirthday

    public Date getBirthday()

  - ### setBirthday

    public void setBirthday​(Date birthday)

  - ### getCity

    public String getCity()

  - ### setCity

    public void setCity​(String city)

  - ### getCompanyName

    public String getCompanyName()

  - ### setCompanyName

    public void setCompanyName​(String companyName)

  - ### getConsentProvidedForMinor

    public ConsentProvidedForMinor getConsentProvidedForMinor()

  - ### setConsentProvidedForMinor

    public void setConsentProvidedForMinor​(ConsentProvidedForMinor consentProvidedForMinor)

  - ### getCountry

    public String getCountry()

  - ### setCountry

    public void setCountry​(String country)

  - ### getCreatedTime

    public Date getCreatedTime()

  - ### setCreatedTime

    public void setCreatedTime​(Date createdTime)

  - ### getDeletedTime

    public Date getDeletedTime()

  - ### setDeletedTime

    public void setDeletedTime​(Date deletedTime)

  - ### getDepartment

    public String getDepartment()

  - ### setDepartment

    public void setDepartment​(String department)

  - ### getDisplayName

    public String getDisplayName()

  - ### setDisplayName

    public void setDisplayName​(String displayName)

  - ### getEmployeeId

    public String getEmployeeId()

  - ### setEmployeeId

    public void setEmployeeId​(String employeeId)

  - ### getExternalUserState

    public ExternalUserState getExternalUserState()

  - ### setExternalUserState

    public void setExternalUserState​(ExternalUserState externalUserState)

  - ### getExternalUserStateChangeTime

    public Date getExternalUserStateChangeTime()

  - ### getFaxNumber

    public String getFaxNumber()

  - ### setFaxNumber

    public void setFaxNumber​(String faxNumber)

  - ### getGivenName

    public String getGivenName()

  - ### setGivenName

    public void setGivenName​(String givenName)

  - ### getImAddresses

    public List<String> getImAddresses()

  - ### isResourceAccount

    public boolean isResourceAccount()

  - ### setAsResourceAccount

    public void setAsResourceAccount​(boolean isResourceAccount)

  - ### getHireDate

    public Date getHireDate()

  - ### setHireDate

    public void setHireDate​(Date hireDate)

  - ### getInterests

    public List<String> getInterests()

  - ### getJobTitle

    public String getJobTitle()

  - ### setJobTitle

    public void setJobTitle​(String jobTitle)

  - ### getLegalAgeGroupClassification

    public LegalAgeGroupClassification getLegalAgeGroupClassification()

  - ### getLicenseAssignmentStates

    public List<LicenseAssignmentState> getLicenseAssignmentStates()

  - ### getEmailAddress

    public String getEmailAddress()

  - ### getMailboxSettings

    public MailboxSettings getMailboxSettings()

  - ### setSkuId

    public void setSkuId​(MailboxSettings mailboxSettings)

  - ### getMailNickname

    public String getMailNickname()

  - ### setMailNickname

    public void setMailNickname​(String mailNickname)

  - ### getMobilePhone

    public String getMobilePhone()

  - ### setMobilePhone

    public void setMobilePhone​(String mobilePhone)

  - ### getMySite

    public String getMySite()

  - ### setMySite

    public void setMySite​(String mySite)

  - ### getOfficeLocation

    public String getOfficeLocation()

  - ### setOfficeLocation

    public void setOfficeLocation​(String officeLocation)

  - ### getOnPremisesDistinguishedName

    public String getOnPremisesDistinguishedName()

  - ### getOnPremisesDomainName

    public String getOnPremisesDomainName()

  - ### getOnPremisesExtensionAttributes

    public OnPremisesExtensionAttributes getOnPremisesExtensionAttributes()

  - ### setOnPremisesExtensionAttributes

    public void setOnPremisesExtensionAttributes​(OnPremisesExtensionAttributes onPremisesExtensionAttributes)

  - ### getOnPremisesImmutableId

    public String getOnPremisesImmutableId()

  - ### setOnPremisesImmutableId

    public void setOnPremisesImmutableId​(String onPremisesImmutableId)

  - ### getOnPremisesLastSyncTime

    public Date getOnPremisesLastSyncTime()

  - ### getOnPremisesProvisioningErrors

    public List<OnPremisesProvisioningError> getOnPremisesProvisioningErrors()

  - ### getOnPremisesSamAccountName

    public String getOnPremisesSamAccountName()

  - ### getOnPremisesSecurityIdentifier

    public String getOnPremisesSecurityIdentifier()

  - ### getOnPremisesSyncEnabled

    public boolean getOnPremisesSyncEnabled()

  - ### getOnPremisesUserPrincipalName

    public String getOnPremisesUserPrincipalName()

  - ### getOtherEmailAddresses

    public List<String> getOtherEmailAddresses()

  - ### getPasswordPolicies

    public String getPasswordPolicies()

  - ### setPasswordPolicies

    public void setPasswordPolicies​(String passwordPolicies)

  - ### getPasswordProfile

    public PasswordProfile getPasswordProfile()

  - ### setPasswordProfile

    public void setPasswordProfile​(PasswordProfile passwordProfile)

  - ### getPastProjects

    public List<String> getPastProjects()

  - ### getPostalCode

    public String getPostalCode()

  - ### setPostalCode

    public void setPostalCode​(String postalCode)

  - ### getPreferredDataLocation

    public String getPreferredDataLocation()

  - ### setPreferredDataLocation

    public void setPreferredDataLocation​(String preferredDataLocation)

  - ### getPreferredLanguage

    public String getPreferredLanguage()

  - ### setPreferredLanguage

    public void setPreferredLanguage​(String preferredLanguage)

  - ### getPreferredName

    public String getPreferredName()

  - ### setPreferredName

    public void setPreferredName​(String preferredName)

  - ### getProvisionedPlans

    public List<ProvisionedPlan> getProvisionedPlans()

  - ### getProxyAddresses

    public List<String> getProxyAddresses()

  - ### getRefreshTokensValidFromTime

    public Date getRefreshTokensValidFromTime()

  - ### getResponsibilities

    public List<String> getResponsibilities()

  - ### getSchools

    public List<String> getSchools()

  - ### getShowInAddressList

    public boolean getShowInAddressList()

  - ### setShowInAddressList

    public void setShowInAddressList​(boolean showInAddressList)

  - ### getSkills

    public List<String> getSkills()

  - ### getSignInActivity

    public List<SignInActivity> getSignInActivity()

  - ### getState

    public String getState()

  - ### setState

    public void setState​(String state)

  - ### getStreetAddress

    public String getStreetAddress()

  - ### setStreetAddress

    public void setStreetAddress​(String streetAddress)

  - ### getSurname

    public String getSurname()

  - ### setSurname

    public void setSurname​(String surname)

  - ### getUsageLocation

    public String getUsageLocation()

  - ### setUsageLocation

    public void setUsageLocation​(String usageLocation)

  - ### getPrincipalName

    public String getPrincipalName()

  - ### setPrincipalName

    public void setPrincipalName​(String principalName)

  - ### getType

    public String getType()

  - ### setType

    public void setType​(String type)