pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Raj Mathur <raju@linux-delhi.org>
To: pgsql-admin@postgresql.org
Subject: Users and groups
Date: Fri, 14 Feb 2003 09:21:14 +0530
Message-ID: <15948.26546.900701.127373@mail.linux-delhi.org> (raw)

Hi,

Using PostgreSQL 7.2.3 on a Linux box and facing some minor issues
with determining which groups users belong to.

I have created a PgSQL group called `administrators'.  Now when I need
to check whether user X is a member of that group, I use the
contrib/array_iterator operator to do something like,

select groname from pg_group where grolist **=
       ( select usesysid from pg_user where usename = 'X' ) ;

This works just fine.  However, the complementary process, determining
all the users in group administrators, isn't so clean.  Currently I'm
brute-forcing it, getting each user in turn and then checking whether
she belongs to group administrators using the construct above.

Is there a simpler way?

Also, are there any caveats attached to using the pg_ system tables
directly?  I prefer to do that to prevent duplication of user status:
let PgSQL store whether the user is an administrator or not rather
than have another table keeping that information.  However, I'd change
that if the structure of the pg_ tables is subject to change from time
to time.

Regards,

-- Raju
-- 
Raj Mathur                raju@kandalaya.org      http://kandalaya.org/
                      It is the mind that moves



view thread (5+ messages)  latest in thread

Message-ID: <15948.26546.900701.127373@mail.linux-delhi.org>
Permalink:  ../15948.26546.900701.127373@mail.linux-delhi.org/
Also on:    postgresql.org/message-id/15948.26546.900701.127373@mail.linux-delhi.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: raju@linux-delhi.org
  Subject: Re: Users and groups
  In-Reply-To: <15948.26546.900701.127373@mail.linux-delhi.org>
  References: <15948.26546.900701.127373@mail.linux-delhi.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox