0

I'm working with a legacy system that attempts to execute schema changes in SQL for specific users by first querying sysobjects as that user to determine if the object exists. If it does it creates an ALTER VIEW statement otherwise it creates a CREATE VIEW statement. In this case the view exists, but the query continues to fail to list the object.

For example:

setuser 'APPLICATION_DEV'
Select * from sysobjects o, sysusers u
where u.uid = o.uid 
and u.name = N'APPLICATION_DEV'

The problem is that certain accounts in this database can run this query without error and it returns all of the objects owned by that user. Other accounts however get no records returned by this query. If I setuser to SA and run the query all of that users objects appear. The affected user is the owner of the schema and has create view permissions on the schema. I cannot find any differences in permissions between a working user and a non-working user account.

Is there a permission that I am missing that would restrict a user from querying their own objects in sysobjects?

Yes, I know sysobjects is obsolete, but I have no control over the actual code here and instead have to fix the database so their code will work as expected.

EDIT: Additional findings. To complicate matters I can run this succesfully:

setuser 'APPLICATION_DEV'
Select * from sysusers
Where name = 'APPLICATION_DEV'

I can also execute this succesfully:

setuser 'APPLICATION_DEV'
Select * from sysobjects
Where uid = 308 --308 is the uid of the APPLICATION_DEV user

However, when I use a join either in the where clause or via INNER JOIN I then get no records. What would restrict my access to records purely based on the join? Index permissions?? I'm baffled.

1 Answers1

0

For the particular user in user mapping check whether you have checked all the checkboxes apart from db_denydatareader and db_denydatawriter.

also check this
The SELECT permission was denied on the object 'sysobjects', database 'mssqlsystemresource', schema 'sys'
http://social.msdn.microsoft.com/Forums/en/sqlsecurity/thread/a2befd20-2a9b-4a60-95a9-3a80a1a99ea1

Community
  • 1
  • 1
Vijay Hulmani
  • 969
  • 8
  • 17
  • Hi, thanks for the response. There are no roles checked for the working or broken users. In addition, the user CAN query sysobjects it just returns dbo objects only and no objects for it's own UID. – user1695323 Jan 08 '13 at 16:12