Posts Tagged ‘system’

Simple ASP Authentication System


2010
02.16


This article describes how you can secure ASP applications using simple, but quite effective authentication schemes. This article uses a very simple way to achieve this. Just follow the steps and you have a secure login system.

Step 1: Create a table of users

Just create a simple table of user logins and passwords. I have included a database userinfo.mdb with this example, which contains a sample table tUsers. tUsers has two fields – Username and UserPassword. Username is the primary key.

Download and copy this database on your hard disk.
Step 2: Set the default authentication status

This you do in the gobal.asa file. All you have to do is, set a session variable to a default “not authenticated” status.

Why? Because, when a users first come into the application, they are not valid until you have checked their “credentials.” The default status makes sure that everyone has to go through the front door.

In global.asa file, within the Session_OnStart event, write this code

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
SUB Session_OnStart
‘ This is the default authentication status
Session(“Authenticated”) = 0
END SUB
</SCRIPT>

The authentication status is the most important thing to keep in mind, so don’t forget this.

Step 3: Create a login page

This is an ASP page, with just HTML in it. Call it say login.asp. For your convenience, here is the sample code:

<HTML>
<BODY BGCOLOR=FFFFFF>
<FORM ACTION=”verify.asp” METHOD=POST>
Name:
<INPUT SIZE=20>

Password:
<INPUT SIZE=20>
<INPUT VALUE=”Login Now”>
</BODY>
</HTML>

It contains a form with 2 INPUT elements. These elements are used to collect the user name and password of the user. This information we POST to verify.asp where we verify if the user is valid or not.

Step 4: Create the system DSN for the database

In order to access the userinfo.mdb, we need to create a system DSN in ODBC. If you are familiar with ASP, you can choose your own DSN scheme. To create a system DSN, do the following:

  • Open the Control panel of your machine (in Start ..Settings menu in Windows 95/NT)
  • Click on “ODBC”
  • Click on “System DSN” tab
  • Click “Add”. Choose the “Microsoft Access Database Driver”, and click “Finish”
  • Give the DSN a name, say “LoginDSN” In “Database” settings, click “Select” and point to the userinfo.mdb on your hard disk.
  • Click OK

This sets up a system DSN named “LoginDSN” on your machine. This will point to the userinfo.mdb on the hard disk.

Step 5: Create an authentication page

This is the verify.asp page we saw in step 3. In this page, we check for valid users. We get the user information from the login.asp (remember the form elements?)

Our intent is

    • Check for valid users and set the authentication status accordingly
    • If the user is valid, the authentication status is 1
    • If the user is invalid, the authentication status is 0

The code for verify.asp is as shown below. You can modify it accordingly.

<%
‘ Create a command object. This object serves to run our queries
Set Cm = Server.CreateObject(“ADODB.Command”)

‘ Specify the system DSN path
Cm.ActiveConnection = “LoginDSN”

‘ Now it’s time for the query. We need to check the user information
‘ against the table tUsers
Cm.CommandText = “SELECT * FROM tUsers WHERE ” & _
“UserName=’” & Request.Form(“UserName”) & “‘ AND ” & _
“UserPassword=’” & Request.Form(“UserPassword”) & “‘ ”

‘ Set the query type. 1 means it is a SQL statement
Cm.CommandType = 1

‘ Retrieve the results in a recordset object
Set Rs = Cm.Execute

‘ We now check if the user is valid. If user is valid, the recordset MUST
‘ haverecord. Otherwise it is empty. If user exists, we set authentication
‘ status to 1 and send the user to appropriate page, say welcome.asp.
‘ Else send the user back to login.asp
If Rs.EOF Then
Session(“Authenticated”) = 0
Response.Redirect (“login.asp”)
Else
Session(“Authenticated”) = 1
Response.Redirect (“welcome.asp”)
End If
%>

Step 6: Check the authentication status

This is the important piece of our system. We must check the authentication status on EACH ASP PAGE that we want to be secured. This is simple to do. Just check if the authentication status is 1, if not send the user back to login.asp. The sample code is

