?
Solved

login to db user mapping/alias

Posted on 2004-09-10
2
Medium Priority
?
718 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 250 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In this article, WatchGuard's Director of Security Strategy and Research Teri Radichel, takes a look at insider threats, the risk they can pose to your organization, and the best ways to defend against them.
Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 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