Querying users

This topic contains examples of how to:

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
    Managing 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.

TIP: To learn how to query the profile of the user, read Querying user profiles.

Here is a code example:

public User GetUser(Guid userId)
{
    UserManager userManager = UserManager.GetManager();
 
    User user = userManager.GetUser(userId);
 
    return user;
}

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
    Managing users.
  2. Get all users.
    To get all users, call the GetUsers method of the UserManager class.

Here is a code example:

public List<User> GetAllUsers()
{
    UserManager userManager = UserManager.GetManager();
 
    List<User> users = userManager.GetUsers().ToList();
 
    return users;
}

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK