469,283 Members | 2,228 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

How to write a function that will return true if user is in a certain role?

I have a SQL database with an Access front end. In the database I
have a read only and a read write role. When a read only user opens
the database I want all the fields on the form to be locked so that
the user will not try to change data and get an error from the server.

Right now I am doing that with a table. But it's a hassle to have to
maintain a table when if I could answer the question is the currently
logged in user in the read write role?

My server is running SQL Server 2000. So I was wondering if I could
write a function to do this? The function would take the role being
checked as a text parameter and return true if the currently logged in
user is in that role or false if he/she isn't.
Jul 20 '05 #1
1 1868
Tom Dauria (td*****@bu.edu) writes:
I have a SQL database with an Access front end. In the database I
have a read only and a read write role. When a read only user opens
the database I want all the fields on the form to be locked so that
the user will not try to change data and get an error from the server.

Right now I am doing that with a table. But it's a hassle to have to
maintain a table when if I could answer the question is the currently
logged in user in the read write role?

My server is running SQL Server 2000. So I was wondering if I could
write a function to do this? The function would take the role being
checked as a text parameter and return true if the currently logged in
user is in that role or false if he/she isn't.


Yes, you could probably write a function.

But it is not clear to me whether you are using SQL Server roles or
roles you have defined on your own.

If you are using SQL Server roles, you can simply say

SELECT is_memeber('readwrite-role')

So you don't even need a funcion in that case.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Stumped and Confused | last post: by
18 posts views Thread by jas | last post: by
8 posts views Thread by Mark White | last post: by
12 posts views Thread by raj s | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.