Frequently Rare

Tuesday, November 29, 2005

Top 9 (yes, 9) albums

I just found a piece of paper stuffed away inside a book... it's from 6 years ago, and purports to be a list that I wrote detailing my then top 9 (yes, 9, not 10, because obviously 10 was too passé, and, lets face it, 9 is a much better number anyway. Or something.) albums.

I decided to list them here for posterity - in no particular order. I'll put up the list as it would be today at some point.


  • Gracelands, Paul Simon

  • Bridge Over Troubled Water, Simon and Garfunkel

  • Automatic for the People, REM

  • Tracy Chapman, Tracy Chapman

  • OK Computer, Radiohead

  • Expecting to Fly, the Bluetones

  • Third Eye Blind, Third Eye Blind

  • Ogden's Nut Gone Flake, The Small Faces

  • The La's, The La's



It's surprising how many I don't like anymore! Also, where are The Beatles and Bob Dylan?

Monday, November 28, 2005

Newspapers: Society is Doomed!

It seems to be the case that balanced news doesn't sell papers. Maybe no one wants to read about how things are in context anyway.

Have a quick read of the majority of newspapers and you'll probably be convinced that society is falling apart at the seams - a new ice age on the way, not enough electricity to keep people warm this winter, crime getting worse, hospitals getting worse, working until you are 734 years of age, etc, etc. Are things *this* bad?

Well I think things aren't great - they could be better, but they aren't that bleak. Not yet. I hope.

Balanced news would be nice. Or how about an alternative viewpoint? A new newspaper - the Daily Smile - only reporting on nice things.

But then it would probably be about 3 pages long. With adverts.

:-)

Thursday, November 24, 2005

Consent

I just checked dictionary.com:

1. To give assent, as to the proposal of another; agree. See Synonyms at assent.
2. Archaic. To be of the same mind or opinion.

You see, things like this and this make me angry. Really angry.

They send out the wrong message.

What follows is an opinion. However, I also happen to think it is the right one:

Consent can only be given. It cannot be taken, assumed, or forced. If a person is incapacitated then consent cannot actually be given. I feel that the concept of consent is not valid in these situations and it is an opportunistic crime to take advantage of someone under these conditions. To take advantage of another person's incapacity is cowardice too. Then there are those who pile on the drinks or seek other ways to put someone in this state - in a state where consent cannot be given, where a person cannot defend themselves, where a person cannot even remember what happened - this is even worse as it has been planned.

To say that someone deserves it because they got themselves into that situation shows an astonishing lack of understanding, compassion, honesty, and justice.

I've always felt we should strive to be better than this. I'm no expert, but people who dress up to go out on the town are going out to have a good time. I'm pretty sure they are not advertising themselves as a target. Society should be better than this.

Monday, November 21, 2005

ASP.Net, the Context Identity, and Timers/Threads

Every now and again, I like to add a post to my blog to remind me of something useful. If anyone else finds it useful, then all the better. I'll come and tidy this one up a bit later.

I write alot of ASP.Net applications at the moment. I'm a big fan of REST (REpresentational State Transfer) and AJAX too, and have used them alot recently to implement some nice solutions.

When connecting to data sources, the most common model I've encountered is the Trusted User model. In this model, the application runs in the context of a user who is trusted to access network resouces like fileshares and databases. This is not to say that users do not log on to the applications; it's just that any actions they perform that require the application to connect to a resource is usually done in the context of this trusted user. The other common model is Impersonation/Delegation, which tends to involve logging on users then using their credentials to access resources (i.e. the user is impersonated by the application, and then delegation is used to allow the application to present their credentials to remote resources).

This is all fine and dandy. You can set up either model at the application level by adding the <identity/> element in web.config, which, amongst other things, allows you to define a specific identity to run the user as. Impersonation/Delegation required a little more work if you want the credentials to survive numerous resource hops; If I remember correctly, your domain has to be native (all Windows 2000 or above with "Kerberos" authentication), and the server the application is hosted on has to have a flag set in Active Directory to allow it to be trusted for delegation.

However, when you start the application up and start a timed event or create a separate process thread (the two are basically the same thing), then things start to break. If you look at the thread identity when the timer elapses and its event fires, or some code executes in the child thread, you find it is null. This is annoying, because it means that your thread/timer event cannot make calls to other resources that require authentication.

What you need to do is grab the identity that the application starts with. You can do this most simply in Global.asax, in the Applcation_OnStart event by storing it in a field, by using

m_ImpersonationIdentity = WindowsIdentity.GetCurrent();

(you'll need to be using System.Security and System.Security.Principal).

You can then pass this identity to your other event/timer when you instantiate or start them and store them in a field there. When you want to make a remote call, you change the impersonation context:

//Create a principal
WindowsPrincipal currentPrincipal = new WindowsPrincipal(m_ImpersonationIdentity);

//Assign the principal
System.Threading.Thread.CurrentPrincipal = currentPrincipal;

//Begin an impersonation context.
WindowsImpersonationContext impersonationContext = m_ImpersonationIdentity.Impersonate();

try{
//Do Stuff
}
finally{
//Undo the impersonation context.
impersonationContext.Undo();
//"unassign" the thread principal - very important - think thread pooling.
System.Threading.Thread.CurrentPrincipal = null;
}

(Again, you'll need to be using System.Security and System.Security.Principal).

Et voila, you can now make calls in the context of whatever identity you want too when launching child threads in an ASP.Net application.

Monday, November 14, 2005

10 Things...

Why are these so hard?

10 Ways to Please Customers