core: SQL exception is thrown when assigning a permissions

The SQL exception occurs as the user (or group) is added to the database,
even though it was already added.
This happens as webadmin passes the group and user objects with a NULL id
(the external ID is the one that represents the "real id" - that is the id
in the external directory system).

The solution is to check if such a user (or a group) already exists in DB,
and if not - add it.

Change-Id: Ie518061d081c09a25fe5582899a6105df629ab06
Bug-Url: https://bugzilla.redhat.com/1057147
Signed-off-by: Yair Zaslavsky <yzaslavs@redhat.com>