Solved

login to db user mapping/alias

Posted on 2004-09-10
2
709 Views
Last Modified: 2006-11-17
Hi,
using Sybase Central on ASE 12.5.* if I examine a particular login the Users tab displays which users in  which databases are mapped to this login. e.g. by default the sa login is mapped to the dbo user in master, model, sybsystemdb and sybsystemprocs databases.

How can I pull this info out using SQL? syslogins and sysdatabases don't seem to have the right relationship? Can this be done with out querying each individual db?
0
Comment
Question by:skehanb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
grant300 earned 125 total points
ID: 12032552
You have to query the sysusers table in each database, however, it is not a problem if you know the databases you are interested in.  Just create a view in sybsystemprocs that does a UNION ALL query of the sysusers tables in all of the databases you are interested in.  Then you can join that to master..syslogins
or, for that matter, but the join right in the view.  Your done.

If you have to make the routine dynamic so that you don't have to know the database names ahead of time, just write a little stored procedure to get it for you.  Open a cursor on sysdatabases, create a temp table, build a dynamic sql statement to insert/select the contents of each sysusers table into the temp table, then join that mess with syslogins and you are done.

Hope that helps.

Bill
0
 
LVL 6

Expert Comment

by:ChrisKing
ID: 12033080
Rob Verschoor (www.sypron.nl) has a lot of handy little utilities for just such a purpose:

There are many of them but the one that I am think of is "sp_rv_exec" that executes a procedure in every database.

Rob's examples show:
exec sp_rv_exec "sp_adduser", "jsmith"                          -- adds user "jsmith" to all databases
exec sp_rv_exec "sp_addtype", "newtype", "char(25)"      -- adds datatype "newtype" to all databases

so why not:
exec sp_rv_exec "sp_helpuser", "fred"

check it out at http://www.sypron.nl/new_ssp.html
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Getting to know the threat landscape in which DDoS has evolved, and making the right choice to get ourselves geared up to defend against  DDoS attacks effectively. Get the necessary preparation works done and focus on Doing the First Things Right.
This article explains the fundamentals of industrial networking which ultimately is the backbone network which is providing communications for process devices like robots and other not so interesting stuff.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question