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
  • 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)