Getting AD users in a group with PowerShell

PowerShell rocks, but a part of the rockiness comes from the great third party additions. For example, enumerating the users in an Active Directory Group is somewhat painful with the basic PowerShell… but throw in Quest Software’s excellent free ActiveRoles Management Shell extensions, and things get a lot smoother.

The goodness can be downloaded from http://www.quest.com/powershell/activeroles-server.aspx.

I needed to get email addresses of users in a group and its subgroups. Well, I power up the ActiveRoles Management Shell and type in:

Get-QADGroupMember MYDOMAIN\Finance -indirect |
   where { $_.Type -eq 'user' } |
   foreach { $_.Email }

And then, I just have what I need. Of course, had I needed something else, I would have had quite a great object structure available for navigation.

Thanks, Quest guys!

June 11, 2010  Tags: ,   Posted in: Windows IT  One Comment

First SANKO meeting today – also via Live Meeting

The first meeting of SANKO, the Finnish .NET Developer User Group is today at 14:00 Finnish time in Microsoft’s premises. Check out my previous post for details!

imageThe meeting is also broadcast via LiveMeeting, allowing you to participate. Of course, you can also ask questions via the Q&A tool. Unfortunately, LiveMeeting does not convey the food just announced by the Finnish DPE goddess Tanja.

Welcome, one way or another!

June 8, 2010   Posted in: General  No Comments

Windows Azure CDN now priced and available!

Last November, Microsoft rolled out Windows Azure Content Delivery Network, allowing you to cache your blobs near your users. It was in free CTP for a while, but starting in July, there will be official support – and a price tag attached.

In a recent post on the Windows Azure team blog, the team laid out the pricing: it’s $0.15/GB in the European and North American data centers and $0.20/GB elsewhere. Additionally, you pay $0.01 per 10,000 transactions. It’s actually exactly what I was guessing at back in November – the same price as Azure data transfer from normal data centers in the Western countries.

There is one gotcha though. The CDN servers are a separate cluster of storage. When a user first requests the file from the CDN, the CDN server also retrieves the data from the Azure storage. This means that for the first hit, you pay for both the Azure –> CDN transport as well as the CDN –> user transport.

For Western countries, the $0.15/GB on both channels makes CDN mostly a convenience feature, providing better performance for users in regions with limited abroad connectivity. However, in the Asia Pacific region where data transfers are priced at $0.45/GB, the CDN can also represent a significant way to cut data transfer costs in the cloud.

In comparison to others

The pricing is reasonably competitive. Amazon CloudFront pushes the price per GB slightly lower when you’re transferring really many GBs of data (hey, these guys have a pricing category for 1000 TB+ of monthly transfer!). The rate per transactions is slightly higher, compensating some of that. However, for most applications, the Amazon implementation is practically just as cheap or expensive as Azure.

Both Amazon and Azure implementations also share the same model regarding origin retrievals; Amazon CloudFront data is stored in Amazon S3, and transfer charges from there to the CloudFront are similar as with the Azure Storage to Azure CDN transfers.

SimpleCDN couples the storage and data transfer to a single package and sells it in bundles. This way, it can show very low calculated costs per GB, but reaching the figures would require knowing the demand in forehand – something that practically never happens. That said, SimpleCDN is rather cheap by any measure; whether its quality of service stands up to the services of the giants is another issue (I don’t have enough experience to judge). At any rate, looking at SimpleCDN’s pricing is enlightening, and their competitive savings examples, while perhaps even more contrived, provide an interesting insight into some pricing issues.

Powering it up

Microsoft’s and Amazon’s key benefit is the ease of use. Since they provide an entire cloud programming platform, your data is somewhat likely to be up there already.

When you want to set up CDN access from an Azure Blob Storage account, just check a “Enable CDN” checkbox and you’re good to go. For optimization purposes, you may also want to tinker with blob caching times to make sure that the CDN is serving up-to-date versions of files, but not refreshing them from the source more often than necessary.

June 2, 2010  Tags: , ,   Posted in: Cloud, Web  No Comments

Geolocation on the web

Did you know W3C has a draft specification for Geolocation API in browsers? In practice, that means a JavaScript call could discover your location. Does that really work? And if, how?

There’s this site called http://isgeolocationpartofhtml5.com/, which plots your position on a Google Map. It also correctly answers the question of whether Geolocation API belongs to HTML5; it does not, but is rather a separate specification.

image

