Wednesday, March 18, 2009

Blocking IP Addresses Using MMC

I was searching for a solution to block any communication with specific IP addresses. I have come to this solution using MMC (Microsoft Management Console). The following steps will allow you to block any communication - whatever the protocol is - with specific IP addresses or subnet:

1. Open Start Manu > Run > Write "MMC". Then press Enter.
2. In the Management Console > File > Add/Remove Snap-in...
3. In the opened dialog, leave "Local Computer" as it's and click "Finish".



4. You will have a new node in the left tree called: "IP Secuirty Policies in Local Computer".
5. Right click on this node and select "Create IP Security Policy".
6. In the opened dialog, write "Block IP".
7. Click Next till the end of the wizard and then "Finish".
8. You will have an item in the left pane called: "Block IP". Right click on it and select "Properties".



9. In the opened dialog, click "Add".
10. Go through the wizard, till you reach a step called: "IP Filter List".
11. Click "Add". IP Filter Dialog will open.



12. Modify the name of your IP Filter and click "Add" to add an IP filter policy.
13. Click "Next. Leave "Source Address" as "My IP Address".
14. In the destination address, you can select "A specific IP Address". You can also filter by DNS or subnet. Enter the IP address to block. Then click Next.



15. Leave the protocol to be "Any" and click "Next".
16. Then click "Finish".
17. Apply all changes, and close all the opened windows. You may have to add "Block" action if it doesn't exist.
18. After you finish, don't forget to write click on "Block IP" policy and select "Assign".



Now try to ping the blocked IP addresses. You should get "Destination Unreachable" message.


Tuesday, March 17, 2009

Maintenance Plans in SQL Server

Creating backups for your database is an essential task in every environment especially for critical data storage. But have you ever ask yourself how to create your backups in a periodic manner - say every week or so? If you was able to do so, how will you manage the space in your disk? Maybe you don't want to keep any backup files older than one month.

The first solution you may think about is to create a SQL script and execute it in a custom job. But wait, SQL Server can do it for you and save alot of this implementation hassle. In the SQL Server, you have the option to create "Maintenance Plan" for your database. This plan provides you with more advanced options for creating backups for the data and the transactions logs.

When you create a new plan, you will have to go through a configuration wizard. The interesting part is in the backup configurations. You can provide how often you want to backup your database (i.e every week, month or so). You also specify how long you want to keep the backup files and when to remove it (i.e You may remove any backups older than one month) so that you save your storage space. Another interesting point, you can create only one plan for more than one database. The plan can be configured also to create a separate backup folder for each database.

The maintenance plan is a periodic task which needs a running job. This is why it requires a running SQL Server Agent in your database server.


Monday, March 09, 2009

Stories From A Gaming Startup

CuttingEdgeClub organize a seminar in ITWorx to elaborate a story about how gaming startup can emerge. The seminar is scheduled to be on Wednesday, 11th March, 2009 at 5:30 PM in ITWorx - Free Zone. The session will be provided by Mostafa Ashour - Managing Partner, Khayal Interactive Entertainment.


CuttingEdgeClub is an ITWorx technical seminar club for technology enthusiasts. Its mission is to provide an easy gateway to pertinent and updated technology information for a growing audience in a simple, pragmatic and accessible way.


Sunday, March 08, 2009

Resident Evil

Do you know about the time-bomb viruses? Those ones which start execution in a certain time frame. Today, I have a similar behavior but this time not a virus. It's an evil code.

We have an application on the production environment which has been created seven years ago. The project seems to be working properly for a long time with no massive problems. However, an exception suddenly encountered when any user try to edit some data items.

Microsoft VBScript runtime error '800a0006'
Overflow: 'CInt'
/newsline/newsline/dbshell.asp, line 641
The project was implemented in classic ASP and VB script. If you had the opportunity to work with this crappy-style languages, you can imagine how debugging in this kind of code is missy. So I had no way except to analyze the exception getting the most out of it.

If you notice, it's an overflow exception. This means that CInt has got some large integer number to convert and failed to. After googling, I have found that there is a maximum limit for this method input and it's 32768. From a second look in the exception, you can see that it happens in a file called: "dbshell.asp". This leads to conclude that the number this method is trying to convert is retrieved from the database.

This was actually a good guessing. In the production environment and after seven years, some data table in the database reached to have more than 33974 records. The method couldn't convert any sequence ID for any items with ID larger than 32768. The issue couldn't be captured in the quality test as this low level test case couldn't be considered or even thought to be problematic.

The developer who wrote this code from seven years ago didn't imagine that some day the number of the records will reach this limit. The exception was resident to blow up after these long period. These lead us to an old lesson. At the time of building your application, you don't think that your application will last for long. You need to consider which data you think will go large and which is not. Hence you follow the appropriate guidance in the implementation.


Saturday, February 07, 2009

Code Camp '09

dotNetWork will organize a day called: "Code Camp '09". The day will allow the development professional to introduce several technologies and new Microsoft products. dotNetWork is promising that the day would be one of the biggest events they have ever organized before.

Code Camp '09 is a two day event. It will be held on: Thursday, February 19 and Friday, February 20, 2009. To have more information about the event and the agenda, please visit the event website: Code Camp '09

.network.org user group is a group of youth who share the same passion for the development on .Net platform in Egypt. The group started in the last December 2007 with several technical events during the last year. For more information about the group, visit their website here.


Sunday, November 23, 2008

