Solved

login to db user mapping/alias

Posted on 2004-09-10
2
703 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

710 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