If you did try the site, you may have noticed one of a few things:

  1. If you’re running IE, you will get plotted into a random location. IE does not support the API.
  2. If you’re running Firefox 3.5 or newer, you will get a prompt asking if you want to share your location. If you answer no, you’ll get a random location; if you answer “yes”, you may get a correct location.
  3. Other browsers provide varying results. Most builds don’t support it.

How do they do it?

The Geolocation API discusses the ways to call this. In terms of JavaScript code, it’s fairly simple:

if ( navigator.geolocation ) {
    navigator.geolocation.getCurrentPosition( successPosition, errorPosition );
} else {
    errorPosition();
}

Not very hard – just passing a couple of . The interesting part is the success path, i.e. how does the browser know where I am?

The underpinnings of geolocation

image Superficially speaking, geolocation is a reasonably simple problem – it’s just a couple of coordinates. The key problem is that the location data isn’t exactly trivial to come by. Typically, devices do not know where they are. The notable exceptions are mobile devices with built in GPS, but even that is not a perfect solution: GPS works poorly indoors, cannot be kept always on due to battery consumption and takes quite a while to boot up after having been off.

Instead, there are a few other strategies:

  • Locating by IP address. This is by far the most typical, but can also be very inaccurate at times. Its greatest benefit is that it can be done without the client. The browser needs no geolocation support, as the IP address is always known to the server.
  • Using known Wi-Fi hotspots. If the computer has its WLAN capabilities on, it’ll notice nearby wireless networks. If you happen to know the locations of these stations, you instantly gain an idea on where you are. Not surprisingly, Google Street View photography vehicles also tracked the wireless networks and stored their locations.
  • Using cell tower information. If you’re connected to the cellular network – typical with phones, less common with computers – you can use the cell tower ID to identify the tower and thus its position – if you happen to possess a mapping of cell tower IDs to locations. Not surprisingly, e.g. Google does.
  • Using GPS, perhaps A-GPS (Assisted GPS). In A-GPS, other information sources are used to provide a rough location, greatly reducing the GPS startup time.

Combinations are, of course, possible. For example, Firefox sends your IP and nearby Wi-Fi data to Google, which Firefox uses as its data provider for geolocation. That’s a decent combination and has worked excellently a few times for me; other times, the combination positions me in New York while I’m really across the Atlantic in Finland.

The Windows 7 Geolocation Support in Context

One of the key improvements for Windows 7 was that there is now a new Windows Sensor and Location Platform. What it means is that there is an OS-level library for providing geolocation data to the applications.

Well, how does Windows know where you are? The truth is, it doesn’t. The WSLP provides a standard way to plug sensors into the OS, enabling access from all applications without the applications knowing the actual source of the information – quite a bit like the W3C Geolocation specification.

imageIn reality, rather few implementations for this sensor API exist yet. Perhaps the most noteworthy is Geosense for Windows, a free software-based location driver for Windows 7. At this time, its positioning functionality is the same as it is with Firefox: Google’s services are used.

Ideally,  Firefox would request the location data from the Windows 7 SLP (as represented in the diagram) instead of directly accessing Google services. This way, Firefox would directly benefit from possible better implementations – such as the ones based on GPS hardware. Not surprisingly, such a plan is in the works.

Of course, since the vast majority of Windows 7 installations don’t provide any data through the SLP right now, the benefit wouldn’t be great – and for OSes other than Windows 7, you’d still need the handwritten implementation. Of course, the benefits of SLP are on the rise as hardware manufacturers start writing drivers to power the SLP.

May 28, 2010  Tags: , , ,   Posted in: Web  No Comments

Technical Computing Initiative launched by Microsoft

One morning last week, I woke up to an email from Bob Muglia. The subject is the launch of a new initiative, Technical Computing.

So far, what they have managed to do is to launch a site called www.modelingtheworld.com, but the promises go quite a bit further: They want modeling the world to be easy and cheap, even for businesses that don’t have the amounts of computer power modeling currently takes. The team also seems to be attacking the problems regarding the complexity of modeling today.

Interesting, but it’s a long way – and so far, the program seems to be doing far more talking than delivering – the fact that they’re attaching VS2010’s parallelism tools and the concurrency runtime to the team’s merit list isn’t exactly convincing. However, as I sat down to think about it, I think Microsoft’s portfolio actually has surprisingly many assets in this regard.

  1. Windows Azure. It’s the basic element to provide the computing power and data storage.
  2. .NET Task Parallel Library and Concurrency and Coordination Runtime (CCR). It provides an easy to use basic approach for distributed computing. While TPL’s relatively high abstraction level may not be suitable for all modeling scenarios, it will certainly allow easy access to modeling.
  3. Microsoft Solver Foundation. While very little-known, it is a rather robust framework for solving mathematical problems.
  4. An excellent, cheap BI stack. Although perhaps not commonly thought so, the modeling and scientific community can greatly benefit from a good BI stack. Analyzing, and perhaps even more importantly, reporting the results makes a great difference.
  5. Codename Dallas. Although yet unpublished, Microsoft’s Data as a Service (DaaS) offering looks like a winner. Once it’s live, it’ll be a very lucrative approach for distributing and commercializing the results of modeling.

