Creating user entry manually

I note that the entries in People are created automatically when a user logs in.

Is there a mechanism to create entries in advance of a user logging in ? I’d like to have an autocomplete based on user name to assign ownership but this would need me to ask the people to log in before they would match the autocomplete.

When I try to add a user, it is greyed-out (since the users are coming from SSO, I assume).

Dear Tim

You can create the user programmatically, you need the username and email

use Drupal\user\Entity\User;

      $check_user = user_load_by_name( $username );
      if( $check_user ) return FALSE; // user exists
      $user = User::create();

      // This username must be unique and accept only a-Z,0-9, - _ @ .

      // Mandatory settings
      // Optional settings
      $language = 'en';
      $user->set("langcode", $language);
      $user->set("preferred_langcode", $language);

      // Save user
      $res = $user->save();

      if (!$res) {
         \Drupal::messenger()->addMessage('Fail to register user:' . $username, 'error' );
         \Drupal::logger('CREATING USER')->error("Fail to register user @username", ['@username' =>$username ]);
         return FALSE;
      // reload the user to get uid
      $check_user = user_load_by_name( $username );

After that, you can assign roles, if necessary.

Best regards

Thanks - where should I put the code ? Would I need to create a new module ?

Dear Tim

As I see it
1- For an action that must be executed frequently, create a module.
2- For one execution, or test code:
Devel (Devel |
Devel PHP (Devel PHP |