<%
If Session(“Authenticated”) = 0 Then
Response.Redirect (“Login.asp”)
End If
%>

Alternatively, you can copy this code into a file, say check.inc, and include the following code on top of your files instead.

<!– #include file=”check.inc” –>

As I mentioned before, this code needs to go on TOP of each page that you want to protect.

The above 6 steps help you to create a simple authentication system. Remember that this system protects ONE virtual directory and not the whole web site. You need to create one for each virtual path you want to secure.

Also, the above system is targeted towards new users. The database and the code is kept simple so you can learn from it. The entire system can be downloaded from this site. The zipped file contains the database and all the files.

About the Author

Syed Yasir Hashmi http://www.yasir.in is an I.T guru working in the industry for the last 12 years

Popularity: 13% [?]

  • Share/Bookmark

How the Google Nexus One Stacks Up


2010
01.07

How the Google Nexus One Stacks Up

01.07.10

Google Nexus One

Does the so-called “Google Phone” measure up against the iPhone, Droid, and other leading smartphones?

tuesday’s announcement of the Google Nexus One smartphone wasn’t a shocker, but the phone itself has some great new features and is in a good position to become the top Android device just months after the Motorola Droid took over that spot. The Nexus One’s specs are appealing, with a 1 GHz Snapdragon processor, an amazing screen that is similar to the Droid’s, and a 5-megapixel camera with LED flash. Google’s Nexus One is also the first device to run Android 2.1 software, which adds features like new home screen panels and interactive wallpaper.

So how does the Nexus One measure up to the other big-name smartphones out there? We’ll compare the Nexus One to the Motorola Droid, Apple iPhone 3GS, Motorola CLIQ, and the Palm Pre, four of the highest-rated and most-buzzed about smartphones of the last year. We’ll show how the Nexus One’s specs compare in terms of network, OS, display, processor, and camera. Of course, final judgments will have to wait until we’ve had a chance to test the unit. Network
The Nexus One can be purchased on contract from T-Mobile immediately and will be available for Verizon Wireless in the spring. This is the first time such a heavyweight smartphone has been offered on two simultaneous U.S. networks so quickly, and it’s a peculiar (and welcome) example of choice for the consumer. The Nexus One can also be purchased unlocked, and you can use a T-Mobile or AT&T SIM card to get service. (Keep in mind, however, that because of supported frequency bands, unlocked Nexus Ones will be compatible with T-Mobile’s 3G network, but not AT&T’s.) While T-Mobile had its share of publicity problems in 2009, the service is known for good pricing and customer service. T-Mobile is going to be the first with HSPA+ data, so CLIQ and Nexus One owners who can get 3G service from the carrier should be able to enjoy noticeably faster data speeds before other carriers.

By comparison, the iPhone’s biggest problem is arguably that it’s only on AT&T, which has a reputation for dropped calls and unreliable service. The Pre is on Sprint, which continues to be a fairly reliable option for 3G service and coverage. The Droid has the advantage of being tied exclusively to Verizon—a feather in its cap because of Verizon’s trustworthy service. When it comes to the network, Google’s Nexus One trails the Droid at the moment, but when it adds Verizon in the spring, the Nexus One looks set to have the most attractive options.

Operating System
The Nexus One has a real edge when it comes to the OS. Android 2.1 is, not surprisingly, better than the Motorola Droid’s Android 2.0. And it’s light years ahead of the Motorola CLIQ’s Android 1.5, which feels dated even with its MotoBlur extras.

As for whether Android 2.1 is better than the iPhone’s 3.1 OS, that’s a matter of personal preference. Each has its own feel—Android more customizable, iPhone more streamlined. Two of the biggest differences are that Android can run several third-party apps simultaneously—not the iPhone. Android also allows for more customization of home screens than the iPhone. On the other side, the latest iPhone OS has an onboard video editor and a simpler-to-use interface.

