|
|
|
|
![]() ![]() |
Dec 25 2005, 01:38 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 407 Joined: 13-December 04 Member No.: 2,696 |
I'm working on a piece of user/group authentication and I've run into a question that has to do with ASP coding, I think. I have very little experience with ASP, though.
In essence, I have a couple of tables: users, groups, articles, Permissions for articles, and Groupmemberships... So, on a page, it opens up the article and looks for what groups have been given access to the article... It then looks at the userID (session variable) and determines what groups the user belongs to.... you I'll have 2 lists, the groups the user is in and the the groups that have access to the article... If there is any common between the two, then the user has access... otherwise they don't. So... User Group IDs^^^^^^^^^^^Article Group IDs 1^^^^^^^^^^^^^^^^^^^3 3^^^^^^^^^^^^^^^^^^^4 7^^^^^^^^^^^^^^^^^^^2 This person would have permission because the user belongs to one or more groups that have permission... or... User Group IDs^^^^^^^^^^^Article Group IDs 1^^^^^^^^^^^^^^^^^^^8 3^^^^^^^^^^^^^^^^^^^4 7^^^^^^^^^^^^^^^^^^^2 This person would get an access denied error.... So, my question is, how would I compare the two to see if there are any common elements in ASP or SQL? The data is in a MS SQL database... Thanks, |
|
|
|
Jan 30 2006, 05:51 PM
Post
#2
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 40 Joined: 29-January 06 Member No.: 17,841 |
You have provided both the tables the same. I am assuming this is your table structure
----------------------------- User-group ----------------------------- user-id, group-id ----------------------------- group-articles ----------------------------- group-id, article-id You can use sql to check the permissions CODE select * from user-group, group-articles where user-group.group-id=group-articles.group-id and user-id=<user id> and article-id=<article id> replace <> with actual values. If this query returns results, then the user has permission. Otherwise, he doesn't. Note that it requires only one query. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 20th July 2008 - 05:36 PM |