Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to Check user accessibility.

Author  Topic 

hdv212
Posting Yak Master

140 Posts

Posted - 2008-05-21 : 16:56:06
hi
i want when user connect to sql server and wants to do some works via my app, before doing nothing, check accessibility of user whether he/she can access that object or not, but i don't know which sp or function or view is useful for this work,can anyBody help me ?
thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-21 : 16:58:47
This doesn't make sense. Just run your query and catch the error if the user doesn't have permissions. Act according to the error.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

hdv212
Posting Yak Master

140 Posts

Posted - 2008-05-21 : 17:10:43
thanks tKizer
but i want to when user could not access to that object, my app display an Appropriate message to it ?
how to handle this type of exception ?
thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-21 : 17:12:08
You will know when you catch the error.

Use a Try/Catch and in the catch put your message code when a permissions error has occurred.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

hdv212
Posting Yak Master

140 Posts

Posted - 2008-05-21 : 17:14:13
which exception has permission error ?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-21 : 17:19:23
It should be error 229.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

hdv212
Posting Yak Master

140 Posts

Posted - 2008-05-21 : 17:37:35
thanks tkizer
i was test your suggestion in sample app and works correctly.
very thanks.
regards
Go to Top of Page
   

- Advertisement -