Author |
Topic |
speirsp
Starting Member
3 Posts |
Posted - 06 December 2005 : 08:49:24
|
All,
I need to find out which cookies, session variables I need to set in order to log into snitz forums without using the snitz login form. I have authentication already and an existing user database and wish to use that. i understand I will probably have two user databases, but the existing will simply update the snitz one. Just need to know what to set.
Regards,
Paul
|
|
Roger Fredriksson
Average Member
Sweden
556 Posts |
Posted - 06 December 2005 : 10:02:05
|
This is how I did it after Snitzers(Shaggy?) helped me (a lot) and it works! <% 'The table USERS is in my old non-Snitz db in wich the members-info is taken from my old registration form and stored. 'I have made a session-variable holding the ID for the current visitor. First step is to get all input-values for 'the current user for transfer her/his info to Snitz db. My connection is now to old-db. cUsId=Session("UsId") oSql = "SELECT * FROM USERS WHERE IDnr =" & cUsId Set objrs = cnObj.execute(oSql) cUserID = objrs.Fields("IDnr") cEpost=objrs.Fields("Email") user = objrs.Fields("username") pass = objrs.Fields("password") ' Fornamn=first name; Efternamn=last name cFornamn=objrs.Fields("Fornamn") cEfternamn=objrs.Fields("Efternamn") ors.Close set ors = Nothing
<% 'Connect to Snitz-db by using strConnString strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../xxxxx/xxxxx.mdb") '## MS Access 2000 using virtual path 'Now i include the sha-function (first line below) and the ADO Type Library (second line below) %>
<!--#INCLUDE FILE="inc_sha256.asp"--> <!--#INCLUDE FILE="golib.asp"-->
<% Dim objRS, intIDForNewRecord
If Len(Session("Snitz"))=0 then Set objRS = Server.CreateObject ("ADODB.Recordset") objRS.Open "Forum_Members", strConnString , adOpenStatic, adLockOptimistic, adCmdTable
objRS.MoveLast 'intIDForNewRecord = objRS("Member_ID") + 1
objRS.AddNew ' add a new record objRS("M_EMAIL")=cEpost objRS("M_NAME") = user objRS("M_COUNTRY")="ADV" objRS("M_FIRSTNAME")= cFornamn objRS("M_LASTNAME")= cEfternamn strEncodedPassword = sha256("" & trim(pass)) objRS("M_Password") = strEncodedPassword objRS.Update
objRS.Close Set objRS = Nothing call doCookies(pass) Session("Snitz")="OK"
end if %>
<% 'login, hm? the lines below are only for use in my old application Session("USERID")=user Session("NAME")=cFornamn Session("UsID")=cUserID Session("Password")=pass Session("Epost")=cEpost cUsID=cUserID
' this is Snitz-code used by call doCookies above sub doCookies(fSavePassWord) if strSetCookieToForum = 1 then Response.Cookies(strUniqueID & "User").Path = strCookieURL else Response.Cookies(strUniqueID & "User").Path = "/" end if Response.Cookies(strUniqueID & "User")("Name") = user Response.Cookies(strUniqueID & "User")("Pword") = strEncodedPassword Response.Cookies(strUniqueID & "User").Expires = dateAdd("d", intCookieDuration, strForumTimeAdjust) end sub |
rf/www.avgifter.com |
Edited by - Roger Fredriksson on 25 February 2006 05:34:45 |
|
|
speirsp
Starting Member
3 Posts |
Posted - 08 December 2005 : 06:28:15
|
Hi Roger,
Thanks for the info. I did get it working at work, but at home where the live system is, I can't get the thing to run. I'm just looking at the login section. I set the cookie, the session variable but It doesn't seem to work. I'll look further when I'm not so tired. I note that the system can be configured to not use cookies. How would the login be achieved in this case? Do you know what the session variable are that need to be set.
Regards,
Paul
|
|
|
Roger Fredriksson
Average Member
Sweden
556 Posts |
Posted - 08 December 2005 : 08:38:15
|
Sorry,I cannot help you more than sharing the code above. Please step in, Snitzer! |
rf/www.avgifter.com |
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
speirsp
Starting Member
3 Posts |
Posted - 11 December 2005 : 22:09:46
|
Probably not if that is the consequence. I think I have it worked out, thanks to all who helped.
Paul |
|
|
AnonJr
Moderator
United States
5768 Posts |
Posted - 12 December 2005 : 01:11:34
|
Just for reference (and any other poor soul searching for this in the future) how did you work it out? |
|
|
Nisse
Starting Member
Sweden
10 Posts |
Posted - 17 February 2006 : 09:14:04
|
If I implement this code on my site will it login my user on the forum as well? |
|
|
Nisse
Starting Member
Sweden
10 Posts |
Posted - 17 February 2006 : 09:18:20
|
forgot one thing. How do you solve the problem with new users registering. Is there someone who got code for putting a new user in the FORUM_members table?
|
|
|
durell
Starting Member
USA
14 Posts |
Posted - 24 February 2006 : 20:19:34
|
Roger: Looked at your code (I need to integrate current db) and it appears pretty straight forward....but I fall short when it comes to what your field names hold (or mean).
I really need to implement this .....so if you don't mind ....give me some definition of the fields and what they hold.
thanks |
|
|
Roger Fredriksson
Average Member
Sweden
556 Posts |
Posted - 25 February 2006 : 05:46:32
|
durell, I have edited my post above trying to explain the code. I am a copyin and pasting guy with only very rudimentary ASP-knowledge but I will try to explain better if you still have q about my post.
Nisse, yes the code will login your visitor in Snitz-forum. The code also shows you how the info is transferred to Forum_members table.
speirsp, tell us if the code worked for you or share the code you used for getting it to work.
Snitzers, show no mercy - although the code works for me, tell us about shortcommings in the code.
|
rf/www.avgifter.com |
|
|
Nisse
Starting Member
Sweden
10 Posts |
Posted - 17 March 2006 : 12:21:36
|
The questions is what do we do to make the forum recognize that a specified user is logged on to the site. I've managed to create a user i the snitz database, thats no problemen. But what do I do to set the visitors login. So that he don't need to login twice.
What are the session-variables or do I set some cookies?. |
|
|
Roger Fredriksson
Average Member
Sweden
556 Posts |
Posted - 17 March 2006 : 16:53:39
|
The answer is in the code above in my post. I have also emailed the set of files I am using to you. |
rf/www.avgifter.com |
|
|
devo
Starting Member
1 Posts |
Posted - 29 March 2006 : 16:43:27
|
Hello all,
What variables are included in golib.asp? I'm trying to have the user log into my site using existing security, and have them simultaneously logged into snitz. I used the above code (and added a check to see if they are already in the forum db), and all data transfers, but they are not logged via the cookies. I did not use golib.asp, as I don't have it and don't know which variables to set up in the sub above. :)
Any help would be appreciated, Thanks.
|
|
|
Roger Fredriksson
Average Member
Sweden
556 Posts |
Posted - 30 March 2006 : 04:49:33
|
From the top of my head (I am not at my office until tomorrow) the file golib is not necessary for the code to work. It is a file only for my specific app. I think your issue has something to do with the cookies-code but I am not the one to figure it out so please step in Snitzer. (Shaggy helped me to get it to work ) |
rf/www.avgifter.com |
|
|
Roger Fredriksson
Average Member
Sweden
556 Posts |
Posted - 31 March 2006 : 03:09:51
|
The file golib.asp is only for including the ADO type library and has nothing to do with the sub. In the beginning of my page using the code I have <!--#INCLUDE FILE="config.asp"--> <!--#INCLUDE FILE="inc_header.asp" --> I think that inc_header or inc_header_short i nessecary for the sub to work. Snitzers, am I right?
|
rf/www.avgifter.com |
|
|
Topic |
|