ASP Free Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherASP Free Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 24th, 2005, 08:15 AM
jmurrayhead jmurrayhead is offline
Moderator
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 13,091 jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)  Folding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Week 11 h 27 m 23 sec
Reputation Power: 1580
VBulletin permissions

I am experimenting with different ways to give permissions to do certain tasks on a web site I'm working on. I'm not satisfied with what I have come up with so far. I am looking at a VBulletin database and and confused on the concept of how the permissions work. I see they have multiple tables and use numbers, (i.e. 6458778). Do any of you know how they are doing this?

JMH
__________________
jmurrayhead

Did I help you out? Make me popular by clicking the icon!

New Members:Proper way to post a question

Powered by ASP.Net

Reply With Quote
  #2  
Old December 25th, 2005, 06:54 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,943 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 31 m 33 sec
Reputation Power: 2014
those numbers are most probably "bit-masks" - for example let's assume there
are 8 different permissions. we will work with string having 8 characters of 1 or 0,
where 1 means the user has permission in the specific location and 0 means user
does not have permission. for example, "00000000" means no permission at all, and
"11111111" means full permissions. now take this 8 character string and treat it
as binary number - convert it back to decimal and you get ordinary number that
represents the user's permissions. for example, John Doe has permission over page1
and page5. the binary number would be: "10001000" or in decimal, 136 - and that's
what you store in the database. quite hard to grasp, but once you do understand
the concept, it's kind of amazing what you can do with this.
Comments on this post
lewy agrees: Very interesting indeed Shadow
jmurrayhead agrees: +++++++ for helping me

Reply With Quote
  #3  
Old December 25th, 2005, 01:14 PM
jmurrayhead jmurrayhead is offline
Moderator
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 13,091 jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)  Folding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Week 11 h 27 m 23 sec
Reputation Power: 1580
Quote:
Originally Posted by Shadow Wizard
those numbers are most probably "bit-masks" - for example let's assume there
are 8 different permissions. we will work with string having 8 characters of 1 or 0,
where 1 means the user has permission in the specific location and 0 means user
does not have permission. for example, "00000000" means no permission at all, and
"11111111" means full permissions. now take this 8 character string and treat it
as binary number - convert it back to decimal and you get ordinary number that
represents the user's permissions. for example, John Doe has permission over page1
and page5. the binary number would be: "10001000" or in decimal, 136 - and that's
what you store in the database. quite hard to grasp, but once you do understand
the concept, it's kind of amazing what you can do with this.


That's awesome, thanks for that great explanation! I think I would like to try something like that out if I can figure out how to work it. Maybe I shall have to call on you again when I begin this, if you don't mind

Reply With Quote
  #4  
Old December 25th, 2005, 07:05 PM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,943 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 31 m 33 sec
Reputation Power: 2014
no problem, I'm at your service!
best approach would be to start slowly by trial and error.

Reply With Quote
  #5  
Old December 25th, 2005, 11:47 PM
jmurrayhead jmurrayhead is offline
Moderator
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 13,091 jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)  Folding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Week 11 h 27 m 23 sec
Reputation Power: 1580
Quote:
Originally Posted by Shadow Wizard
no problem, I'm at your service!
best approach would be to start slowly by trial and error.


Excellent, I appreciate it! Well, I'll give you some info about what I'm trying to do and we can go from there. Let's say I have 6 sections of my site I want to create groups for. One of these sections is for administrators only. The other 5 give the "moderators", if you will, the option to add a record, (users may edit and delete records they add), edit records, (users may edit records others have added), and/or delete records, (users may delete records others have added). I want to be able to add users to multiple groups. The other ways I was doing it made that difficult, because if a user was a member of two groups, sessions would be set for the first group, and then overwritted with the permissions of the last group. Of course there are ways around this, but I think the way VBulletin does it would be easier for me to manage. Okay, so I think the first step would be to get the database set up to do this. I am using MySQL. Any suggestions on how I should set up for this system to work?

Thanks again,

JMH

P.S. Feel free to move this to a more appropriate forum if need be. Perhaps users looking for similar solutions will not search the lounge for a particular problem like this

Reply With Quote
  #6  
