Solved

login to db user mapping/alias

Posted on 2004-09-10
2
663 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
2 Comments
 
LVL 19

Accepted Solution

by:
grant300 earned 125 total points
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now