ASP.NET MVC Routing Using XML Custom Configuration Settings

In ASP.NET MVC application, you need to add some routing code in the Application_Start of the Global.asax file to define your routing criteria. These lines of code take a shape of configuration settings for the MVC application and I was thinking if we can transfer these configurations line of codes to be XML settings in the web.config file. My target is to make the routing configuration in the web.config file as following:



As you can see, the later configurations define the Ignore and Routing lists of the MVC application. In the "Ignore" list, you define the URL criteria to be ignored by the MVC routing. In the "Map" list, you specify a list of the routes including the route name, controller and action. You can also define any optional parameter mappings for your actions.

To do that, I have to create a custom configuration section: MvcRouteConfigurationSectin. The section has a IgnoreCollection - inherited from ConfigurationElementCollection class - of IgnoreItem and another RoutingCollection of RouteItem.



The solution will also add an extension method for RouteCollection object so that you will be able to map the configuration section in the web.config directly to your RouteTable.



To use the project, you just need to include the MvcXmlRouting.dll in your MVC web project. Then you add the following line inside the configSection Tag in web.config:



You then define the ignore and the routing configurations for your web application as defined earlier in the web.config. Finally, you will need to edit the RegisterRoutes method in the Global.asax file to add a couple of lines as following:



Now all your routing configuration will go to the web.config file. No need to edit the Global file anymore. However, changing the routes in the web.config still need to reset your IIS as the routing is registered in Application_Start.

Download: Binary | Source Code

The project is implemented using ASP.NET MVC Beta 1 and Visual Studio 2008. It's not guaranteed that this project or the related assemblies will properly work in earlier or newer version of ASP.NET MVC Framework.


kick it on DotNetKicks.com
DZone - Vote Up!

Ping Back Links:
- http://blog.51mvc.com/view/20


Thursday, November 13, 2008

Hewitt Middle East Best Employer Study

In the last December 2007, this blog hosted a quick survey to measure the different aspects of the software employers inside Egypt. I am glad to announce that there is another independent initiative showing up these days. Hewitt - a provider of HR outsourcing and consulting services - launches the Best Employers in Middle East 2009 study. The study aims to honor the leading organizations of Middle East as outstanding places to work. Hewitt conducts its Best Employer research in a number of markets, including Eastern Europe, Canada, Latin America and Asia. This survey is designed to be the largest employee research project ever undertaken in Middle East. Hewitt invites all the employers in the Middle East to participate in this survey. The survey will show how effective is your organization and wither it provides a workplace that engages the intellectual and emotional commitment of your employees or not. The study will provide a level of confidentiality so that the names of all participating organizations will be strictly confidential at all points of time. The exception will be those organizations that will be honored as a Hewitt Best Employer in Middle East.


Wednesday, November 12, 2008

On Finding the Arabic Needle in the e-Haystack

Lack of information is an issue, but lack of ability to reach the information is a much more serious issue. With internet getting appended everyday with million of new information pages, search engines become unconsciously mandatory to use.

CuttingEdgeClub organize a seminar in ITWorx to elaborate how search engines operates and to highlight the status of the rapidly growing Arabic-Web in particular.

The seminar is scheduled to be on Wednesday, 19th November, 2008 at 5:30 PM in ITWorx - Free Zone. The session will be provided by Hany Abdelkawi - Project Manager, Link Development.

CuttingEdgeClub is an ITWorx Club aims to share information about the latest technologies among the IT community by organizing technical sessions and seminars in a regular base.


Saturday, November 08, 2008

.NETWork.org 9th Gathering - Coming Out This November

.NETWork.org announced the next 9th Gathering to be held in 29th November. The event will be in CIC - Canadian International College and four speakers from ITWorx and Raya Software will be giving the sessions. Here is the list of the topics and speakers:

BizTalk - SharePoint Integration.
Hossam El-Deen M. Barakat
Senior Software Developer | Raya Software
Information Architecture
Mostafa Mourad
Team Leader | ITWorx

IIS 7
Hossam Kamel
Senior Software Engineer | ITWorx

Applying Domain Driven Design on ASP.NET MVC
Mohammed Meligy
Senior Software Developer | Raya Software









.network.org user group is a group of youth who share the same passion for the development on .Net platform in Egypt. The group started in the last December 2007 with a total of eight technical events during the last 10 months. For more information about the group, visit their website here.


PRG Pattern - You're Already Doing it

Have you ever had this message dialog asking about resubmiting the data when you try to refresh a web page? This actually happen after submitting a form or enter your login information.

One of the good practices when developing web application is to redirect the user after a successful posting request. This practice is refereed as PRG pattern (Post/Redirect/Get). The target is to avoid duplicate post requests from the client and providing a smooth navigation through the web application.

What actually happen in PRG is that the browser try to send an HTTP 303 redirect request along with HTTP "Location" header. It's nice to know that something you're used to make as a default practice is actually a pattern. The following is a sample code in ASP.NET MVC illustrating the usage of the pattern:

[Authorize]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ChangePassword(string currentPassword, string newPassword, string confirmPassword)
{
    if (ModelState.IsValid)
    {
        MembershipUser currentUser = Provider.GetUser(User.Identity.Name, true /* userIsOnline */);

        // Attempt to change password
        bool changeSuccessful = currentUser.ChangePassword(currentPassword, newPassword);

        if (changeSuccessful)
           return RedirectToAction("ChangePasswordSuccess"); //PRG Pattern recommendation
    }

    return View();
}