anchor.diff:          true ->
               throw({error,conflict});
           false ->
  -            apply(db:get(?MODULE, Domain), add, [Domain, User]),
               uce_role:add(Domain, #uce_role{id={UId, Domain}}),
  -            uce_user:addRole(Domain, {UId, Domain}, {"default", []}),
  -            uce_user:addRole(Domain, {UId, Domain}, {UId, []}),
  +
  +            DefaultRoles = [{"default", ""}, {UId, ""}],
  +            apply(db:get(?MODULE, Domain), add,
  +                  [Domain, User#uce_user{roles=User#uce_user.roles ++ DefaultRoles}]),
               {ok, UId}
       end.
   
  
positive.code:         true ->
              apply(db:get(?MODULE, Domain), update, [Domain, User]);
          false ->
              throw({error, not_found})
      end.
  
  list(Domain) ->
      apply(db:get(?MODULE, Domain), list, [Domain]).
  
negative.code:         {error, _} -> throw({error, not_found});
          {ok, User} -> apply(db:get(?MODULE, Domain), delete, [Domain, User#uce_user.id])
      end;
  delete(Domain, {Uid, _} = Id) ->
      case exists(Domain, Id) of
          true ->
              % delete the default role
              case catch uce_role:delete(Domain, {Uid, Domain}) of
                  {error, Reason} when Reason /= not_found ->
                      throw({error, Reason});
                  _ ->
                      apply(db:get(?MODULE, Domain), delete, [Domain, Id])
              end;
          false ->
              throw({error, not_found})
      end.
  