Palm’s webOS is another beast altogether. Its innovative and fun interface features “cards”, where each program is a card you can pull out, cycle through, and discard as needed. Plus, you can run multiple apps simultaneously. Sadly, Palm’s Pre isn’t powerful enough to fully realize webOS without bits of sluggishness, especially with multiple apps running.

Display
The Nexus One has a 3.7-inch, 480-by-800-pixel AMOLED display. The Droid has a similar 3.7-inch 480-by-854-pixel touch screen, but it won’t be quite as vibrant because it’s not AMOLED. We absolutely love the Droid’s screen, so we’ll give the Nexus One equal billing because they are comparable. The iPhone’s bright 3.5-inch, 320-by-480-pixel screen is good, but not Droid or Nexus One good. The CLIQ and Pre’s 3.1-inch, 320-by-480-pixel touch screens are just a little too small for comfort, especially when compared to their smartphone competitors. The Nexus One ties the Droid when it comes to screen specs, until we have to time test the units side-by-side.

Processor
Being Google must have some serious perks. The Nexus One is only the second smartphone, after the HTC HD2, to be equipped with the powerful 1 GHz Snapdragon processor, the fastest processor yet to run on a phone. Most analysts have noted that the processor makes a big difference and makes Android run very smoothly. The Droid runs well too, but its ARM Cortex-A8 is now a generation behind. The iPhone and Pre both run ARM Cortex-A8 processors as well, so count them slightly behind the curve now too. And the CLIQ’s 528 MHz Qualcomm MSM7201A processor, which is responsible for its occasional sluggishness, is now two generations behind. The Nexus One is the clear winner when it comes to processor specs.

Camera
The Nexus One features a 5-megapixel camera with a LED flash and can capture video at 720-by-480 pixels at a minimum of 20 frames per second. The Droid has a 5-megapixel camera with flash and can take videos at the same resolution with 25 frames per second. The iPhone’s 3-megapixel camera doesn’t quite compare, but videos on the iPhone are 640 by 480 pixels and 30 frames per second, which are probably in the same class as the Nexus One and Droid. And the Pre’s 3-megapixel camera works fine, but lacks in options and doesn’t record video. The Droid has a slight edge in terms of camera specs—actual performance is another matter, of course. Stay tuned for our tests.

Smartphones in this Roundup:

Apple iPhone 3G S (AT&T) : Angle Apple iPhone 3GS (AT&T)

$199 – $299
While we haven’t reviewed the Nexus One yet, we’re fairly confident the iPhone 3GS will continue to stay at the top of the smartphone heap because of its multitude of apps, excellent design, great browser, iTunes compatibility, and sheer ease of use.

Droid by Motorola (Verizon Wireless) : Keyboard Droid by Motorola (Verizon)

$199.99
The Droid still represents the future of Verizon Wireless. It’s got a beautiful screen, an OK physical keyboard, good battery life, and an excellent Web browser. But it looks like it will have to share the spotlight with the Nexus One in the coming months.

Motorola Cliq Motorola CLIQ (T-Mobile)

$199.99
Now that Nexus One has popped up, we imagine the CLIQ will lose its luster. But that doesn’t mean this Android 1.5 device isn’t still functionally appealing. It has ground-breaking social networking integration, an excellent physical keyboard, and the cloud-based MotoBlur that backs up data—all of which add value. But its slow processor and smaller screen will keep it squarely in a class behind.

Palm Pre (Sprint) : Angle Palm Pre (Sprint)

$149.99
The Pre, last January’s hot ticket, is starting to look slightly aged. It’s still a great phone with an innovative OS, but the device hasn’t kept up with competitors in terms of app development and new additions. The only thing keeping the Pre in headlines in 2009 was its war with Apple over iTunes syncing, which while novel, isn’t the sort of thing that will really impress the techies out there.

Popularity: 49% [?]

  • Share/Bookmark
Get Adobe Flash playerPlugin by wpburn.com wordpress themes