Create user account programmatically

Hi, I have a db mysql with new accounts from LDAP every week. I wanted to create a PHP script with a cron who is creating user accounts from this db, how can i do that ? I’m trying to find the code in the D8 API.

I can select some fields with mysql request but I don’t know how to use it after to create an account and setup instantly a role to this account.

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed