Additionally JSON-RPC should bail out if host is already joined. Check HTTP status of JSON-RPC request and report 401 Unauthorized error explicitly. Related: https://pagure.io/freeipa/issue/7966 Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>