tags:

views:

17

answers:

1

I'm making a call to odbc32.dll (SQLBrowseConnect) to return a list of databases on a sql server.

From running a trace I can see the query being executed is

select name from master..sysdatabases where has_dbaccess(name)=1

If the credentials I pass aren't the sa user it returns just the system databases. Is there anyway I can use SQLBrowseConnect with another user (whose default database is also not guarenteed to be the master database) to return all databases on the server?

Also I want to avoid smo objects

A: 

The query does work without sysadmin credentials.

You need to ensure that you / the credentials you are using are at least in the public database role on each of the databases that you need to connect to.

As you would guess, select name from master..sysdatabases returns all database names irrespective of your access to the DB.

nonnb