Monthly Archives: August 2010

Extension methods: what, how, when

I’ve already written a little bit about extension methods in the past. However, since I’ve decided to create a new basics series, I think that I probably should go back and write about it again. I guess that the first thing I need to do is define the what. In other words, *what* is an extension method?

An extension method is a static method that you can invoke using instance method syntax. Here’s a quick example:

namespace StringHelpers {
    public static class StringExtension {
        //don''t need this in real world!!
        public static Boolean ContainsOnlyDigits(this String str){
            if(str == null ) throw new NullReferenceException();
            return str.All(c => char.IsDigit(c));
//use the extension method
namespace ConsoleApplication1 { //import extension methods using StringHelpers; class Program { static void Main(string[] args){ var notOnlyDigits = "123Nop"; //const is better Console.WriteLine(((String)null).ContainsOnlyDigits()); } } }

As you can see, an extension method is always static and must be defined in a non generic, non nested, static class. The first parameter of an extension method is annotated with the this qualifier and defines the type over which the method can be called using an instance method syntax. In order to use the extension method (the *how*), we must first introduce it in the current scope. To achieve that, we need to resort to the using directive (as shown in the previous example).

Whenever the compiler finds an extension method, it will convert it into a static method call. Currently, you can use extension methods to extend classes, interfaces,delegates (probably more about this in a future post) and enumerate types. Internally,and since external methods aren’t C# specific, there is a “standard” way to mark a method as an extension method. In C#, when you mark a static method’s first parameter with the this qualifier, the compiler will automatically apply the ExtensionAttribute to that method and to the class where that method is defined. By annotating the type with the attribute, the compiler is able to query an assembly and get all the types that have extension methods defined.

Extension methods are really great and do improve the quality and readability of the code. However, I’ve noticed that they’re starting to be abused…for instance, it was only recently that I’ve downloaded the source code for the Fluent NH project and I couldn’t stop noticing that the CheckXXX methods (used against PersistenceSpecification instances) are all implemented as static methods. I’m having a hard time understanding this and here’s why. In my limited experience, PersistenceSpecification exists so that you can write tests for your NH mappings. Now, that means that you’ll *be* using this methods to test the mappings whenever you instantiate a new instance of that type. Since the guys that wrote the code for those methods *do* have access to the PersistenceSpecification class, I really can’t understand their decision of defining these methods as extension methods (and yes, I know that MS used the same approach for extending the IEnumberable<T> interface, but I believe that we’re not talking about the same type of scenario: after all, it’s perfectly fine to use the IEnumerable<T> without using LINQ).

So, when should we use extension methods? Here’s my thoughts about it (the *when*):

  • use it *sparingly*. I really can’t stress this enough! We’re still doing OO and there are several options for extending types. Do remember that there are some versioning problems associated with extension methods. For instance, if the type you’re “extending” adds a new method with the same name as the extension method, the code will always use the instance method (after recompilation, of course) because extension methods will only be considered as candidates when all the instance method available have been considered as non-viable.
  • they should look and feel like extension methods. The typical example of not following this recommendation is adding an IsNullOrEmpty extension method to some class and returning true when the “this” parameter is null (btw, here’s an example of what I mean). If the “this” parameter of the extension method is null, it should really throw a null reference exception since this is the best option for mimicking what happens with instance methods.

Overall, I’d say that extension methods are an excellent tool, but don’t get carried on and start using it everywhere. After all, we’re still writing object oriented code, right?

Wrap-upper and wrap up for August 2010

Simon May from MS UK created cool app: Live Writer Wrapup Tool. The tool allows you to create the following from your RSS feed:

Bingo: one click and all my messages for the month are published.

To install the tool visit

Then start it, enter your feed address, blog post title, and select the range for you wrap-up (click (don’t release the button) on a first date and slide cursor  to the last date) and click “Blog This!”



MS Security advisory: Insecure Library Loading Could Allow Remote Code Execution

lockRecently issued advisory has kind of shaken the around-security-society: “we all gonna die will be hacked”. Really, this is that nasty sort of a bug which is not a bug, actually. It is more like FireWire: just vulnerable by design, so it is to be fixed more on software vendors side, rather than on Windows one. Correspondingly it is a long, long process and until it is finished it will be considered as a 0day vulnerability. But will it really have such an impact on your security?

I doubt it. Really. On the one hand, an attacker, who successfully utilized the vector has all the power of the current user, which is not good anyway. On the other hand, nevertheless,  the attacker must be either in your local network, or you should use WebDAV. LAN is usually considered as more or less secure. Now the question: how often do you open applications from a not trusted WebDAV folders? I don’t do it and I don’t recommend it whether there is some 0day vulnerability around or no. The only thing that you can do to harm yourself is to open a document from a “prepared” WebDAV folder. This is the hard part to protect from. But you just can avoid doing that unless you are totally sure that the software piece you use to open the document is patched by its vendor or download the document to a local drive before opening it.

So,in normal environment the attacker will get only user’s rights and only in case a document or a program was opened from a not trusted location. It is bad situation,but not as bad as some journalists picture it.

P.S. I still recommend to read the advisory and take precautions.

Meet Aurora (1 of ??)

Now that the public beta of Aurora is out and in the wild, we can finally talk turkey about the product and what it does and doesn”t do. To that end, I”m starting a series of posts to introduce people to Aurora who might not otherwise be able to look at the product. My reasons for doing this (given that there are a lot of other folks who are also blogging/writing about the product) are multifold. First, back in the SBS 2008 pre-release days, I got up on my soapbox and told everyone who would listen that they needed to take a long hard look at SBS 2008 because it was significantly different from SBS 2003. Based on the types of issues I”m still helping IT Pros get through with SBS 2008, there are a LOT of people who didn”t do this. Well, Aurora is completely different from anything you”ve seen in the SBS product space before, and as such, there are some misconceptions and false assumptions I hope I can stamp out early on through these posts. Second, there are some things about the defaults in Aurora that I think need to be tweaked that I doubt very seriously will make it into the final product release build, so I”ll be documenting some of those tweaks here as we go through the series. Third, there are some,well,*different* things I”ll be doing with Aurora, and I want to have a place to highlight some of those unusual configurations someplace, especially if a few of these zany ideas make sense to other IT Pros who want to use them in their own deployments. Finally, I think that Aurora is going to be a huge player in the under-25 employee business, and the sooner consultants and businesses learn about what it can (and cannot!) do, the better!

So, with that introduction, let”s get started. If you haven”t already, I HIGHLY RECOMMEND that you start learning about the product on your own. You can get some overview information from the SBS Blog post from Michael Leworthy. That post includes links to several resources, including an overview video, that make for a good introduction. I”d also recommend, if you haven”t already, that you read the Aurora Beta Announcement on the SBS Blog and go sign up for the beta of the product so you can get your hands on the bits now. 

While you”re waiting for the bits to download, let”s take a quick tour of an out-of-the-box basic install of Aurora in a test environment. From the basic desktop screen, you can see that this is NOT your typical SBS.


In fact, if you”ve seen Windows Home Server, it should look really familiar to you (especially if you”ve been in on the Vail beta). That”s because Aurora is built on the same codebase as the next version of Windows Home Server, codenamed Vail. We”ll get more into the similarities in later posts, but for now, let”s mention the one key difference between Vail and Aurora, and that”s Active Directory.

As you”ll see in the above image, when looking at the list of services running on our unmodified Aurora install, there are Active Directory services running on this server. These are set up as part of the Aurora install and are present by default (i.e., you cannot choose whether to install Active Directory or not). Part of the licensing restriction for Aurora is that it must run Active Directory, and it must be the root domain holder for the network (very similar to the licensing restrictions for SBS, and the reason why you cannot have Aurora and SBS in the same domain).

One other key service of Active Directory is DNS, and as you can see in the above shot of the second page of services on Aurora, the DNS server service is installed and running. Again this is done as part of setup and is not configurable. Active Directory relies heavily on DNS, so it”s good to have the service there and pre-configured as part of the setup.

If you look carefully at the list of services in that second screenshot, however, you may notice something missing (if you”re used to the typical SBS installation). That”s right, there”s no DHCP Server service listed. Aurora does not preinstall or preconfigure DHCP services for the network. The default assumption with Aurora is that some other device on your network, perhaps the Internet Router, is providing DHCP for the network. This is one area where I disagree with the default configuration of Aurora out of the box. I firmly believe that DHCP should be installed and running on Aurora so that proper AD information can be handed out to workstations participating in the Aurora network, such as the default internal domain name and the IP address of the Aurora box as the primary DNS server for the workstations. Anyone who has run across domain-joined workstations that do not point to a domain-enbled DNS server knows that the Active DIrectory performance of the workstation leaves a great deal to be desired. Fortunately, the DHCP service can be installed on Aurora, and I have it on good authority that steps for doing so will be included on independent Aurora build docs that are being developed right now.

Next, let”s take a look at the Active Directory environment that is configured with Aurora. Below is a capture of the Active DIrectory Users and Computers console showing the AD defaults for Aurora.

Again, anyone familiar with SBS will notice significant differences in the SBS AD configuration and the Aurora AD configuration. The Aurora AD configuration is the same as what you would get installing Active Directory on a standard Windows Server 2008 box. No custom OUs, user accounts placed in the Users containers, and so on. This isn”t necessarily a bad thing – Foundation Server does the same when AD is installed (not installed by default). But it *is* different from SBS, and that”s something that IT Pros need to be aware of. This configuration has significant impacts on how Group Policy will be applied, but we”ll dive into Group Policy on Aurora in more detail in a later post.

Since we did mention Group Policy, however, let”s take a quick peek at the Group Policy configuration in our out-of-the-box Aurora install:

When you look in the Group Policy Management Console, you”ll see that the only GPOs listed for the domain are the Default Domain Policy and the Default Domain Controllers Policy. That”s it. Again, this is exactly what you”d expect from a traditional Active Directory installation, but NOT from an SBS installation. SBS has used Group Policy heavily in its configuration since SBS 2003, but that is not the case in the default Aurora install.

So in this quick look at Aurora, I hope you”ve seen that Aurora is NOT the “next version of SBS” as some media outlets have claimed that it is. It”s going to be an interesting hybrid of Home Server and Foundation Server, but it is NOT a derivative of the traditional SBS product line. While not all of the details regarding Aurora have been finalized or made public yet (i.e., pricing, licensing, additional restrictions, etc.), I still think that this is going to be a great platform to build on for the 1-20 employee business. I”m already making plans to “upgrade” several of our customers from SBS 2003 to Aurora (and I”ll cover more about how I plan to approach that move from a technology standpoint in later posts in this series) once the product is released, and see the potential of this product with other clients that we haven”t had a good solution for up until now. But as different as this product is, the typical SBS consultant will need to rethink the way they approach ongoing maintenance for this solution, and the best way to devise those plans is to start working with the product NOW to see what you”re really up against. Some of the tools or processes you”ve been using for years simply may not work the same way on Aurora as they do your other supported devices, and you really don”t want to figure that out AFTER you”ve deployed this to a customer.

Bottom line, we”re sold on Aurora, and think you will be, too. cool apps–useful and not

cloudSome time ago I posted about group policy search service, published in Azure at the Then I thought: “it cannot be the only application on the whole domain!”. And I was right, of course. There is, actually at least several dozens of apps there. There is mostly test stuff at the moment on the site:

WordPress on Azure (how-to)

Several apps related to environment which don’t seem to be a completed apps, but are interesting, nevertheless

A 70 gigapixel (!!!!!) shot of Budapest with zoom and browsing ability. Man, it’s useless, but what a beautiful city. Thanks, guys!

Real-word polygonal battle game (the whole world is a chess-board)

And even the site about medical marijuana strains…

But look, here we have:


Equallogic site

VMWareConsulting (their Azure version works better than the usual one 8) ,,)

They are real, actually.

And just two apps which seem to be interesting:

Webcast collection for IT Pros and developers. Renewable.

And even a document search engine (should compare to Google =) )

Try to find your favourite on, and even to create your own one.

Remote Desktop Connection Manager

Having many servers one wants to improve and optimize work with them. MSTSC is excellent instrument, but with many drawbacks: windows either close each another or there is to much to switch between them, it takes comparatively long time to launch it and so forth. Of course we have built-in Remote Desktop console, but it cannot even alphabetically sort our connections let alone inability to create hierarchical structure of any kind:


Other settings don’t impress either. I have been using visionapp Remote Desktop for a long time (and will continue, because I have a license and it is somewhat more powerful than that stuff the topic is about): great piece of software, which allows all the abovementioned plus more. Take the supported connection types alone:


The remaining options set is impressive too:


But vRD has one essential shortcoming: you have to pay for it. Of course a hundred of dollars is not a huge amount for some company where an administrator has to deal with dozens and hundreds of servers, however… Not long ago I have run into (yeah, I am not the fastest guy in the Universe: my coworkers have been using it for months already) Remote Desktop Connection Manager. It is free console from MS which has all the essential features:

You can organize your connections and sort them (and you can see what” is happening in open windows):


You can save your credentials (and inherit them down the hierarchy), which is not the recommended way to use them, though.


And, after all, all the RDP-related settings. To sum up: if I didn’t have a license for vRD then I would be definitely a grateful user of this console. Therefore,if you do not want to pay or you do not need all the extra features then I recommend you to use the RDC Management console.

On Aurora

Yesterday, Microsoft released the first public beta of Windows Small Business Server Codename “Aurora” on the connect site ( This is one of the two products in the SBS space that were announced back at WPC in July, and Aurora is the new entry into the SBS product space. Though some media outlets have been describing Aurora as the next version of SBS (implying that Aurora follows in the footsteps of SBS 2000, SBS 2003, and SBS 2008), that is NOT correct. The product named Windows Small Business Server Codename “7″ (which has not yet been released in a public beta) will be the next version of “SBS” as we have known it, including Exchange, Sharepoint, RWW, etc., all bundled on the same box.

Aurora is something completely different in the business line. Those who are familiar with Windows Home Server will recognize Aurora when they load it, as Aurora is actually built on the WHS codebase. The key differences in Aurora and WHS are Active Directory (Aurora has it,WHS doesn”t) and user limits (25 for Aurora,10 for WHS). Aurora will also natively integrate with Microsoft”s hosted Exchange product line.

There”s still a lot we don”t yet know about Aurora: pricing, licensing, CALs, release date, etc. But for those who are dealing with businesses under 25 users (for me, i”ll probably put the limit at 20), Aurora is definitely something that you need to start looking at. Now. 

If history has shown me anything of late, it”s that a LOT of people never took a look at SBS 2008 when it was in beta. Yeah, I heard all the excuses: I don”t have the hardware, I don”t have the time, yadda yadda yadda. Same thing after it was released. I spoke to a number of user groups and encouraged the members to load a box with SBS 2008 and kick the tires before dong a customer install. Or doing a migration (or two or three) before doing a migration for a customer. Funny thing is, generally speaking, those who looked at SBS 2008 before deploying it, especially those who ran through test migrations before migrating a customer, had FAR fewer challenges than those who walked into it blind. Back then, my mantra was “SBS 2008 is not your grandfather”s SBS.” SBS 2008 was significantly different than SBS 2003, and IT consultants found out either the easy or the hard way (mostly the hard way despiet a LOT of people”s efforts to the contrary).

Well, the same holds true for Aurora. This is NOT your typical SBS. SO before you even THINK about deploying it for a customer, download the beta and give it a whirl. There”s a greater than 0 chance that Aurora will become the backbone of our internal operation (although we will be doing things a bit differently, but that”s a different post for a different time), so it”s a product we”re particularly sold on. But I cringe at the thought of the IT Consultant who will go out and blindly sell Aurora to a client, either thinking that it”s the “next SBS” or being completely unfamiliar with it and end up causing more problems than resolving issues. 

So please, do yourself and your customers a favor, this time get in early on the Aurora product timeline and start getting familiar with it. You”ll find that it”s a bit easier on hardware requirements than SBS 2008 so that argument should go away, and I think that when you spend some time with it, you”ll see how it will fit in for some of your clients and become a good sales tool for you. Just get over to the Connect site, sign up for the beta, and get started posthaste!

Two Very Important Attributes with Active Directory Recycle Bin

I’ve blogged several times about the AD Recycle Bin (ADRB).  It has been a popular subject here at the Life of Brian and I can see why.  It is a feature all AD admins have been screaming about for years.  I wanted to spend 5 mins of your life going over two attributes that confuse everyone…even me from time to time.

There are over a dozen attributes that deal with ADRB but I want to focus on two of them, isDeleted and isRecycled.  The first time I read through the documentation on these attributes I thought it was pretty straight forward, isDeleted is when an object is deleted and isRecycled is when an attribute is recycled.  Well it is NOT that simple.  Let me explain these attributes a bit further for your understanding.

The isDeleted attribute has been around since Windows 2000 and exists on every AD object.  It describes if an object is deleted (makes sense) but also if it is restorable.  After the ADRB is enabled you have the ability to restore deleted objects (that were deleted after it was enabled).

The isRecycled attribute is new to Windows Server 2008 R2 and only exists on an object after it has been recycled.  By default, a deleted object will become a recycled object after the msDS-deltedObjectLifetime (another new attribute in Server 2008 R2) expires.  Now that object is what I like to call dead dead.  This means that you can’t restore it with all its pretty properties.  Its kind of like the old way of restoring an object just to get its SID back.

I think you can see where the confusion comes into play.  When I hear or read the term isDeleted my gut reaction is to think that it is deleted (dead dead) and when it says isRecycled I think it can be restored fully…well the sad truth is that it is the opposite.

Freebies #2: Diagrams for SharePoint 2010

share-pointThat is quite old stuff, actually. But I just get to it in my “clean up that darn OneNote” job. I won’t repost the whole blog post, it is unnecessary: just believe me – those are great and useful.


RadScheduler Client-Side Capabilities Part 3: Appointment Templates

Unfortunately, client-side templates aren’t present, at least with the 2010 Q1 Telerik release, and it doesn’t seem like Q2 added it either.  So if you want to customize an appointment, be prepared to use JavaScript.  The key event is appointmentCreated, the client-side event when an appointment is, if you haven’t guessed, just created.  The server-side AppointmentTemplate is ignored, so we need to add code to target the div.rsAptContent DIV element to add content to (FireBug came in handy to figure this out).  Using this DIV, we can append content like the following:

function apptCreated(sender, e) {
    var el = $(e.get_appointment()._domElements[0]).find(“div.rsAptContent”);
    $(“<div/>”).html(“some value”).appendTo(el);
    $(“<div/>”).html(“another value”).appendTo(el);

The e.get_appointment() reference refers to the JS object, not an element, but it has a collection of dom elements available via the _domElements collection.  Using find, I dug down through the HTML tree to find the appointment element.  Note: there may have been an easier way, but I had to rapidly add this feature, and this worked for me.  Please comment if there is a better way.

Using JQuery, I appended DIV’s to this root element , which get appended to the element below the subject.  Note: you have to be careful of CSS here, that the appointment will clearly display.  Be mindful of the appointment height, and how much content gets displayed.

Recent Comments