473,767 Members | 7,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access restrictions on rows depending on value of the a column

Hello All,

There is data of several enterprises (ours clients) in a single database.
All tables have a column on primary key what identify the enterprise called
id_enterprise.
My objective is restrict users access on rows depending on value of the
column id_enterprise.
That is, an user can access data only of his enterprise.

I don't want use where clause.
There is some way of determine this in database?

Thanks in advance,

Renato Cramer.

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
2 1872
On Thu, Aug 12, 2004 at 09:54:25 -0300,
Renato Cramer <re****@domsis. com.br> wrote:
Hello All,

There is data of several enterprises (ours clients) in a single database.
All tables have a column on primary key what identify the enterprise called
id_enterprise.
My objective is restrict users access on rows depending on value of the
column id_enterprise.
That is, an user can access data only of his enterprise.

I don't want use where clause.
There is some way of determine this in database?


You can use a view to do this. If they need to modify the data, then you
will need to use rules to make an updateable view. The easy way to do
this is to have a table that maps users to the id_enterprise values that
they are allowed to access and for each table you want to grant access
to, join this special table in the view using the current_user as the
the user to test against.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 23 '05 #2
On Thu, Aug 12, 2004 at 09:54:25AM -0300, Renato Cramer wrote:
There is data of several enterprises (ours clients) in a single database.
All tables have a column on primary key what identify the enterprise called
id_enterprise.
My objective is restrict users access on rows depending on value of the
column id_enterprise.
That is, an user can access data only of his enterprise.
By "user" do you mean a PostgreSQL user, i.e., a user that can
connect directly to the database? Or do the users access the
database via an application? How is a user associated with a
particular id_enterprise value?

What kind of access to users require? Select only? Or also
insert, update, and delete?
I don't want use where clause.
There is some way of determine this in database?


For selects you could use views that join the tables against
a lookup table using id_enterprise and CURRENT_USER. Queries
against a view would get a subset of what's in a table, based
on who's doing the query. This assumes that the database user
can be mapped to one or more id_enterprise values via the
lookup table.

If you need to restrict inserts, updates, and deletes, then you
could use rules and/or triggers.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
5756
by: Dan. | last post by:
hi there, a while back i got into a bit of ASP programming and needed database access. since msAccess was installed on the system i was using at the time i used that and have used that since. but then i heard something about sql and that it's better to change to that as early as you can because it's hard converting access databases and all the code that goes along with it. i would like to know what advantages the sql holds over access. ...
14
5419
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why I get worse response time when the optimizer uses two indexes, than when it uses one. Some context:
3
14315
by: MrNobody | last post by:
I've read that the expression property for DataColumns is used to "Sets or retrieves the expresssion used to filter rows, calculate the values in a column, or create an aggregate column.". I have seen examples on how to filter a column, but how would I filter out an entire row depending on the value of a column? For example, if I wanted to filter out every row in a multi-column table where the "Is Fubar" column equals "true", how would...
6
1443
by: em | last post by:
Hi all, I'm new to C# from VB6 and I'm playing around with SQL server. I can show the value of each field in my datatable with the following loop .... foreach(DataRow myRow in dt.Rows) { foreach(DataColumn myCol in dt.Columns) {
5
36880
by: Richard Dixson | last post by:
I created a new C# web application. Basically all I am trying to do is create a table that consists of a few rows with two columns in each. And then to set those columns to text values from my code behind. However I am not able to do this at all, I am going about this wrong, I think and need guideance. If this was just straight HTML I would do this: <table> <tr><td>field 1</td><td>value 1 set by code behind</td></tr>
0
8642
by: | last post by:
I am testing the following piece of code: Is it possible to list the row number containing the checked box? After checking the desired box, I would want a message box to popup listing the row numbers on the process button click event. Many thanks Option Explicit On Option Strict On Imports System.Data ' Form to show the order's for a customer. Public Class CustomerOrdersForm
4
12441
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
1
7461
by: Chris | last post by:
Hi, I'm using the following code DataTable tables = ((OleDbConnection)oleconn).GetOleDbSchemaTable( OleDbSchemaGuid.Tables, new object { null, null, null, "TABLE" }); foreach (DataRow r in tables.Rows) { string tableName = r as string; //
9
3943
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to one form however, and I think it's hiding somewhere in my code associated with this form, which is...
0
9575
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9407
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10014
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9960
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.