Re: getting all groups where a user belongs to

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Keresztury Balázs <balazs(at)gaslightmusic(dot)hu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: getting all groups where a user belongs to
Date: 2009-09-06 22:56:16
Message-ID: 14261.1252277776@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?iso-8859-2?Q?Keresztury_Bal=E1zs?= <balazs(at)gaslightmusic(dot)hu> writes:
> For example: there is a Service user, called Joe, who belongs to the group
> called SER. There is an other one, Kim, who's an administrator (ADM), which
> inherits rights from both SER and CEO. My problem is that I need a query,
> which returns _all_ the group names which Kim belongs to.
> I already find a solution to get the direct parents of a role, but I'd like
> to have all of them to use it for access control.

You could do something like

select rolname from pg_roles where pg_has_role('Kim', rolname, 'USAGE');

but this isn't going to be terribly efficient if you do it over and
over. You should probably think twice about whether you really need
that data in explicit form on the client side.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-09-06 23:29:48 Re: More Snow Leopard problems...
Previous Message Johan Nel 2009-09-06 22:29:49 Re: getting all groups where a user belongs to