Cannot set a credential for principal ’sa’. (Microsoft SQL Server, Error: 15535)
For anyone on SQL Server 2005 who gets this Cannot set a credential for principal ‘sa’ error, the fix is easy, straight forward and simple…
Make sure “Map to Credential” is checked. That’s it. All you have to do is check “Map to Credential” and you’re set. For those without eyes, it’s on the bottom of the first screen where you set the user password (by right clicking the user and selecting “Properties”)
This one had me scratching my head a bit, clean install from Visual Studio 2008 (With Express 2005 Service Pack 2) and SQL 2008 SSMS
How to find + stop SQL injection attacks
Filed under: .NET, Classic ASP, Hosting, IIS 6.0, Programming 101, SQL Server
There’s a lot of stuff out there about SQL injection attacks, but there’s not much that will help you figure out how to stop these attacks from occurring.
First, let’s talk about what a SQL Injection Attack really is. Some people think it’s a virus of sorts, that is “inside your site.” Not the case. These are bot attacks by other virus infected computers. They simply use a brute force approach of scanning URLs that take POST/GET inputs and attempt to send their own data to them.
So, how do you track these down and stop them? For web sites powered by Microsoft’s IIS, here are our suggestions:
- Look at your IIS logs
Try searching for the word “DECLARE” or “EXECUTE.” If you’ve been hit by an attack, these will more than likely show up in your IIS logs — at least for any attack that was attempted using “GET” posts. If you do find any instances of “DECLARE” or “EXECUTE” these are the pages to start with. - Use centralized database connection handling
Simple, make a centralized file (e.g. connection.asp if you are using ASP) that handles all of your DB access. This way, it’s easier to make sure that you are SQL encoding your pages. You can easily search queries for “DECLARE” and “EXECUTE” and stop the attacks dead in their tracks. - Implement a site wide solution
If you are running your own server, we highly recommend ISAPI_Rewrite from HeliconTech (http://www.helicontech.com/isapi_rewrite). This is an ISAPI filter that allows you to do a variety of things, including scan URL data. This will stop 99% of attacks without changing ANY code on your site!\ - Never use “sa” as your database user, create a user for the database you’re working from and then remove privileges to read the master dbo. This prevents the attacker from “sniffing” your database structure, however, these attacks have evolved so that sanitized stored procedure based attacks happen even with these types of security in place. See http://www.ngssoftware.com/papers/more_advanced_sql_injection.pdf for more information on this and other ideas in preventing SQL Injection attacks.
If you’ve ever been scratching your head wondering where the leak in your programming is (or have taken over a project from someone else) then the best way to determine through which page the attack happened is by checking out the IIS logs.
There are many scripts available to clean up, but the best tip is to backup hourly, and to follow best practices (some of which I highlighted here). Good luck
Easiest & Most comprehensive Mail Marketing tool
iContact’s main to goal is to incorporate sophisticated features into a simple, easy to use and affordable package. Although many programs attempt to achieve this balance, iContact does so incredibly well.
Great User Interface
iContact is able to do this because of their great user interface, which allows new email marketers hit the ground running with basic features, but also makes it simple for the more experienced to access the features they need. Either way, iContact has created an awesome product, which is why over 50,000 customers currently use iContact.
Basic Features You’ll Love
iContact makes it easy for new email marketers to get in the game quickly:
- Inexpensive: just under $10/month to start!
- Over 300 professionally designed email templates make your emails look professional
- Schedule your messages to be distributed in the future to help save time
- Their system automatically makes sure your emails won’t be flagged as SPAM, so your users will always get your emails.
- Track what your subscribers do with your emails, so you know how well your newsletters are being received.
- Event RSVP tracking
- Distribute surveys easily
.
.
Advanced Features You’ll Love
Professional email marketers also get everything they need to manage their bulk email lists:
- Quickly segment your email list to customize which subscriber types get certain emails
- Set-up autoresponders to help automate your email campaigns
- iContact maintains a detailed history of subscriber actions to help you customize your campaigns
- Design and upload your own email templates
- Unlimited number of email lists
Downside: iContact’s Support Hours
The only downside to iContact is the hours they are available to call. Support is not 24×7, but from 8am to 8pm EST. However, their support staff is very helpful, and many times you will find that it’s actually easier to use their online knowledge base, which has video demonstrations and step-by-step instructions to help you with everything you need.
iContact Pricing
With iContact’s pricing, you only pay for the amount of emails you are going to send, which means that you can start off with an inexpensive plan and pay more only when you know that your newsletter is successful. Plus, iContact is one of the most affordable email marketing providers available.
| Contacts | Monthly |
|---|---|
| 250 | $9.95 |
| 500 | $14.00 |
| 1000 | $19.00 |
| 2500 | $29.00 |
| 5000 | $47.00 |
| 10000 | $74.00 |
| 15000 | $109.00 |
| 25000 | $149.00 |
| 35000 | $239.00 |
| 50000 | $379.00 |
| 75000 | $529.00 |
| 100000 | $699.00 |
Is It Right For You?
Because of its features and ease of use, iContact is best for both new email marketers just getting started as well as advanced email marketers who have years of experience. However, if you are a Fortune 500 company or have an extremely large email list (over 100,000 subscribers), iContact probably isn’t right for you.
Basically, iContact has everything you will need to run successful email marketing campaigns.
Speed up website load time by denying tracking
Recently it has dawned upon me that not everyone knows about tracking cookies or analytics (Google and so forth) and what it really means when visiting websites… It’s always seen as a form of spy-ware or hacking Trojan to help people gather information and exploit it to their advantage. That is absolutely true, however, not in a “hacking” sense…
Advertising companies are fond of requiring statistics and demographic information from a website before they tend to invest in advertising, and most websites (if not all) have Google Analytics installed to help them track their users for very powerful reports as to trends when visiting the website. Combined with Webmaster Tools (also a Google product) and some comparison data from the physical server logs, this is more than enough to track trends, visitors and useful information when giving it to possible advertisers to decide if your website is indeed worth investing in.
Enter the Nielsen reporting facility. They claim to be the leaders in gathering data and useful information on the public visiting a specific website. Indeed, what they claim is very nice, but how they go about achieving that borders on the “spyware” side.
From my brief overview of the tracking code installed on several South African websites, I found that several attempts at creating “objects” with client-side JavaScript code made it possible for them to determine which programs you have installed on your PC. Indeed, very interesting.
What would a company want with that type of information anyway? Why not just leave it at Google Analytics, a well known website tracking and analytic software made freely available to anyone and everyone?
Something to hide perhaps, but I can only speculate as to their reasons. Perhaps some advertisors insist on this specific piece of tracking code being installed on the website. Nobody would notice right?
Well, some more advanced users have, and most of them have done something about it already, speeding up their South African websites by noticable amounts, they’re enjoying a glimpse of what true broadband speeds are like in other countries, and with this little tutorial, so can you!
Here’s how!
Read more
How to move domain to a different account in HELM 4
HELM 3 was easy to administrate, a multitude of utilities and tools existed helping us with mundane tasks, one of which is to move a domain from one account created on HELM to a different account. HELM 4… no such luck with a utility… but opening up the database. Checking the Accounts table for the AccountId you need to move a domain to… and then opening the OnlineServices table, will show you all the domains added on HELM and their associated AccountId’s. To change the domain linked to an account, it’s as easy as just changing the AccountId to the one you prefer viewing.
Hope this tip helps some folk as I could find absolutely nothing to indicate how to do this and had to figure it all out by myself.
Changing Table Ownership in SQL Server
Recently I had the unfortunate event of a live server being setup and used by only 1 user which wasn’t dbo. Either the programmer didn’t know any better or… well… he was the village idiot… anyway, so… on with the code. Here is a simple T-SQL statement that will get and loop through all Stored Procedures, Tables and Views and update them to use dbo (or any other user you’d like):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | DECLARE @tbl sysname DECLARE tblcur INSENSITIVE CURSOR FOR SELECT name FROM sysobjects WHERE xtype IN ('U','V','P') AND uid = user_id('olddbuser') OPEN tblcur WHILE 1 = 1 BEGIN FETCH tblcur INTO @tbl IF @@fetch_status <0 BREAK SET @tbl = 'olddbuser.' + @tbl EXEC sp_changeobjectowner @tbl, 'dbo' END DEALLOCATE tblcur |
Using openrowset to connect directly to another database without a linked server and execute a stored procedure
Filed under: General PC Stuff, MSMQ, Programming 101, SQL Server
1 2 | SELECT * FROM OPENROWSET('SQLOLEDB',database_location;username;password, 'set fmtonly off exec database.dbo.stored_Procedure') AS Whatever |
The above piece of code is self-explanatory. I’ve only used this in SQL 2005 though, so if it doesn’t work on SQL 2000 don’t come crying to me.
Replace database_location with the IP/Destination of the server you’d like to connect to
Replace username/password with… well… do I really have to explain this?
Replace database with the catalog/database you’d like to query
Replace stored_Procedure with the stored procedure you’d like to execute
The “As Whatever” is necessary. You could name this anything you’d like.
I’ve used the above to query a database directly for data extraction/manipulation. You could go as far as to inner join this in your normal queries if you’re not doing an update/add cursor loop on this.
Enjoy. Took me a while to figure it out
IP-to-Country lookup, for free and 95% accurate
One of my recent posts showed you how to convert an IP address to an IP number so you could do a lookup on a IP-to-Country database.
However, I’ve found the next best thing. Maxmind.com is one of the leaders in GeoIP location and sports a database that is more than 99% accurate. That’s the paid version. For my project though, I only needed to know the country, and had to be pretty accurate.
Welcome Maxmind’s free JavaScript addon API! 95% accurate and does what I want it to do.
1 2 3 | <script type="text/javascript" src="http://j.maxmind.com/app/country.js"></script> var countryCode = geoip_country_code(); alert(countryCode); |
And that’s IT! You don’t have to host the database, you don’t have to do the number conversion yourself and pretty much everything else is taken care for you. The free service also included City lookups! Include and enjoy!
Here’s the link to their site: http://www.maxmind.com/app/javascript_city
Looping through a 2-dimensional array with jQuery
I recently opened my eyes to the wonderful world of jQuery. *drifts off into a fantasy*
Here’s an example of how to loop through a 2-dimensional array using jQuery. Fun & Easy:
1 2 3 4 5 6 7 | var currencyTocountryName = [['USD','U.S. Dollar (USD)','$'],['GBP','British Pound (GBP)','£'],['EUR','Euro (EUR)','€'],['AUD','Australian Dollar (AUD)','$'],['CAD','Canadian Dollar (CAD)','$'],['NZD','New Zealand Dollar (NZD)','$']] $.each( currencyTocountryName, function( i, value ){ alert(value[0]); alert(value[1]); } ); |
As you can see it’s pretty straight forward. No need to have “i” be the place holder, a simple value[0] will get you the first value in the array. This must be the easiest implementation of a loop and array I’ve done in years. Sure, by now I can do a simple JavaScript loop in my sleep. But without thinking and a lot less code, jQuery allows me to leverage off that power. *Drifts off into a fantasy once again*
IP to Country – Convert IP Address to IP Number
Here is a simple SQL Statement that you can use in a stored procedure to determine the IP number of an IP address to compare with any IP to Country database:
1 2 3 4 5 6 7 8 9 10 11 12 | DECLARE @ip VARCHAR(15),@1st INT,@2nd INT,@3rd INT,@4th INT SET @ip = '41.243.224.9' SELECT @1st = LEFT(@ip,CHARINDEX('.',@ip)-1) SET @ip = RIGHT(@ip,LEN(@ip)-CHARINDEX('.',@ip)) SELECT @2nd = LEFT(@ip,CHARINDEX('.',@ip)-1) SET @ip = RIGHT(@ip,LEN(@ip)-CHARINDEX('.',@ip)) SELECT @3rd = LEFT(@ip,CHARINDEX('.',@ip)-1) SET @ip = RIGHT(@ip,LEN(@ip)-CHARINDEX('.',@ip)) SELECT @4th = @ip SELECT ((@4th)+(@3rd*256)+(@2nd * 65536)+(@1st * 16777216)) |
This allows you to have a SQL procedure take the variable of an IP address and not have to convert the IP address in code first. This should work for MySQL as well with minor changes.
The formula is pretty simple and self-explanatory. As soon as I find a reliable (mostly complete) IP to Country database, I will edit this post to reflect it, thus far I haven’t found any to even pick up the address range my country is in which is a real shame. Not even the open source PHP project ip2c can pick it up, which makes me doubt it’s ability to help in any program developed to determine the country automatically from the IP address.













































