System hook 'user_create' doesn't run when new ldap user created

Zendesk: https://gitlab.zendesk.com/agent/tickets/81750

It looks like this is happening because:

  1. LDAP users get created via Gitlab::LDAP::User#gl_user.
  2. This calls Gitlab::OAuth#build_new_user: https://gitlab.com/gitlab-org/gitlab-ce/blob/v9.5.1/lib/gitlab/o_auth/user.rb#L154-156
  3. This calls Users::BuildService (https://gitlab.com/gitlab-org/gitlab-ce/blob/v9.5.1/app/services/users/build_service.rb) instead of Users::CreateService, which does fire system hooks

I propose we move https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/services/users/create_service.rb#L13-17 into a helper, and run this in Users::UpdateService if the user.persisted? is false.

Edited by Stan Hu