index | search | no replies | posting guidelines | help | login | register |
Index » Products » ASP Report Wizard v2 |
| |||||||
Jul 30 2004, 4:09 AM |
| ||||||
scott69 from: UK | I have no idea where user names are added and groups assigned....I can't see it in the example documentation. Can anyone help? Thanks. | ||||||
Jul 30 2004, 7:38 AM |
| ||||||
ghost from: Washington, DC | Check out the following tutorials: ------------------------- Ghost | ||||||
Jul 30 2004, 7:50 AM |
| ||||||
scott69 from: UK | Thanks for the reply. If I understand correctly the names would be embedded in the Select Case statement and permissions assigned accordingly? What about passwords though? Thanks. | ||||||
Jul 30 2004, 8:10 AM |
| ||||||
ghost from: Washington, DC | You can download the sample applications and check out the example in the advanced folder, It shows how to basically control user roles. However, we did not include a users database because we wanted to leave it generic. If you check line 20 in the login.asp page, the function IsValidUser is basically where you would add a connection to your users database to valid the login. For example: Function IsValidUser(usr, pwd) Dim Conn, RS, SQL Set Conn = Server .CreateObject("ADODB.Connection" ) Conn.Open ( "DRIVER={Microsoft Access Driver " & _ " (*.mdb)};DBQ=C:\databases\users.mdb" ) SQL = "SELECT COUNT(UserName) FROM Users WHERE " & _ " UserName= '"& usr & "' AND Password= "' & pwd & "'" Set RS = Conn.Execute(SQL) If Not RS.EOF Then If CInt (RS(0 )) = 1 Then IsValidUser = True End If RS.Close End If Set RS = Nothing End Function You can even return the users role using this function ------------------------- Ghost | ||||||
Jul 30 2004, 8:43 AM |
| ||||||
whichman from: Laurel, MD | You can also choose to implement a simple XML database for you users usernames and passwords. Consider an xml file of the following format <users> <john role="admin">pass1</john> <jen role="user">pass2</jen> <joey role="usre">pass3</joey> </users> Note: These passwords normally have to be encrypted, we left it so for simplicity. Your is function will look something like this Function IsValidUser(usr, pwd) 'reset all variables IsValidUser = False Session( "UserRole" ) = "" 'On Error Resume Next Dim xmldoc, nodeList, node Set xmldoc = Server .CreateObject("Microsoft.XMLDOM" ) xmldoc.async = False 'xmldoc.load(Server.MapPath("users.xml")) xmldoc.load( "D:\secure\users.xml" ) If xmldoc.parseError.ErrorCode=0 Then Set nodeList = xmldoc.documentElement.getElementsByTagName(usr) If nodeList.length>0 Then If nodeList.Item(0 ).Text = pwd Then IsValidUser = True On Error Resume Next Session( "UserRole" ) = nodeList.Item(0 ).attributes.getNamedItem("role" ).nodeValue If Err .number<>0 Then Session( "UserRole" ) = "GUEST" End If End If End If End If Set xmldoc = Nothing End Function ------------------------- Master of the Game | ||||||
Aug 5 2004, 1:01 PM |
| ||||||
scott69 from: UK | That's great thanks. It's working really well now as a result of this. Many thanks!! | ||||||
Aug 5 2004, 1:02 PM |
| ||||||
scott69 from: UK | Thanks for that! I just used this on a different project and it's working great! Thanks again. | ||||||
Aug 5 2004, 1:49 PM |
| ||||||
whichman from: Laurel, MD | U aRe Welcome! ------------------------- Master of the Game | ||||||
Pages: (1) [1] |