Get Login Group

Get Login Group

Post by Greg Strau » Tue, 12 Dec 1995 04:00:00



I am using VB 3.0 to connect to SQL Server 6.0 via ODBC API. Is there
a way to obtain the SQL Server _group_ that the currently logged in
user belongs to? My application will implement certain functions if
the current user belongs to a certain group.

Thanks for any help.
--------------------------------------

Victoria, BC, Canada

"...You can see the World from here!"
--------------------------------------

 
 
 

Get Login Group

Post by El » Sat, 16 Dec 1995 04:00:00


: > I am using VB 3.0 to connect to SQL Server 6.0 via ODBC API. Is there
: > a way to obtain the SQL Server _group_ that the currently logged in
: > user belongs to? My application will implement certain functions if
: > the current user belongs to a certain group.
: >
: > Thanks for any help.
: > --------------------------------------

: > Victoria, BC, Canada
: >
: > "...You can see the World from here!"
: > --------------------------------------
: >
:
: select  'group' = name
: from    sysusers u1,
:         sysusers u2
: where   u1.uid = user_id()
: and     u1.gid = u2.gid
: and     u2.suid < 0

Nice, but curious, why the last line?

Elliott

 
 
 

Get Login Group

Post by davi » Tue, 19 Dec 1995 04:00:00


To get the database group you can also use the following
stored procedure.

select user_name(gid)
from sysusers


the connection string.  This query will not require
a self join.

 
 
 

Get Login Group

Post by Simon Walke » Tue, 19 Dec 1995 04:00:00



> : > I am using VB 3.0 to connect to SQL Server 6.0 via ODBC API. Is
there
> : > a way to obtain the SQL Server _group_ that the currently logged in
> : > user belongs to? My application will implement certain functions if
> : > the current user belongs to a certain group.
> : >
> :
> : select  'group' = name
> : from    sysusers u1,
> :         sysusers u2
> : where   u1.uid = user_id()
> : and     u1.gid = u2.gid
> : and     u2.suid < 0

> Nice, but curious, why the last line?

> Elliott

Because users and groups are held in the same table, differentiated only
by groups having suids < 0...
If you leave out the last line you get the group row and the user row.

There is actually a slight mistake in the above code - it should read:

        select  'group' = u2.name
        ...               ^^^

I expect one of the reasons why it's taking so long to implement
multiple-group membership is the design of this table, another Sybase
classic.  

Cheers,
simon walker
The SQL Workshop
Milton Keynes, UK

 
 
 

Get Login Group

Post by Simon Walke » Wed, 20 Dec 1995 04:00:00


> To get the database group you can also use the following
> stored procedure.

> select user_name(gid)
> from sysusers


Indeed.  Nice one.  

 select user_name(gid)
 from sysusers
 where uid = user_id()

to refine that for the current connection.

You learn something new every day.  Or if not actually *every* day, at
least every other day.  Except weekends and national holidays of course.  
And Fridays in my case.  I never learn anything on Fridays.  

simon walker
The SQL Wibbler
Great Wittering, UK

 
 
 

1. Getting the login????

I know there must be a way to do this but i'm having trouble getting it to
work.

I have a database that rests on a sql server and the login to the server is
taken from the NT login.  (less passwords for users is always a good thing).

What i want is if a user modifies any data on the form, the "DateModified"
field get set to the current date and the "ModifiedBy" field gets assigned
their userid.

I did it in SQL 7.0 but when i bring it into access, it doesn't seem to do
anything.  I know there is just something small that i'm missing and i'm
sure thousands have done this before me.  Having said that, could someone
help me out with the solution????

Noel Murphy

2. pgsql/src/bin/pg_dump Tag: REL7_2_STABLE pg_dump.c

3. xp_sendmail w/@query gets 17969 - Unable to Login to SQL Server

4. ADO connection string path?

5. Getting Windows NT Login Name in a Trigger

6. Update Problem? No error with no record.

7. Getting my login SPID

8. xp_cmdshell and bcp

9. Users getting SQL Server Login dialog

10. Getting User's NT Login programatically

11. Getting around MS Access login prompt - how?

12. Getting rid of ReportSmith login prompt