Query users

This topic contains examples of how to:

  • Query a single user
  • Query all users
  • Query user by first name

Querying a single user

To query a specific user, you must perform the following:

  1. Get instance of the user manager.
    The manager is represented by the UserManager class. For more information about getting the instance, see For developers: Users.
  2. Get the user.
    To get the specified user, call the GetUser method of the UserManager class. It has two overloads:
    • GetUser(string username) – returns the user with the specified username.
    • GetUser(Guid id) – returns the user with the specified ID.

NOTE: To learn how to query the profile of the user, read For developers: Query user profiles.

Here is a code example:

Querying all users

To query all users, you must perform the following:

  1. Get instance of the user manager.
    The manager is represented by the UserManager class. For more information about getting the instance, see For developers: Users.
  2. Get all users.
    To get all users, call the GetUsers method of the UserManager class.

Here is a code example:

Querying a user by first name

Normally you can get the user object by any of the User class properties. For example in order to get a user by username, you can use the following code:

However some of the fields of the user are no longer properties of the User class like first name and last name. Instead you should use the SitefinityProfile. Here is a sample code that demonstrates how to query all users by first name:




Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Modify users