Re: Implementing row-level security (SQL/AD)



Br@dley <n0mail@xxxxxx> wrote:
> MGFoster <me@xxxxxxxxxxx> wrote:
>> Br@dley wrote:
>>> I'm going to go into a fair bit of detail as I'm hoping my methods
>>> may be of assistance to anyone else wanting to implement something
>>> similar (or totally confusing:)
>>>
>>> One of systems I've developed has three levels of security.
>>>
>>> Admins - can see all records
>>> Manager - can only see records based on an organisation structure
>>> held in a table (simple tree structure)
>>> Employee - can only see own records
>>>
>>> The system uses a table which contains 'login', 'employeeid' (level
>>> is determined from security group/role)
>>>
>>> User account creation is controlled by a form which forces the
>>> account to be associated with an employeeid (if manager/employee
>>> level). This is the critical step.
>>>
>>> I then use queries (row-level security) to return only the employee
>>> records that person can view based on the user role and the
>>> employeeid. (This has been implemented in both Access and for SQL
>>> backends). Still with me? :)
>>>
>>> In our Access version that is all fine and works well. In SQL
>>> however it means that all security still has to be administered
>>> through the client software to link employee's to a login.
>>>
>>> User account details are entered into a form and then I use a stored
>>> procedure that creates an SQL account, give permissions to the
>>> database, assign the user to a database role and then create an
>>> entry in my users table linking them to an employee record. I then
>>> put a user-defined function as the criteria in my views so they
>>> return only the appropriate employee records. The function checks
>>> the current database role and gets the current user's employeeid
>>> from the user table and then returns a true/false if that employeeid
>>> is valid for the person to see. Admin level - allow all records
>>>
>>> Manager level - This one is a little trickier since it's not just
>>> returning all the employee's that belong to the organisation unit
>>> that the person manages but also all the people of the sub-units as
>>> well (it needs to cascade all the way down the tree levels). This is
>>> done by creating a special field in the organisation table which
>>> contains a string of all the parent ID's in the structure for each
>>> unit (eg. unit 12's string might be ';1;5;12;'). This allows a
>>> simple query to be used (eg. a criteria of LIKE *;5;* returns all
>>> the organisation units who are children, grand-children, etc of unit
>>> 5). Employee level - return only records for current user's
>>> employeeid
>>>
>>> The link between the login and an employee record is the hurdle I
>>> can't seem to get past. I can't see any other way to implement this
>>> type of security.
>>>
>>> The reason we want to remove administration from the client is so
>>> the administration can be done solely on the server or even better
>>> using Active Directory.
>>>
>>> This is probably "pie in the sky" stuff but it would be nice to be
>>> able to determine this link automatically or use some other method.
>>>
>>> ie. if domain\group is given manager level access to the database
>>> (ie. made a member of my manager database role in SQL) then a member
>>> of this windows group then has access to the database but somehow
>>> can only see the records of the people they manage???
>>>
>>> I might have to create a mixed environment where manager/employee
>>> level is for user accounts (requiring a link to be made to an
>>> employee record manually via the client), whereas admin level can be
>>> for either user accounts or groups.....
>
>> First a carp, then a suggestion.
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Carp: Having more than one value in a column violates 1NF

<>

>> , i.e., each
>> cell must be atomic (only one piece of data in a cell [aka Field]).
>> You can solve your hierarchical problem by using nested sets. See
>> this site for an MS SQL version of a nested set solution:
>>
>> http://toponewithties.blogspot.com/

> Funnily enough I've done a very similar thing....

Actually I've implemented the Materialised Path method without knowing
it:)

"[using a] node's primary keys within the path string"
http://www.dbazine.com/oracle/or-articles/tropashko4

Obviously the limitation of this method is that the path strings needs
to be updated if records are changed. I simply rebuild all the strings
every time the user leaves the organisation screen as it is a very fast
operation to perform.

<>
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response


.



Relevant Pages

  • Re: Implementing row-level security (SQL/AD)
    ... In SQL however it means that all security still has to be administered through the client software to link employee's to a login. ... User account details are entered into a form and then I use a stored procedure that creates an SQL account, give permissions to the database, assign the user to a database role and then create an entry in my users table linking them to an employee record. ... Manager level - This one is a little trickier since it's not just returning all the employee's that belong to the organisation unit that the person manages but also all the people of the sub-units as well. ...
    (comp.databases.ms-access)
  • Re: Restrict access for single user to certain tables?
    ... Create a User Account in the database linked to the sql Login ... database role to the User Account in the database. ...
    (microsoft.public.sqlserver.security)
  • Re: Problems connecting to SQL Server
    ... I sat down on the SQL 7 Server and used the SQL ... this with the SA user account / password combination. ... set up the DSN because the application that uses the DSN must supply a ... So, now to MDAC. ...
    (microsoft.public.sqlserver.clients)
  • Re: Sicherheitsupdate installieren
    ... This error occurs when the installation program can't ... start the SQL Server ... invalid user account, user account does not have permission to start ... Hoffe, das Hilft. ...
    (microsoft.public.de.sqlserver)
  • I see whats wrong with forced protocol encryption now! Heres the easiest solution.
    ... Assuming you have a box ready for an SQL install. ... Create yourself an unprivileged user account. ... Install SQL server. ...
    (microsoft.public.sqlserver.security)