code: public static function createNewUser($username,$individualGroupAssignmentOptions = null) {
          if(static::getExtensionOptions('ENABLE_YII2_PROFILING') == true) {
              Yii::beginProfile('createNewUser', static::YII2_PROFILE_NAME . 'createNewUser');
          }
          
          $userObjectDb = new static();
  
          //Username has to be set before a LDAP query
          $userObjectDb->username = $username;
          $userObjectDb->setIndividualGroupAssignmentOptions($individualGroupAssignmentOptions);
          
          //Check if user exists in LDAP.
          if($userObjectDb->queryLdapUserObject() == null) {
              $userObjectDb = null;
          } else {
              $roles = $userObjectDb->updateGroupAssignment();
  
              //When a group is needed for login and no roles are assigned to user, don't create one
              if (count($roles) > 0 || static::getGroupAssigmentOptions('LOGIN_POSSIBLE_WITH_ROLE_ASSIGNED_MATCHING_REGEX',$userObjectDb->individualGroupAssignmentOptions) == null) {
                  $userObjectDb->generateAuthKey();
                  $userObjectDb->updateAccountStatus();
                  $userObjectDb->save();
              } else {
                  $userObjectDb = null;
              }
          }
          
          if(static::getExtensionOptions('ENABLE_YII2_PROFILING') == true) {
              Yii::endProfile('createNewUser', static::YII2_PROFILE_NAME . 'createNewUser');
          }        
          return $userObjectDb;
      }
docs: Create a new object in database.
  
  @param string $username username of the LDAP user.
  @return Edvlerblog\Adldap2\model\UserDbLdap object. Null if the username is not found in LDAP.