Old December 26th, 2005, 06:49 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,943 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1Folding Points: 392772 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 31 m 33 sec
Reputation Power: 2014
as I mentioned before, have one single numeric field for the permissions.
now suppose user JMH is member of 3 groups: 1, 3 and 5. to build the
number that represent his permissions follow those steps:
1. build "bit mask" string: "10101" (1st, 3rd and 5th digits are 1)
2. use BinaryToInt() function (see below) to convert your bit mask string to integer
3. you will get 21 - store this as the permissions.
and the opposite direction, when you read the number from database follow
those steps to see if the member is part of specific group:
1. use IntToBinary() function (see below) to convert 21 back to "10101"
2. use such code for example to see if member is part of the 2nd group:
Code:
If Mid(strBinaryPermission, 2, 1)="1" Then
   'user is part of group 2!
End If

once you put it all in functions and add your own remarks I believe
you'll see its power and advantages.

and to save you some time, here are two helper functions:
ASP Code:
Original - ASP Code
  1. Function IntToBinary(ByVal num)
  2.     Dim result
  3.     IntToBinary="0"
  4.     If num<1 Then Exit Function
  5.     result=""
  6.     Do Until num<1
  7.         result=result&CStr(num Mod 2)
  8.         num = Fix(num/2)
  9.     Loop
  10.     IntToBinary=StrReverse(result)
  11. End Function
  12.  
  13. Function BinaryToInt(ByVal strBinary)
  14.     Dim result, x
  15.     BinaryToInt=0
  16.     If Len(strBinary)=0 Then Exit Function
  17.     Do Until Left(strBinary, 1)="1"
  18.         strBinary = Mid(strBinary, 2, Len(strBinary))
  19.         If Len(strBinary)=0 Then Exit Function   
  20.     Loop
  21.     result=0
  22.     For x=1 To Len(strBinary)
  23.         If Mid(strBinary, x, 1)="1" Then
  24.             result = result+(2^(Len(strBinary)-x))
  25.         End If
  26.     Next
  27.     BinaryToInt=result
  28. End Function


I won't move this yet as it's not really language-specific... the codes can be
converted easily to any language.

Last edited by Shadow Wizard : December 27th, 2005 at 04:42 AM.

Reply With Quote
  #7  
Old December 26th, 2005, 12:02 PM
jmurrayhead jmurrayhead is offline
Moderator
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 13,091 jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)  Folding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced FolderFolding Points: 88523 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Week 11 h 27 m 23 sec
Reputation Power: 1580
wow...maybe I should just stick to pc repair...lol Well, I am going to attempt to understand what the heck is going on in those functions. I understand that one is converting from binary to integer and another is converting from integer to binary. But the individual parts of the function I don't understand. I know what len does, but other's I've never seen before or never had to use. Perhaps you can enlighten me, I won't understand any of this unless I understand all of it, if you know what I mean.

First, copy: Copy(strBinaryPermission, 2, 1) What is going on here, I understand it's searching the string for a value.

Second, ByVal: IntToBinary(ByVal num) I have no clue what's going on here.

Third, Fix: num = Fix(num/2) All I know about fix is that it chops off the decimal point and integers to right of it.

Or if you just feel like giving me a rundown of what is happening in each line, that would be cool too I tried looking up some of these, but descriptions of what they do were vague.


Thanks for you help Shadow!

Reply With Quote
  #8  
Old December 26th, 2005, 05:20 PM
pws1970 pws1970 is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Aug 2005
Posts: 3,250 pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)pws1970 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 20017 Folding Title: Starter FolderFolding Points: 20017 Folding Title: Starter Folder
Time spent in forums: 4 Weeks 1 Day 4 h 5 m 50 sec
Reputation Power: 363
Wow. I guess what your trying to decipher from Shadow is security permissions and in awe of his execellent replication of binary control procedures you might try the security stucture layer.

This is an excellent concept that derives the persons level of admission dependant on the value entered,

E.G.


Full Permissions = 5
Administartor = 4
Top Level User = 3
Mid Level User = 2
Bpottom Level User = 1
Newbie = 0

When the user registars with your site they are given the specific security level to which they are credited. This number may be held in the username or even relational table as you decide. Hence the non-binary conformisist structure of allowing access into a site. From login you could access the table and determine access and control the viewing privileges of all users to your site.

Reply With Quote
  #9  
Old December 26th, 2005, 06:33 PM
jmurrayhead jmurrayhead is offline
Moderator
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 13,091 jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 9th Grade (Above 100000 Reputation Level)