Looking forward to getting this into practice…

May 24, 2010   Posted in: General  No Comments

Unifying URIs from multiple domains with mod_rewrite

For a change, something totally non-Windows here! This web site is served at www.heikniemi.fi as well as www.heikniemi.net. There are multiple reasons for this, but until this week, it has sucked quite a bit from a search engine perspective. It no longer does.

Any page has had at least two URIs. What this means is that the amount of links pointing to any of the pages has been halved; some people have linked to .fi, some to .net. The idea of canonicalizing these URIs to a single host name should combine the visibility (also known as Google Juice), and pages will have a far higher chance of gaining pagerank and thus rise in the Google search results.

My goal was simple: Everything in this blog (/hardcoded/*) was to be served under www.heikniemi.net – because that has traditionally been the URI I have given for this blog. For all the rest of the content, it made more sense to work under the .fi suffix, given that the content is in Finnish as well.

On an Apache server with Linux, this is very straightforward to do (supposing the mod_rewrite Apache module has been installed, but that’s usually the case). Just throw in an .htaccess file in the web site’s root directory with this:

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.heikniemi\.fi$ [NC]
RewriteRule ^(.*)$ http://www.heikniemi.fi/$1 [R=301,L]

Basically, the RewriteCond just says “Apply the following rule whenever the domain name is NOT (note the exclamation mark) www.heikniemi.fi – compared with no case-sensitivity”.

When that condition applies, the RewriteRule’s first argument, a regular expression, is evaluated against the path part of the request URI. For “http://www.heikniemi.net/foobar/”, the path part would be “foobar/”. The .* in parentheses captures all of the path, and the captured group is reused in the second argument to RewriteRule, the URI to where the user shall be redirected.

The R=301 argument sets the HTTP result code to permanent redirect. This is essential to gather the Google Juice. Without R=301, the status code 302 (temporarily moved) is used, and this wouldn’t unify the page ranks between the two sites. The L argument just cancels processing of further rules, and is not strictly necessary, though perhaps clarifies the meaning of the rules.

An exception makes the rule

Then I wanted to make /hardcoded always be served under www.heikniemi.net. There are two approaches to this: Either I could add another RewriteCond/RewriteRule pair to the root .htaccess file, providing centralized control, or I could add a new .htaccess file under the specific directory, just governing files thereunder.

The choice between these two is mostly a choice of preference. I preferred modularity (separate .htaccess easily deployable with the content) over central control, but your mileage may vary. So I pushed the following into hardcoded/.htaccess.

RewriteCond %{HTTP_HOST} !^www\.heikniemi\.net$ [NC]
RewriteRule ^(.*)$ http://www.heikniemi.net/hardcoded/$1 [R=301,L]

Overall, this just a few things reversed from the previous example. However, there is one important thing to note: Note that ^(.*)$ gets captured, but then $1 is appended after /hardcoded/. Now, because this is /hardcoded/.htaccess, paths passed to its RewriteRules are relative to that directory. For example, when I request http://www.heikniemi.fi/hardcoded/2010/05/, that RewriteRule gets to parse a path of “2010/05/”, not “hardcoded/2010/05/” as it would if the same rule were pasted into the .htaccess file in the web site’s root directory.

The two mandatory nitpicks

Something to note: I didn’t really double my Google Juice. The absolute majority of documents were practically always referenced by a single domain name – this was a consequence of consistent linking, but there was no constraint preventing people from linking into separate domains. This is really a way to be sure that you’re benefiting everything you can.

Another point: Really, more than two host names were unified. The servers were always also accessible as heikniemi.fi and heikniemi.net, without the www suffix. The same fix took care of it all.

May 21, 2010  Tags:   Posted in: Web  One Comment

Finnish .NET Developer User Group SANKO founded

Finland has had a distinctive lack of active, developer-oriented user groups. We want to fix this by coming up with a new one, called SANKO (Suomen Aktiivisten .NET-kehittäjien Kerho).

Right now, SANKO operates without a formal basis – instead of bothering with a registered association and whatnot, we want to get down to the business. We have a Facebook page and a LinkedIn group, and you’re welcome to join either.

The real action is, of course, in our meetings. At this time, we aim at organizing 4-6 meetings per year. The agenda for each shall be the usual: a couple of hours of presentations then followed by some snacks and open discussion. The first session will be held on 8th June in Microsoft Finland’s premises (Keilaranta, Espoo). The topic will be “The state of Microsoft Web Development”, and you can sign up already.  All sessions will be in Finnish, and of course, it’s totally free.

I will be delivering the first and last talk in the session. The first one is something of an opening keynote, outlining the tools of the day. The second one provides a near-future view of web development, positioning technologies such as AppFabric, Azure and HTML 5. Also, the esteemed Microsoft C# MVP Jani Järvinen will be providing an overview of MVC 2.0 and Dynamic Data, while Niko Suni will cover the current state of Web Forms. Check out the registration page for a detailed agenda.

Welcome!

May 18, 2010  Tags:   Posted in: .NET  One Comment

A few fun statistics on Visual Studio 2010 source code

In episode 543 of .NET Rocks, Phil Haack revealed a few interesting tidbits about Visual Studio 2010:

  • The codebase consists of 1.5 million files. Don’t know about lines of code, but even at a reasonable 100 lines of code per file, we’d be talking about a whopping 150 million LOC.
  • Those 1.5 million files have been organized into no less than 220 000 directories, averaging about 7 files per directory.
  • A full signed build on Visual Studio takes a bit over 61 hours. The guys did manage to produce a test build in 11 hours, though.
  • 4719 bugs filed via Connect were fixed.
  • Visual Studio contains 70 000 automated UI regression tests.

I’ll reconsider the next time I whine about a bloated project.

May 7, 2010  Tags:   Posted in: .NET  7 Comments

.NET icon Brad Abrams moves on to Google

So the news is out: Brad Abrams of .NET, Silverlight and WCF fame is out of Microsoft (ok, that’s already so last week) and the next destination is Google (that’s more recent).

While I’m sad to see Microsoft lose the guy behind the holy Framework Design Guidelines and a lot of other stuff, it is something that needs to happen every now and then. But all in all, I think cross-pollination between the two technology giants is very healthy indeed.

I have realized that a big share of problems I’m seeing are actually about Microsoft vs. Google. Besides the Bing, Android and whatever battles, I frequently seem to encounter Google App Engine vs. Azure (and Google Docs vs. Microsoft BPOS) as well as GData vs. OData. Many of these questions are unnecessarily polarized by stark attitudes, but beside that, there is a whole lot of common between the offerings.

What the world really needs is people knowledgeable in both. It’s great to have people like Jon Skeet working for Google but also super-active in the Microsoft programmer scene. And again, it’s great to have somebody with as intimate Microsoft knowledge as Brad inside Google.

My hope is that the situation isn’t just used to grab the competitor’s secrets, but rather to understand things more broadly and push the envelope. Both companies have the resources and only need the vision. Microsoft’s sore points are design issues and slow execution of plans, while Google could certainly use some of Microsoft’s wisdom in creating developer communities. Good luck, Brad!

May 6, 2010  Tags:   Posted in: General  No Comments

Silverlight 3 debugging error in Visual Studio 2010

“Unable to start debugging. The application uses a version of Silverlight that is not supported by the debugger.”

Yeah, got that one. It’s actually a pretty clear error message once you understand a few things.

First, debugging Silverlight applications requires the Developer Runtime version of Silverlight. If Visual Studio installs Silverlight for you, you will get the developer version. However, since you’re somewhat likely to already have Silverlight on your computer, VS won’t install it, and you’re left without the developer version.

The developer version is easy to get from the Silverlight site, but the problem is that you’re likely to get the Silverlight 4 Developer Runtime. That won’t help you in debugging Silverlight 3 applications, so you need the Silverlight 3 developer runtime, which is considerably harder to find.

Here are the direct download links: Silverlight 3 Developer Runtime (~6.4 megs) and Silverlight 4 Developer Runtime (~8.2 megs). The sizes are important as all versions are named as Silverlight_developer.exe, and the only easy way you can tell them apart is by the file sizes.

Also note that you cannot install Silverlight 3 runtime after you’ve got version 4, so you may end up temporarily uninstalling Silverlight 4 before you install Silverlight 3. But a few reboots later, Silverlight 3 is working. At least for me, at least for now.

May 4, 2010  Tags: ,   Posted in: .NET  One Comment