Hello
you can try
create or replace function is_member_of(text, text) returns boolean as $$
select exists(select rolname from pg_catalog.pg_auth_members m JOIN
pg_catalog.pg_roles b ON m.roleid = b.oid where m.member = (select oid
from pg_roles where rolname = $1) and rolname = $2)
$$ language sql ;
postgres=# select is_member_of('pavel','admin');
is_member_of
--------------
t
(1 row)
Regards
Pavel Stehule
2012/12/25 Philipp Kraus <[email protected]>:
> Hello,
>
> how can I check if a user is within a group? I use current_user() to get the
> logged-in user, but I have a group "service" and I need a check if the user
> is member of the group
>
> Thanks
>
> Phil
>
> --
> Sent via pgsql-general mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
--
Sent via pgsql-general mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general