This topic is locked
[SOLVED]

 Login Table using a different database

5/10/2010 04:26:57
ASPRunnerPro General questions
M
manan author

Hi,
I'm currently using ASPRunnerPro ver 6.2. I maintain several applications and would like to use a common login database with usernames and passwords, so that users can have a common login for all the applications. I am able to do it in ver 6.0 by manually modifying the login.asp file and specifying the database connection string. But in ver 6.2, I am lost as the login.asp scripts look very different.
Is there a better other way other than manually modifying the login.asp file? Can we do it at the Event tab (Login Page: before Process)? If YES, can you show me an example, please. The login database name is staff.mdb and the table name is login (contains id and pwd columns).
Please help.
Thank you.

Sergey Kornilov admin 5/10/2010

Unless I'm missing something there is no need to modify login.asp file you point it to the same login table.
Probably you need to clarify a little bit why you need to modify login.asp manually.

M
manan author 5/10/2010



Unless I'm missing something there is no need to modify login.asp file you point it to the same login table.
Probably you need to clarify a little bit why you need to modify login.asp manually.


Hi Sergey,
Please allow me to explain. For example, I have 3 separate applications: Staff Particulars, Book Loan and Vehicle Booking System. Now I want to have a central login database which is in the Staff Particulars database (staff.mdb). I do not want to combine the 3 applications using the same database source. The structure of the databases is as follows:

  1. c:\inetpub\wwwroot\staff\db\staff.mdb
  2. c:\inetpub\wwwroot\book\db\book.mdb
  3. c:\inetpub\wwwroot\vehicle\db\vbs.mdb
    When my staff runs application number 2 or 3, the system will look for the login table which is only found in application number 1. In the previous versions, I manually modified the file "login.asp" in applications 2 and 3, and included/modified the lines in blue:
    "...

    dim xt

    set xt = new XTempl
    db_connect[color="#0000FF"]2()

    DoEvent "BeforeProcessLogin dbConnection"

    ..."
    I also modified the "dbcommon.asp" file and included this function:
    "...

    function db_connect[color="#0000FF"]2()

    set dbConnection = server.CreateObject("ADODB.Connection")

    dbConnection.ConnectionString = strConnection

    dbConnection.Open

    end function

    ..."
    Lastly, I modified the "dbconnection.asp" file and included the line in blue:
    "...

    strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\book.mdb") & ";User Id=admin;Password="

    [color="#0000FF"]strConnection2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("..\staff\db\staff.mdb") & ";User Id=admin;Password="

    ..."
    The above 3 steps worked perfectly. Applications no 2 and 3 will check the login table found in application 1, whenever the staff logs in. But now in ver 6.2, the scripts in login.asp file is very much different and complex for a non-ASP programmer like me to comprehend or edit.
    I would like to know if there a better other way other than manually modifying the login.asp file and the other 2 files as mentioned above. Can we do it at the Event tab (Login Page: before Process)? If YES, can you show me an example, please? The login database name is staff.mdb and the table name is login (contains id and pwd columns).
    Please help.
    Thank you.

Sergey Kornilov admin 5/11/2010

I see what you saying. Here is how you can make it work using events.
In applications 2 and 3 you can use AfterAppInit global event and the following code:

strPage= Request.ServerVariables("SCRIPT_NAME")

strPage= Right(strPage,Len(strPage) - InStrRev(strPage,"/"))

if strPage="login.asp" then

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("..\cstaff\db\cstaff.mdb") & ";User Id=admin;Password="

end if


This is it.

M
manan author 5/11/2010



I see what you saying. Here is how you can make it work using events.
In applications 2 and 3 you can use AfterAppInit global event and the following code:

strPage= Request.ServerVariables("SCRIPT_NAME")

strPage= Right(strPage,Len(strPage) - InStrRev(strPage,"/"))

if strPage="login.asp" then

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("..\cstaff\db\cstaff.mdb") & ";User Id=admin;Password="

end if


This is it.


Hi Sergey,
Thank you very much for the prompt reply and easy solution. It works perfectly! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=49705&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
I should have asked this question long ago time ago and avoided the hassles of manually modifying the files after generating them from ASPRunnerPro. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=49705&image=2&table=forumreplies' class='bbc_emoticon' alt=':P' />
I believe this solution may be relevant to many customers out there. Best Regards.