diff --git a/src/Form/UwAddUsersForm.php b/src/Form/UwAddUsersForm.php
index 51d3e4cb68e35d0b7b1234094263cfd14bc03565..4e4668e4afabcf179cdd871be1dee8775912fbfb 100644
--- a/src/Form/UwAddUsersForm.php
+++ b/src/Form/UwAddUsersForm.php
@@ -4,12 +4,45 @@ namespace Drupal\uw_cfg_common\Form;
 
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\path_alias\AliasManager;
+use Drupal\user\Entity\User;
+use Drupal\uw_cfg_common\Service\UWLdap;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Form class for the content access form.
  */
 class UwAddUsersForm extends FormBase {
 
+  /**
+   * Path alias manager from core.
+   */
+  protected AliasManager $pathAliasManager;
+
+  /**
+   * UW Ldap service from uw_cfg_common module.
+   */
+  protected UWLdap $uwLdap;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    // Instantiates this form class.
+    return new static(
+      $container->get('path_alias.manager'),
+      $container->get('uw_cfg_common.uw_ldap')
+    );
+  }
+
+  /**
+   * Class constructor.
+   */
+  public function __construct(AliasManager $pathAliasManager, UWLdap $uwLdap) {
+    $this->pathAliasManager = $pathAliasManager;
+    $this->uwLdap = $uwLdap;
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -82,7 +115,7 @@ class UwAddUsersForm extends FormBase {
       if ($existing_user) {
         $this->messenger()->addError($this->t('The user ID <a href="@link"><em>@user</em></a> already exists and was skipped.',
           [
-            '@link' => \Drupal::service('path_alias.manager')->getAliasByPath('/user/' . $existing_user->uid->value),
+            '@link' => $this->pathAliasManager->getAliasByPath('/user/' . $existing_user->uid->value),
             '@user' => $user,
           ]
         ));
@@ -108,7 +141,7 @@ class UwAddUsersForm extends FormBase {
       $password = str_shuffle($password);
 
       // Do the LDAP lookup.
-      $person = \Drupal::service('uw_cfg_common.uw_ldap')->lookupPerson($user);
+      $person = $this->UWLdap->lookupPerson($user);
       if (!$person) {
         $this->messenger()->addError($this->t('The user ID <em>@user</em> could not be found (or was set to private) and was skipped.', ['@user' => $user]));
         continue;
@@ -118,7 +151,7 @@ class UwAddUsersForm extends FormBase {
       $email = empty($person['mail'][0]) ? $user . '@uwaterloo.ca' : $person['mail'][0];
 
       // Add the user.
-      $new_user = \Drupal\user\Entity\User::create();
+      $new_user = User::create();
       $new_user->setPassword($password);
       $new_user->enforceIsNew();
       $new_user->setEmail($email);
@@ -130,7 +163,7 @@ class UwAddUsersForm extends FormBase {
 
       $this->messenger()->addStatus($this->t('Created a new user with the user ID <a href="@link"><em>@user</em></a>.',
         [
-          '@link' => \Drupal::service('path_alias.manager')->getAliasByPath('/user/' . $new_user->uid->value),
+          '@link' => $this->pathAliasManager->getAliasByPath('/user/' . $new_user->uid->value),
           '@user' => $user,
         ]
       ));