SQL Web Authentication

Given that NTCR is only good in a network environment, how can I redirect a user back to a login page (or trap something) if I pass their username and password into a OLE DB connection string and use SQL authentication? When a user is not in the SQL user list the error is: Microsoft OLE DB Provider for SQL Server (0x80040E4D). Login failed for user ‘weblogin’. Apart from installing additional software on the server is there a elegant way to handle this and take the user to a nicer place?

One simple technique is to set “On Error Resume next” prior to making the database hit. Then check the value of the Err object when you return. If it is not zero, you know an error took place and can proceed to a nicer rejection page.

On Error Resume NextobjConn.Open "dsn", "userid", "password"If Err <> 0 Then   display neat error messageend if

Encapsulate the above in its own function so that the On Error statement does not affect your other code.

Obviously, this is a simple solution for your immediate problem. Perhaps you can rethink your design so that user names and passwords of users to your site are stored in a table against which you validate using a common SQL Server login name and password rather than have to generate and maintain SQL Server users.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS