Link to home
Start Free TrialLog in
Avatar of jsm11482
jsm11482

asked on

User authentication over winsock....

Hi, I am developing a program which will require users to enter a userID and password in order to sign in to the service.  I have created a web interface using ASP and an Access Database which verifies users perfectly.  What I need to know is how to tie these two together, that is, have the user enter their userID and password in the program, than have the program send that info to the ASP sign in page or the Access database, and then receive a response.  I also want to be able to have users sign up from the application.  If this is unclear, please let me knwo what part is unclear so i can help you help me!
Thank you all very much for your time!
-Josh
Avatar of PaulHews
PaulHews
Flag of Canada image

You have an existing web interface that does authentication?  If you are using basic authentication on te web server, you can insert username:password into the URL like so:

http://username:password@www.yoursite.com/
Avatar of jsm11482
jsm11482

ASKER

Paul: How would I go about launching the URL and getting a return value that will tell me whether or not the user is authorized? and also, how would i add a user to the database?
Thanks, Josh
Never done http with winsock, although there are lots of articles on it at www.vbip.com .  I usually use the Inet control or a third party http control.  From the client side, it still depends how the server authentication works.  What does your ASP ppage look like?
Paul: Lets try this from a different angle.  Lets say I want to connect DIRECTLY to the database instead of using the web interface i created.  I want to verify a userID/password, i want to add a record (a new user) and in order to add a record, i have to make sure that the chosen userID does not already exist.  I am not a Database buff so if you could give me a nice slow walk through or some sample code or something, that would be great!
Thanks again!
-Josh
Implement a ActiveX DLL which takes the username and password.

You will have this information from your ASP page already.

Then in your ASP

Dim objLogin
Dim Result
Set objLogin = CreateObject(LoginObject)

Result = objLogin.Login(UserId,Password)

If Result = etc...

In VB start a new ActiveX DLL project.

Add a reference to Microsoft ADO 2.x

Your class will only have one method Login

Public Function Login(UserID as String, Password as String ) as Boolean

On Error goto errHandler:
   Dim conn as new ADODB.Connection
   conn.Provider = "Microsoft.Jet.OLEDB.4.0"
   conn.Open "data source=" & "c:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb;,User Id=" & UserID &";Password=" & Password

   if conn.State = adStateOpen then
        Login = True
   else
        Login = False
   endif
   
   Exit Function

errHandler:

    'You could try and pass back the error to ASP
    'As a minimum though
    Login = False

End Function

Compile the DLL

You now have a simple login to your database from ASP.
Of course you could do this through ASP also.

Hope this helps

Vin.

 
 


 

Vincent: I am confused as to where to implement the first part of your code (the ASP part).  Also, I do not know how to add a reference to the ADODB component.  Also, I am not sure if the method 'conn.Open' will be able to connect to remote database...but then again, you probably know better ;-).  Please walk me through the connection steps so I can understand what I am doing.
Thank you very much!!
-Josh
Ok here we go

In your ASP code

Add a new ASP file

Call it say GetLogin.asp

In your globals section of your GetLogin.asp

Dim objLogin

Then add a Function

Function LoginToDatabase(UserID, Password)

    'The object you create here will be your login DLL
    'The name will be ProjectName.ClassName    
    Set objLogin = Server.CreateObject(LoginObject.Login)

    if IsEmpty(objLogin)
        LoginToDatabase = False
    end if

    LoginToDatabase = objLogin.Login(UserID, Password)

End Function


In your ASP code for logging in I'm assuming this has been written.

Add the following code

'
' Security
'
%>
<!-- #include file="GetLogin.asp"--!>
%>

At the point in your code you want to login to the system

     'You get the UserID and Password from your Page
     'Textboxes
     'Can't do this for you
     
     If Not LoginToDatabase(UserID,Password) then
        'Exit gracefully
     endif
     'Continue

Hope that helps I don't have time to write the ASP for you

If you need to find out more check out the following link

http://msdn.microsoft.com/scripting/

Vin.
Any progress here?

Any progress ?

V.
ok...now all i need is to be able to open a connection to a database on the internet FROM visual basic, then verify the username and password over that connection....i am all set with the asp pages...
thanks
-josh
Are you still available to help?
-Josh
Yup

Vin
Vincent: ok, take MSN Messenger for example.  When you sign on, MSN runs and checks your userid and password
against a database on the internet.  That is what I want to do.  Create a form in VISUAL BASIC with
fields UserID and Password, and when the user clicks "Sign In," run and check the userid and password
against the database on the internet.  That is it! Hope that helps!!
Thank you TONS!
-Josh
Don't quite undestand where you are going with this.

Are you trying to connect to a database on a webserver ?

I thought the database was a local access database.

Vin.
no its on a webserver...thanks
-josh
And your ASP sits on the webserver too yes ?

All you need to do is call your ActiveX DLL from the ASP page as I described.

When the user presses the Login button
Call the login function from your ASP code passing the values from the text boxes.

Vin.


i dont understand how to do that though...sorry!
-Josh
Avatar of DanRollins
Hi jsm11482,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.
    *** The Question "how to connect to remote database over the Intenet" was not answered.  Some PAQ value, though.

jsm11482, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
Dan > its ok to close the question.  Thanks!
-Josh
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial