471,853 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

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 1934
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
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.