Print Page | Close Window

Existing user database integration + segregation

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=21637
Printed Date: 08 April 2026 at 8:09pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Existing user database integration + segregation
Posted By: gariputro
Subject: Existing user database integration + segregation
Date Posted: 17 October 2006 at 4:22pm
I know it sounds confusing, so let me explain.  I have a site that contains an existing SQL user database.  I already know how, and have performed, the function of using my existing user database as the forum members database:
http://forums.webwiz.net/forum_posts.asp?TID=19621&KW=integrate+user+database - http://forums.webwiz.net/forum_posts.asp?TID=19621&KW=integrate+user+database
 
Now that I have the forum setup and users are able to access it without logging in, I need the ability to control what the users see based on their rights within the website (see example):
 
User A logs into the website, visits the forum, and is only allowed to see section A of the forum
User B logs into the website, visits the forum, and is only allowed to see section B of the forum
 
I have the forum set up with group permissions and I have User A separate from User B in the SQL database based on a field where I store an access rights number (eg A=1, B=2, Admin=9, etc), so how do I pass that information to the forum and automatically assign them to a group when they visit, thereby restricting what they can view within the forum?



Replies:
Posted By: WebWiz-Bruce
Date Posted: 17 October 2006 at 4:39pm
The simplest way would be for you to edit the file functions_member_API.asp

At line 222 you will find the following line:-

intForumStartingGroup = CInt(rsCommon("Group_ID"))

This line gets the Gorup_ID number of the strating group to place the user in.

What you would need to do is change this so based on your login system if it is user A they are given the group ID of the group you want them to be in and another for group B users:-

If UserA Then
    intForumStartingGroup = 3
ElseIf UserB Then
    intForumStartingGroup = 4
End If

You can get the Group_ID number by looking in ten tblGroup table in the database and get the ID numbers for the groups you want to use.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: gariputro
Date Posted: 17 October 2006 at 4:55pm
That is just the type of answer I was looking for!  I was hoping that someone would point me to a spot in the scripts where the group is assigned/checked.  I will give this a try.  Thanks boRg!


Posted By: gariputro
Date Posted: 18 October 2006 at 4:51pm
And now onto my question #2...
 
How can I update this the GroupID on the fly, so that when I change a user designation within my own login system, the next time that user logs in their GroupID is changed?
 
Your previous example works perfectly for users visiting the forum for the very first time.  Once I got that up and running, I copied and inserted the code to around line 172 in functions_members_API.asp and then inserted: 
 
rsCommon.Fields("Group_ID") = intForumStartingGroup
 
at line 182 (just before the rsCommon.Update) hoping that the user designation would be read from Session, converted to a GroupID number and rewritten to the database, just as a changed password would.  Doing this however, gives me an error message:
 
Server Error in Forum Application
An error has occured while writing to the database.
Please contact the forum administrator.

Support Error Code:- err_SQLServer_existingMemberAPI()_update_pass
File Name:- functions_member_API.asp

Error details:-
ADODB.Recordset
Item cannot be found in the collection corresponding to the requested name or ordinal.
 
Did I miss something?


Posted By: WebWiz-Bruce
Date Posted: 18 October 2006 at 5:11pm
It looks like a simple change may not do it and the API file may need to be re-written to accommodate the customisations you require. If you are unsure about ASP programming you may need to ask a developer about this.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: gariputro
Date Posted: 18 October 2006 at 5:25pm
Well, I by no means am an ASP programmer.  PHP, that's another story.
 
In looking at the code, I realize it wouldn't be a quick fix, but wouldn't it still be rather easy?  I would need to modify the SQL statement to also pull 'strDbTable & "Permissions.Group_ID"' from the Permissions table (this is all on a shared server which I have limited access to, so if I get a tbl name wrong, don't burn me), then read it as an rsCommon and overwrite it.  Have I oversimplified it?


Posted By: WebWiz-Bruce
Date Posted: 18 October 2006 at 5:30pm
Without going all through the code it looks like you might have found a solution yourself.

If you download the Access version and open the database you will get all the table names and field names so you shouldn't get them wrong.

All the table names and field names are the same no matter which database you are using.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: gariputro
Date Posted: 18 October 2006 at 6:33pm
Found a solution, no.  Have a theory, yes!
 
I'll post back if I can figure out how to make this work.  I'm sure someone else can benefit from my sweat. Smile


Posted By: gariputro
Date Posted: 19 October 2006 at 7:59pm

Well, I'm happy to say that after messing around with the code for the past 12 hours or so (my eyes hurt) I have a workable solution.  Is it the best possible solution?  Well, probably not, but I'm open to some guru taking my example, cleaning it up and writing it in as a feature in the future (attn: boRg Smile).  I resorted to using an SQL insert statement to change the database because I was having troubles with writing using rsCommon.

All modifications were done to functions_members_API.asp.  Line markers are estimates and may be off by a few.

Line 90 (insert):
Dim strGroup
Dim oldGroupID
 
Line 98 (insert):
'Get the current user group ID passed in your session; rename Group to whatever you called your session variable
strGroup = Session("Group")
 
Line 109 (replace):
strSQL = "SELECT " & strDbTable & "Author.Password, " & strDbTable & "Author.Salt, " & strDbTable & "Author.Username, " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.User_code, " & strDbTable & "Author.Active, " & strDbTable & "Author.Login_attempt, " & strDbTable & "Author.Group_ID " & _
 
Line 139 (insert):
oldGroupID = rsCommon("Group_ID")
 
Line 194 (insert):
'If the Session Group_ID does not match that on record we need to overwrite it in the db
If NOT strGroup = oldGroupID Then 
  
  'Set the forum group ID number for an Existing Member
  'Check tblPermissions for values used below
  '1 = Adminsitrator (reserved for Admin only)
  '2 = Guest (default)
  '3 = Moderator (all User Admins)
  '4 = Newbie
  '5 = Operator
  '6 = Power User
 
  If strGroup = 1 or strGroup = 2 Then
    intForumStartingGroup = 5
  ElseIf strGroup = 3 Then
    intForumStartingGroup = 6
  ElseIf strGroup = 4 Then
    intForumStartingGroup = 3
  ElseIf strGroup = 9 Then
    intForumStartingGroup = 1
  Else
    intForumStartingGroup = 2
  End If
   
  'Setup SQL statement to update tblAUthor db with new Group_ID
  strSQL2 = "UPDATE " & strDbTable & "Author " & strRowLock & _
  " SET Group_ID=" & intForumStartingGroup & _
  " WHERE Author_ID =" & lngUserID & ";" 
   
  'Set error trapping
  On Error Resume Next
   
  'Write SQL query to the db
  adoCon.Execute(strSQL2)
   
  'If an error has occured write an error to the page
  If Err.Number <> 0 Then Call errorMsg("An error has occured while writing to the database.", "existingMemberAPI()_update_pass", "functions_member_API.asp")
      
  'Disable error trapping
  On Error goto 0
  
End If
 
*EDIT* Oops, I lied.  I made one addition to database_connections.asp for the SQL statement I ran.
Line 73 (insert):
Dim strSQL2


Posted By: WebWiz-Bruce
Date Posted: 20 October 2006 at 9:35am
Looks good Clap

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net